Next: , Previous: , Up: Data handling   [Contents][Index]


3.3.2 Linking array

Sometimes the data arrays are so large, that one couldn’t’ copy its values to another array (i.e. into mglData). In this case, he can define its own class derived from mglDataA (see mglDataA class) or can use Link function.

In last case, MathGL just save the link to an external data array, but not copy it. You should provide the existence of this data array for whole time during which MathGL can use it. Another point is that MathGL will automatically create new array if you’ll try to modify data values by any of mglData functions. So, you should use only function with const modifier if you want still using link to the original data array.

Creating the link is rather simple – just the same as using Set function

  double *a = new double[50];
  for(int i=0;i<50;i++)   a[i] = sin(M_PI*i/49.);

  mglData y;
  y.Link(a,50);