7.4 Data filling

MGL command: list DAT v1 ...

Creates new variable with name dat and fills it by numeric values of command arguments v1 .... Command can create one-dimensional and two-dimensional arrays with arbitrary values. For creating 2d array the user should use delimiter ‘|’ which means that the following values lie in next row. Array sizes are [maximal of row sizes * number of rows]. For example, command list 1 | 2 3 creates the array [1 0; 2 3]. Note, that the maximal number of arguments is 1000.

MGL command: list DAT d1 ...

Creates new variable with name dat and fills it by data values of arrays of command arguments d1 .... Command can create two-dimensional or three-dimensional (if arrays in arguments are 2d arrays) arrays with arbitrary values. Minor dimensions of all arrays in arguments should be equal to dimensions of first array d1. In the opposite case the argument will be ignored. Note, that the maximal number of arguments is 1000.

Method on mglData: void Set (const float *A, int NX, int NY=1, int NZ=1)
Method on mglData: void Set (const double *A, int NX, int NY=1, int NZ=1)
C function: void mgl_data_set_float (HMDT dat, const mreal *A, int NX, int NY, int NZ)
C function: void mgl_data_set_double (HMDT dat, const double *A, int NX, int NY, int NZ)
Method on mglDataC: void Set (const float *A, int NX, int NY=1, int NZ=1)
Method on mglDataC: void Set (const double *A, int NX, int NY=1, int NZ=1)
Method on mglDataC: void Set (const dual *A, int NX, int NY=1, int NZ=1)
C function: void mgl_datac_set_float (HADT dat, const mreal *A, int NX, int NY, int NZ)
C function: void mgl_datac_set_double (HADT dat, const double *A, int NX, int NY, int NZ)
C function: void mgl_datac_set_complex (HADT dat, const dual *A, int NX, int NY, int NZ)

Allocates memory and copies the data from the flat float* or double* array.

Method on mglData: void Set (const float **A, int N1, int N2)
Method on mglData: void Set (const double **A, int N1, int N2)
C function: void mgl_data_set_mreal2 (HMDT dat, const mreal **A, int N1, int N2)
C function: void mgl_data_set_double2 (HMDT dat, const double **A, int N1, int N2)

Allocates memory and copies the data from the float** or double** array with dimensions N1, N2, i.e. from array defined as mreal a[N1][N2];.

Method on mglData: void Set (const float ***A, int N1, int N2)
Method on mglData: void Set (const double ***A, int N1, int N2)
C function: void mgl_data_set_mreal3 (HMDT dat, const mreal ***A, int N1, int N2)
C function: void mgl_data_set_double3 (HMDT dat, const double ***A, int N1, int N2)

Allocates memory and copies the data from the float*** or double*** array with dimensions N1, N2, N3, i.e. from array defined as mreal a[N1][N2][N3];.

Method on mglData: void Set (gsl_vector *v)
Method on mglDataC: void Set (gsl_vector *v)
C function: void mgl_data_set_vector (HMDT dat, gsl_vector *v)
C function: void mgl_datac_set_vector (HADT dat, gsl_vector *v)

Allocates memory and copies the data from the gsl_vector * structure.

Method on mglData: void Set (gsl_matrix *m)
Method on mglDataC: void Set (gsl_matrix *m)
C function: void mgl_data_set_matrix (HMDT dat, gsl_matrix *m)
C function: void mgl_datac_set_matrix (HADT dat, gsl_matrix *m)

Allocates memory and copies the data from the gsl_matrix * structure.

Method on mglData: void Set (const mglDataA &from)
Method on mglData: void Set (HCDT from)
C function: void mgl_data_set (HMDT dat, HCDT from)
Method on mglDataC: void Set (const mglDataA &from)
Method on mglDataC: void Set (HCDT from)
C function: void mgl_datac_set (HADT dat, HCDT from)

Copies the data from mglData (or mglDataA) instance from.

Method on mglDataC: void Set (const mglDataA &re, const mglDataA &im)
Method on mglDataC: void Set (HCDT re, HCDT im)
Method on mglDataC: void SetAmpl (HCDT ampl, const mglDataA &phase)
C function: void mgl_datac_set_ri (HADT dat, HCDT re, HCDT im)
C function: void mgl_datac_set_ap (HADT dat, HCDT ampl, HCDT phase)

Copies the data from mglData instances for real and imaginary parts of complex data arrays.

Method on mglData: void Set (const std::vector<int> &d)
Method on mglDataC: void Set (const std::vector<int> &d)
Method on mglData: void Set (const std::vector<float> &d)
Method on mglDataC: void Set (const std::vector<float> &d)
Method on mglData: void Set (const std::vector<double> &d)
Method on mglDataC: void Set (const std::vector<double> &d)
Method on mglDataC: void Set (const std::vector<dual> &d)

Allocates memory and copies the data from the std::vector<T> array.

Method on mglData: void Set (const char *str, int NX, int NY=1, int NZ=1)
C function: void mgl_data_set_values (const char *str, int NX, int NY, int NZ)
Method on mglDataC: void Set (const char *str, int NX, int NY=1, int NZ=1)
C function: void mgl_datac_set_values (const char *str, int NX, int NY, int NZ)

Allocates memory and scanf the data from the string.

Method on mglData: void SetList (long n, ...)

Allocate memory and set data from variable argument list of double values. Note, you need to specify decimal point ‘.’ for integer values! For example, the code SetList(2,0.,1.); is correct, but the code SetList(2,0,1); is incorrect.

Method on mglData: void Set (const arma::vec &d)
Method on mglData: void Set (const arma::mat &d)
Method on mglData: void Set (const arma::cube &d)
Method on mglDataC: void Set (const arma::vec &d)
Method on mglDataC: void Set (const arma::cx_vec &d)
Method on mglDataC: void Set (const arma::mat &d)
Method on mglDataC: void Set (const arma::cx_mat &d)
Method on mglDataC: void Set (const arma::cube &d)
Method on mglDataC: void Set (const arma::cx_cube &d)

Allocates memory and copies the data from the Armadillo structures.

Method on mglData: arma::mat arma_mat (long k=0)
Method on mglData: arma::cube arma_cube ()
Method on mglData: arma::cx_mat arma_mat (long k=0)
Method on mglData: arma::cx_cube arma_cube ()

Return data in Armadillo format.

Links external data array, i.e. don’t delete this array at exit.

MGL command: var DAT num v1 [v2=nan]

Creates new variable with name dat for one-dimensional array of size num. Array elements are equidistantly distributed in range [v1, v2]. If v2=nan then v2=v1 is used.

MGL command: fill dat v1 v2 ['dir'='x']
Method on mglData: void Fill (mreal v1, mreal v2, char dir='x')
Method on mglDataC: void Fill (dual v1, dual v2, char dir='x')
C function: void mgl_data_fill (HMDT dat, mreal v1, mreal v2, char dir)
C function: void mgl_datac_fill (HADT dat, dual v1, dual v2, char dir)

Equidistantly fills the data values to range [v1, v2] in direction dir={‘x’,‘y’,‘z’}.

MGL command: fill dat 'eq' [vdat wdat]
Method on mglData: void Fill (HMGL gr, const char *eq, const char *opt="")
Method on mglData: void Fill (HMGL gr, const char *eq, const mglDataA &vdat, const char *opt="")
Method on mglData: void Fill (HMGL gr, const char *eq, const mglDataA &vdat, const mglDataA &wdat, const char *opt="")
Method on mglDataC: void Fill (HMGL gr, const char *eq, const char *opt="")
Method on mglDataC: void Fill (HMGL gr, const char *eq, const mglDataA &vdat, const char *opt="")
Method on mglDataC: void Fill (HMGL gr, const char *eq, const mglDataA &vdat, const mglDataA &wdat, const char *opt="")
C function: void mgl_data_fill_eq (HMGL gr, HMDT dat, const char *eq, HCDT vdat, HCDT wdat, const char *opt)
C function: void mgl_datac_fill_eq (HMGL gr, HADT dat, const char *eq, HCDT vdat, HCDT wdat, const char *opt)

Fills the value of array according to the formula in string eq. Formula is an arbitrary expression depending on variables ‘x’, ‘y’, ‘z’, ‘u’, ‘v’, ‘w’. Coordinates ‘x’, ‘y’, ‘z’ are supposed to be normalized in axis range of canvas gr (in difference from Modify functions). Variables ‘i’, ‘j’, ‘k’ denote corresponding index. At this, zero value is used for variables if corresponding dimension is absent in the data. Variable ‘u’ is the original value of the array. Variables ‘v’ and ‘w’ are values of vdat, wdat which can be NULL (i.e. can be omitted).

MGL command: modify dat 'eq' [dim=0]
MGL command: modify dat 'eq' vdat [wdat]
Method on mglData: void Modify (const char *eq, int dim=0)
Method on mglData: void Modify (const char *eq, const mglDataA &v)
Method on mglData: void Modify (const char *eq, const mglDataA &v, const mglDataA &w)
Method on mglDataC: void Modify (const char *eq, int dim=0)
Method on mglDataC: void Modify (const char *eq, const mglDataA &v)
Method on mglDataC: void Modify (const char *eq, const mglDataA &v, const mglDataA &w)
C function: void mgl_data_modify (HMDT dat, const char *eq, int dim)
C function: void mgl_data_modify_vw (HMDT dat, const char *eq, HCDT v, HCDT w)
C function: void mgl_datac_modify (HADT dat, const char *eq, int dim)
C function: void mgl_datac_modify_vw (HADT dat, const char *eq, HCDT v, HCDT w)

The same as previous ones but coordinates ‘x’, ‘y’, ‘z’ are supposed to be normalized in range [0,1]. Variables ‘i’, ‘j’, ‘k’ denote corresponding index. At this, zero value is used for variables if corresponding dimension is absent in the data. If dim>0 is specified then modification will be fulfilled only for slices >=dim.

MGL command: fillsample dat 'how'
Method on mglData: void FillSample (const char *how)
C function: void mgl_data_fill_sample (HMDT a, const char *how)

Fills data by ’x’ or ’k’ samples for Hankel (’h’) or Fourier (’f’) transform.

MGL command: datagrid dat xdat ydat zdat
Method on mglData: mglData Grid (HMGL gr, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *opt="")
Method on mglData: mglData Grid (const mglDataA &x, const mglDataA &y, const mglDataA &z, mglPoint p1, mglPoint p2)
C function: void mgl_data_grid (HMGL gr, HMDT u, HCDT x, HCDT y, HCDT z, const char *opt)
C function: void mgl_data_grid_xy (HMDT u, HCDT x, HCDT y, HCDT z, mreal x1, mreal x2, mreal y1, mreal y2)

Fills the value of array according to the linear interpolation of triangulated surface assuming x-,y-coordinates equidistantly distributed in axis range (or in range [x1,x2]*[y1,y2]). Triangulated surface is found for arbitrary placed points ‘x’, ‘y’, ‘z’. NAN value is used for grid points placed outside of triangulated surface. See Making regular data, for sample code and picture.

MGL command: put dat val [i=all j=all k=all]
Method on mglData: void Put (mreal val, int i=-1, int j=-1, int k=-1)
Method on mglDataC: void Put (dual val, int i=-1, int j=-1, int k=-1)
C function: void mgl_data_put_val (HMDT a, mreal val, int i, int j, int k)
C function: void mgl_datac_put_val (HADT a, dual val, int i, int j, int k)

Sets value(s) of array a[i, j, k] = val. Negative indexes i, j, k=-1 set the value val to whole range in corresponding direction(s). For example, Put(val,-1,0,-1); sets a[i,0,j]=val for i=0...(nx-1), j=0...(nz-1).

MGL command: put dat vdat [i=all j=all k=all]
Method on mglData: void Put (const mglDataA &v, int i=-1, int j=-1, int k=-1)
Method on mglDataC: void Put (const mglDataA &v, int i=-1, int j=-1, int k=-1)
C function: void mgl_data_put_dat (HMDT a, HCDT v, int i, int j, int k)
C function: void mgl_datac_put_dat (HADT a, HCDT v, int i, int j, int k)

Copies value(s) from array v to the range of original array. Negative indexes i, j, k=-1 set the range in corresponding direction(s). At this minor dimensions of array v should be large than corresponding dimensions of this array. For example, Put(v,-1,0,-1); sets a[i,0,j]=v.ny>nz ? v[i,j] : v[i], where i=0...(nx-1), j=0...(nz-1) and condition v.nx>=nx is true.

MGL command: refill dat xdat vdat [sl=-1]
MGL command: refill dat xdat ydat vdat [sl=-1]
MGL command: refill dat xdat ydat zdat vdat
Method on mglData: void Refill (const mglDataA &x, const mglDataA &v, mreal x1, mreal x2, long sl=-1)
Method on mglData: void Refill (const mglDataA &x, const mglDataA &v, mglPoint p1, mglPoint p2, long sl=-1)
Method on mglData: void Refill (const mglDataA &x, const mglDataA &y, const mglDataA &v, mglPoint p1, mglPoint p2, long sl=-1)
Method on mglData: void Refill (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &v, mglPoint p1, mglPoint p2)
Method on mglData: void Refill (HMGL gr, const mglDataA &x, const mglDataA &v, long sl=-1, const char *opt="")
Method on mglData: void Refill (HMGL gr, const mglDataA &x, const mglDataA &y, const mglDataA &v, long sl=-1, const char *opt="")
Method on mglData: void Refill (HMGL gr, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &v, const char *opt="")
C function: void mgl_data_refill_x (HMDT a, HCDT x, HCDT v, mreal x1, mreal x2, long sl)
C function: void mgl_data_refill_xy (HMDT a, HCDT x, HCDT y, HCDT v, mreal x1, mreal x2, mreal y1, mreal y2, long sl)
C function: void mgl_data_refill_xyz (HMDT a, HCDT x, HCDT y, HCDT z, HCDT v, mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2)
C function: void mgl_data_refill_gr (HMGL gr, HMDT a, HCDT x, HCDT y, HCDT z, HCDT v, long sl, const char *opt)

Fills by interpolated values of array v at the point {x, y, z}={X[i], Y[j], Z[k]} (or {x, y, z}={X[i,j,k], Y[i,j,k], Z[i,j,k]} if x, y, z are not 1d arrays), where X,Y,Z are equidistantly distributed in range [x1,x2]*[y1,y2]*[z1,z2] and have the same sizes as this array. If parameter sl is 0 or positive then changes will be applied only for slice sl.

MGL command: gspline dat xdat vdat [sl=-1]
Method on mglData: void RefillGS (const mglDataA &x, const mglDataA &v, mreal x1, mreal x2, long sl=-1)
C function: void mgl_data_refill_gs (HMDT a, HCDT x, HCDT v, mreal x1, mreal x2, long sl)

Fills by global cubic spline values of array v at the point x=X[i], where X are equidistantly distributed in range [x1,x2] and have the same sizes as this array. If parameter sl is 0 or positive then changes will be applied only for slice sl.

MGL command: idset dat 'ids'
Method on mglData: void SetColumnId (const char *ids)
Method on mglDataC: void SetColumnId (const char *ids)
C function: void mgl_data_set_id (HMDT a, const char *ids)
C function: void mgl_datac_set_id (HADT a, const char *ids)

Sets the symbol ids for data columns. The string should contain one symbol ’a’...’z’ per column. These ids are used in column.

MGL command: bernoulli dat [p=0.5]
Method on mglData: void RndBernoulli (mreal p=0.5)
C function: void mgl_data_rnd_bernoulli (HMDT dat, mreal p)
C function: mreal mgl_rnd_bernoulli (mreal p)

Fills data by random numbers of Bernoulli distribution with probability p.

MGL command: binomial dat n [p=0.5]
Method on mglData: void RndBinomial (long n, mreal p=0.5)
C function: void mgl_data_rnd_binomial (HMDT dat, long n, mreal p)
C function: mreal mgl_rnd_binomial (long n, mreal p)

Fills by random numbers according to binomial distribution in n coin flips with probability p.

MGL command: brownian dat y1 y2 sigma h
Method on mglData: void RndBrownian (mreal y1, mreal y2, mreal sigma, mreal h)
C function: void mgl_data_rnd_brownian (HMDT dat, mreal y1, mreal y2, mreal sigma, mreal h)

Fills by fractional brownian motion.

MGL command: discrete dat vdat
Method on mglData: void RndDiscrete (const mglDataA &vdat)
C function: void mgl_data_rnd_discrete (HMDT dat, HCDT vdat)
C function: mreal mgl_rnd_discrete (HCDT vdat)

Fills by random numbers according to discrete distribution.

MGL command: exponential dat [p]
Method on mglData: void RndExponential (mreal p)
C function: void mgl_data_rnd_exponential (HMDT dat, mreal p)
C function: mreal mgl_rnd_exponential (mreal p)

Fills by random numbers according to exponential distribution with scale p.

MGL command: gaussian dat [mu=0 sigma=1]
Method on mglData: void RndGaussian (mreal mu=0, mreal sigma=1)
C function: void mgl_data_rnd_gaussian (HMDT dat, mreal mu, mreal sigma)
C function: mreal mgl_rnd_gaussian (mreal mu, mreal sigma)

Fills by random numbers according to Gaussian distribution with average mu and scale sigma.

MGL command: shuffle dat ['dir'='a']
Method on mglData: void RndShuffle (char dir='a')
C function: void mgl_data_rnd_shuffle (HMDT dat, char dir)

Shuffle data cells (for dir=‘a’) or slices (for dir=‘xyz’).

MGL command: uniform dat lo hi
Method on mglData: void RndUniform (mreal lo, mreal hi)
C function: void mgl_data_rnd_uniform (HMDT dat, mreal lo, mreal hi)
C function: mreal mgl_rnd_uniform (mreal lo, mreal hi)

Fills by random numbers uniformly chosen in (lo,hi).

MGL command: uniformint dat lo hi
Method on mglData: void RndInteger (long lo, long hi)
C function: void mgl_data_rnd_integer (HMDT dat, long lo, mreal hi)
C function: long mgl_rnd_integer (long lo, long hi)

Fills by random integers uniformly chosen in [lo,hi).