Data processing
***************

nav

This chapter describe classes mglData and mglDataC for working with data arrays of real and complex numbers. Both classes are derived from abstract class mglDataA, and can be used as arguments of any plotting functions (see MathGL core). These classes are defined in #include <mgl2/data.h> and #include <mgl2/datac.h> correspondingly. The classes have mostly the same set of functions for easy and safe allocation, resizing, loading, saving, modifying of data arrays. Also it can numerically differentiate and integrate data, interpolate, fill data by formula and so on. Classes support data with dimensions up to 3 (like function of 3 variables -- x,y,z). The internal representation of numbers is mreal (or dual=std::complex<mreal> for mglDataC), which can be configured as float or double by selecting option --enable-double at the MathGL configuring (see Installation). Float type have smaller size in memory and usually it has enough precision in plotting purposes. However, double type provide high accuracy what can be important for time-axis, for example. Data arrays are denoted by Small Caps (like DAT) if it can be (re-)created by MGL commands.

external

Public variables
================

nav

 -- Variable of mglData: mreal * a
 -- Variable of mglDataC: dual * a
     Data array itself. The flat data representation is used. For example, matrix [nx x ny] is presented as flat (1d-) array with length nx*ny. The element with indexes {i, j, k} is a[i+nx*j+nx*ny*k] (indexes are zero based).

 -- Variable of mglData: long nx
 -- Variable of mglDataC: long nx
     Number of points in 1st dimensions ('x' dimension).

 -- Variable of mglData: long ny
 -- Variable of mglDataC: long ny
     Number of points in 2nd dimensions ('y' dimension).

 -- Variable of mglData: long nz
 -- Variable of mglDataC: long nz
     Number of points in 3d dimensions ('z' dimension).

 -- Variable of mglData: std::string id
 -- Variable of mglDataC: std::string id
     Names of column (or slice if nz>1)  -- one character per column.

 -- Variable of mglData: bool link
 -- Variable of mglDataC: bool link
     Flag to use external data, i.e. don't delete it.

 -- Variable of mglDataA: std::wstring s
     Name of data. It is used in parsing of MGL scripts.

 -- Variable of mglDataA: bool temp
     Flag of temporary variable, which should be deleted.

 -- Variable of mglDataA: void (*)(void *) func
     Pointer to callback function which will be called at destroying.

 -- Variable of mglDataA: void * o
     Pointer to object for callback function.

 -- Method on mglData: mreal GetVal (long i)
 -- Method on mglDataC: mreal GetVal (long i)
 -- Method on mglData: void SetVal (mreal val, long i)
 -- Method on mglDataC: void SetVal (mreal val, long i)
     Gets or sets the value in by "flat" index I without border checking. Index I should be in range [0, nx*ny*nz-1].

 -- Method on mglDataA: long GetNx ()
 -- Method on mglDataA: long GetNy ()
 -- Method on mglDataA: long GetNz ()
 -- C function: long mgl_data_get_nx (HCDT dat)
 -- C function: long mgl_data_get_ny (HCDT dat)
 -- C function: long mgl_data_get_nz (HCDT dat)
     Gets the x-, y-, z-size of the data.

 -- C function: mreal mgl_data_get_value (HCDT dat, int i, int j, int k)
 -- C function: dual mgl_datac_get_value (HCDT dat, int i, int j, int k)
 -- C function: mreal * mgl_data_value (HMDT dat, int i, int j, int k)
 -- C function: dual * mgl_datac_value (HADT dat, int i, int j, int k)
 -- C function: void mgl_data_set_value (HMDT dat, mreal v, int i, int j, int k)
 -- C function: void mgl_datac_set_value (HADT dat, dual v, int i, int j, int k)
     Gets or sets the value in specified cell of the data with border checking.

 -- C function: const mreal * mgl_data_data (HCDT dat)
 -- C function: const dual * mgl_datac_data (HCDT dat)
     Returns pointer to internal data array.

 -- C function only: void mgl_data_set_func (mglDataA *dat, void (*func)(void *), void *par)
     Set pointer to callback function which will be called at destroying.

 -- C function: void mgl_data_set_name (mglDataA *dat, const char *name)
 -- C function: void mgl_data_set_name_w (mglDataA *dat, const wchar_t *name)
     Set name of data, which used in parsing of MGL scripts.

external

Data constructor
================

nav

 -- MGL command: new DAT [nx=1 'eq']
 -- MGL command: new DAT nx ny ['eq']
 -- MGL command: new DAT nx ny nz ['eq']
 -- Constructor on mglData: mglData (int mx=1, int my=1, int mz=1)
 -- Constructor on mglDataC: mglDataC (int mx=1, int my=1, int mz=1)
 -- C function: HMDT mgl_create_data ()
 -- C function: HMDT mgl_create_data_size (int mx, int my, int mz)
 -- C function: HADT mgl_create_datac ()
 -- C function: HADT mgl_create_datac_size (int mx, int my, int mz)
     Default constructor. Allocates the memory for data array and initializes it by zero. If string EQ is specified then data will be filled by corresponding formula as in fill.

 -- MGL command: copy DAT dat2 ['eq'='']
 -- MGL command: copy DAT val
 -- Constructor on mglData: mglData (const mglDataA &dat2)
 -- Constructor on mglData: mglData (const mglDataA *dat2)
 -- Constructor on mglData: mglData (int size, const float *dat2)
 -- Constructor on mglData: mglData (int size, int cols, const float *dat2)
 -- Constructor on mglData: mglData (int size, const double *dat2)
 -- Constructor on mglData: mglData (int size, int cols, const double *dat2)
 -- Constructor on mglData: mglData (const double *dat2, int size)
 -- Constructor on mglData: mglData (const double *dat2, int size, int cols)
 -- Constructor on mglDataC: mglDataC (const mglDataA &dat2)
 -- Constructor on mglDataC: mglDataC (const mglDataA *dat2)
 -- Constructor on mglDataC: mglDataC (int size, const float *dat2)
 -- Constructor on mglDataC: mglDataC (int size, int cols, const float *dat2)
 -- Constructor on mglDataC: mglDataC (int size, const double *dat2)
 -- Constructor on mglDataC: mglDataC (int size, int cols, const double *dat2)
 -- Constructor on mglDataC: mglDataC (int size, const dual *dat2)
 -- Constructor on mglDataC: mglDataC (int size, int cols, const dual *dat2)
     Copy constructor. Allocates the memory for data array and copy values from other array. At this, if parameter EQ or VAL is specified then the data will be modified by corresponding formula similarly to fill.

 -- MGL command: copy REDAT IMDAT dat2 ['eq'='']
     Allocates the memory for data array and copy real and imaginary values from complex array DAT2.

 -- MGL command: copy 'name'
     Allocates the memory for data array and copy values from other array specified by its name, which can be "invalid" for MGL names (like one read from HDF5 files).

 -- MGL command: read DAT 'fname'
 -- Constructor on mglData: mglData (const char *fname)
 -- Constructor on mglDataC: mglDataC (const char *fname)
 -- C function: HMDT mgl_create_data_file (const char *fname)
 -- C function: HADT mgl_create_datac_file (const char *fname)
     Reads data from tab-separated text file with auto determining sizes of the data.

 -- MGL command: delete dat
 -- MGL command: delete 'name'
 -- Destructor on mglData: ~mglData ()
 -- C function: void mgl_delete_data (HMDT dat)
 -- Destructor on mglDataC: ~mglDataC ()
 -- C function: void mgl_delete_datac (HADT dat)
     Deletes the data array from memory.

external

Data resizing
=============

nav

 -- MGL command: new DAT [nx=1 ny=1 nz=1]
 -- Method on mglData: void Create (int mx, int my=1, int mz=1)
 -- Method on mglDataC: void Create (int mx, int my=1, int mz=1)
 -- C function: void mgl_data_create (HMDT dat, int mx, int my, int mz)
 -- C function: void mgl_datac_create (HADT dat, int mx, int my, int mz)
     Creates or recreates the array with specified size and fills it by zero. This function does nothing if one of parameters MX, MY, MZ is zero or negative.

 -- MGL command: rearrange dat mx [my=0 mz=0]
 -- Method on mglData: void Rearrange (int mx, int my=0, int mz=0)
 -- Method on mglDataC: void Rearrange (int mx, int my=0, int mz=0)
 -- C function: void mgl_data_rearrange (HMDT dat, int mx, int my, int mz)
 -- C function: void mgl_datac_rearrange (HADT dat, int mx, int my, int mz)
     Rearrange dimensions without changing data array so that resulting sizes should  be MX*MY*MZ < nx*ny*nz. If some of parameter MY or MZ are zero then it will be selected to optimal fill of data array. For example, if MY=0 then it will be change to MY=nx*ny*nz/MX and MZ=1.

 -- MGL command: transpose dat ['dim'='yxz']
 -- Method on mglData: void Transpose (const char *dim="yx")
 -- Method on mglDataC: void Transpose (const char *dim="yx")
 -- C function: void mgl_data_transpose (HMDT dat, const char *dim)
 -- C function: void mgl_datac_transpose (HADT dat, const char *dim)
     Transposes (shift order of) dimensions of the data. New order of dimensions is specified in string DIM. This function can be useful also after reading of one-dimensional data.

 -- MGL command: extend dat n1 [n2=0]
 -- Method on mglData: void Extend (int n1, int n2=0)
 -- Method on mglDataC: void Extend (int n1, int n2=0)
 -- C function: void mgl_data_extend (HMDT dat, int n1, int n2)
 -- C function: void mgl_datac_extend (HADT dat, int n1, int n2)
     Increase the dimensions of the data by inserting new (|N1|+1)-th slices after (for N1>0) or before (for N1<0) of existed one. It is possible to insert 2 dimensions simultaneously for 1d data by using parameter N2. Data to new slices is copy from existed one. For example, for N1>0 new array will be
     a_ij^new = a_i^old where j=0...N1. Correspondingly, for N1<0 new array will be a_ij^new = a_j^old where i=0...|N1|.

 -- MGL command: squeeze dat rx [ry=1 rz=1 sm=off]
 -- Method on mglData: void Squeeze (int rx, int ry=1, int rz=1, bool smooth=false)
 -- Method on mglDataC: void Squeeze (int rx, int ry=1, int rz=1, bool smooth=false)
 -- C function: void mgl_data_squeeze (HMDT dat, int rx, int ry, int rz, int smooth)
 -- C function: void mgl_datac_squeeze (HADT dat, int rx, int ry, int rz, int smooth)
     Reduces the data size by excluding data elements which indexes are not divisible by RX, RY, RZ correspondingly. Parameter SMOOTH set to use smoothing (i.e. out[i]=\sum_{j=i,i+r} a[j]/r) or not (i.e. out[i]=a[j*r]).

 -- MGL command: crop dat n1 n2 'dir'
 -- Method on mglData: void Crop (int n1, int n2, char dir='x')
 -- Method on mglDataC: void Crop (int n1, int n2, char dir='x')
 -- C function: void mgl_data_crop (HMDT dat, int n1, int n2, char dir)
 -- C function: void mgl_datac_crop (HADT dat, int n1, int n2, char dir)
     Cuts off edges of the data I<N1 and I>N2 if N2>0 or I>n[xyz]-N2 if N2<=0 along direction DIR.

 -- MGL command: crop dat 'how'
 -- Method on mglData: void Crop (const char *how="235x")
 -- Method on mglDataC: void Crop (const char *how="235x")
 -- C function: void mgl_data_crop_opt (HMDT dat, const char *how)
 -- C function: void mgl_datac_crop_opt (HADT dat, const char *how)
     Cuts off far edge of the data to be more optimal for fast Fourier transform. The resulting size will be the closest value of 2^n*3^m*5^l to the original one. The string HOW may contain: x, y, z for directions, and 2, 3, 5 for using corresponding bases.

 -- MGL command: insert dat 'dir' [pos=off num=0]
 -- Method on mglData: void Insert (char dir, int pos=0, int num=1)
 -- Method on mglDataC: void Insert (char dir, int pos=0, int num=1)
 -- C function: void mgl_data_insert (HMDT dat, char dir, int pos, char num)
 -- C function: void mgl_datac_insert (HADT dat, char dir, int pos, char num)
     Insert NUM slices along DIR-direction at position POS and fill it by zeros.

 -- MGL command: delete dat 'dir' [pos=off num=0]
 -- Method on mglData: void Delete (char dir, int pos=0, int num=1)
 -- Method on mglDataC: void Delete (char dir, int pos=0, int num=1)
 -- C function: void mgl_data_delete (HMDT dat, char dir, int pos, char num)
 -- C function: void mgl_datac_delete (HADT dat, char dir, int pos, char num)
     Delete NUM slices along DIR-direction at position POS.

 -- MGL command: delete dat
 -- MGL command: delete 'name'
     Deletes the whole data array.

 -- MGL command: sort dat idx [idy=-1]
 -- Method on mglData: void Sort (lond idx, long idy=-1)
 -- C function: void mgl_data_sort (HMDT dat, lond idx, long idy)
     Sort data rows (or slices in 3D case) by values of specified column IDX (or cell {IDX,IDY} for 3D case). Note, this function is not thread safe!

 -- MGL command: clean dat idx
 -- Method on mglData: void Clean (lond idx)
 -- C function: void mgl_data_clean (HMDT dat, lond idx)
     Delete rows which values are equal to next row for given column IDX.

 -- MGL command: join dat vdat [v2dat ...]
 -- Method on mglData: void Join (const mglDataA &vdat)
 -- Method on mglDataC: void Join (const mglDataA &vdat)
 -- C function: void mgl_data_join (HMDT dat, HCDT vdat)
 -- C function: void mgl_datac_join (HADT dat, HCDT vdat)
     Join data cells from VDAT to DAT. At this, function increase DAT sizes according following: z-size for data arrays arrays with equal x-,y-sizes; or y-size for data arrays with equal x-sizes; or x-size otherwise.

external

Data filling
============

nav

 -- 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.

 -- Method on mglData: void Link (mglData &from)
 -- Method on mglData: void Link (mreal *A, int NX, int NY=1, int NZ=1)
 -- C function: void mgl_data_link (HMDT dat, mreal *A, int NX, int NY, int NZ)
 -- Method on mglDataC: void Link (mglDataC &from)
 -- Method on mglDataC: void Link (dual *A, int NX, int NY=1, int NZ=1)
 -- C function: void mgl_datac_link (HADT dat, dual *A, int NX, int NY, int NZ)
     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. Making regular data

 -- 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).

external

File I/O
========

nav

 -- MGL command: read DAT 'fname'
 -- MGL command: read REDAT IMDAT 'fname'
 -- Method on mglData: bool Read (const char *fname)
 -- Method on mglDataC: bool Read (const char *fname)
 -- C function: int mgl_data_read (HMDT dat, const char *fname)
 -- C function: int mgl_datac_read (HADT dat, const char *fname)
     Reads data from tab-separated text file with auto determining sizes of the data. Double newline means the beginning of new z-slice.

 -- MGL command: read DAT 'fname' mx [my=1 mz=1]
 -- MGL command: read REDAT IMDAT 'fname' mx [my=1 mz=1]
 -- Method on mglData: bool Read (const char *fname, int mx, int my=1, int mz=1)
 -- Method on mglDataC: bool Read (const char *fname, int mx, int my=1, int mz=1)
 -- C function: int mgl_data_read_dim (HMDT dat, const char *fname, int mx, int my, int mz)
 -- C function: int mgl_datac_read_dim (HADT dat, const char *fname, int mx, int my, int mz)
     Reads data from text file with specified data sizes. This function does nothing if one of parameters MX, MY or MZ is zero or negative.

 -- MGL command: readmat DAT 'fname' [dim=2]
 -- Method on mglData: bool ReadMat (const char *fname, int dim=2)
 -- Method on mglDataC: bool ReadMat (const char *fname, int dim=2)
 -- C function: int mgl_data_read_mat (HMDT dat, const char *fname, int dim)
 -- C function: int mgl_datac_read_mat (HADT dat, const char *fname, int dim)
     Read data from text file with size specified at beginning of the file by first DIM numbers. At this, variable DIM set data dimensions.

 -- MGL command: readall DAT 'templ' v1 v2 [dv=1 slice=off]
 -- Method on mglData: void ReadRange (const char *templ, mreal from, mreal to, mreal step=1, bool as_slice=false)
 -- Method on mglDataC: void ReadRange (const char *templ, mreal from, mreal to, mreal step=1, bool as_slice=false)
 -- C function: int mgl_data_read_range (HMDT dat, const char *templ, mreal from, mreal to, mreal step, int as_slice)
 -- C function: int mgl_datac_read_range (HADT dat, const char *templ, mreal from, mreal to, mreal step, int as_slice)
     Join data arrays from several text files. The file names are determined by function call sprintf(fname,templ,val);, where VAL changes from FROM to TO with step STEP. The data load one-by-one in the same slice if AS_SLICE=false or as slice-by-slice if AS_SLICE=true.

 -- MGL command: readall DAT 'templ' [slice=off]
 -- Method on mglData: void ReadAll (const char *templ, bool as_slice=false)
 -- Method on mglDataC: void ReadAll (const char *templ, bool as_slice=false)
 -- C function: int mgl_data_read_all (HMDT dat, const char *templ, int as_slice)
 -- C function: int mgl_datac_read_all (HADT dat, const char *templ, int as_slice)
     Join data arrays from several text files which filenames satisfied the template TEMPL (for example, TEMPL="t_*.dat"). The data load one-by-one in the same slice if AS_SLICE=false or as slice-by-slice if AS_SLICE=true.

 -- MGL command: scanfile DAT 'fname' 'templ'
 -- Method on mglData: bool ScanFile (const char *fname, const char *templ)
 -- C function: int mgl_data_scan_file (HMDT dat, const char *fname, const char *templ)
     Read file FNAME line-by-line and scan each line for numbers according the template TEMPL. The numbers denoted as %g in the template. Saving and scanning file

 -- MGL command: save dat 'fname'
 -- Method on mglDataA: void Save (const char *fname, int ns=-1) const
 -- C function: void mgl_data_save (HCDT dat, const char *fname, int ns)
 -- C function: void mgl_datac_save (HCDT dat, const char *fname, int ns)
     Saves the whole data array (for NS=-1) or only NS-th slice to the text file FNAME.

 -- MGL command: save val dat 'fname'
     Saves the value VAL to the text file FNAME.

 -- MGL command: save 'str' 'fname' ['mode'='a']
     Saves the string STR to the text file FNAME. For parameter MODE=a will append string to the file (default); for MODE=w will overwrite the file. Saving and scanning file

 -- MGL command: readhdf DAT 'fname' 'dname'
 -- Method on mglData: void ReadHDF (const char *fname, const char *dname)
 -- Method on mglDataC: void ReadHDF (const char *fname, const char *dname)
 -- C function: void mgl_data_read_hdf (HMDT dat, const char *fname, const char *dname)
 -- C function: void mgl_datac_read_hdf (HADT dat, const char *fname, const char *dname)
     Reads data array named DNAME from HDF5 or HDF4 file. This function does nothing if HDF5|HDF4 was disabled during library compilation.

 -- MGL command: savehdf dat 'fname' 'dname' [rewrite=off]
 -- Method on mglDataA: void SaveHDF (const char *fname, const char *dname, bool rewrite=false) const
 -- C function: void mgl_data_save_hdf (HCDT dat, const char *fname, const char *dname, int rewrite)
 -- C function: void mgl_datac_save_hdf (HCDT dat, const char *fname, const char *dname, int rewrite)
     Saves data array named DNAME to HDF5 file. This function does nothing if HDF5 was disabled during library compilation.

 -- MGL command: savehdf val 'fname' 'dname' [rewrite=off]
 -- C function: void mgl_real_save_hdf (real val, const char *fname, const char *dname, int rewrite)
 -- C function: void mgl_dual_save_hdf (dual val, const char *fname, const char *dname, int rewrite)
 -- C function: void mgl_int_save_hdf (long val, const char *fname, const char *dname, int rewrite)
     Saves value val named DNAME to HDF5 file. This function does nothing if HDF5 was disabled during library compilation.

 -- MGL command: datas 'fname'
 -- Method on mglDataA: int DatasHDF (const char *fname, char *buf, long size) static
 -- C function: int mgl_datas_hdf (const char *fname, char *buf, long size)
     Put data names from HDF5 file FNAME into BUF as '\t' separated fields. In MGL version the list of data names will be printed as message. This function does nothing if HDF5 was disabled during library compilation.

 -- MGL command: openhdf 'fname'
 -- Method on mglParse: void OpenHDF (const char *fname)
 -- C function: void mgl_parser_openhdf (HMPR pr, const char *fname)
     Reads all data array from HDF5 file FNAME and create MGL variables with names of data names in HDF file. Complex variables will be created if data name starts with !.

 -- C function: const char * const * mgl_datas_hdf_str (HMPR pr, const char *fname)
     Put HDF data names as list of strings (last one is ""). The result is valid untill next call of the function.

 -- MGL command: import DAT 'fname' 'sch' [v1=0 v2=1]
 -- Method on mglData: void Import (const char *fname, const char *scheme, mreal v1=0, mreal v2=1)
 -- C function: void mgl_data_import (HMDT dat, const char *fname, const char *scheme, mreal v1, mreal v2)
     Reads data from bitmap file (now support only PNG format). The RGB values of bitmap pixels are transformed to mreal values in range [V1, V2] using color scheme SCHEME (see Color scheme).

 -- MGL command: export dat 'fname' 'sch' [v1=0 v2=0]
 -- Method on mglDataA: void Export (const char *fname, const char *scheme, mreal v1=0, mreal v2=0, int ns=-1) const
 -- C function: void mgl_data_export (HMDT dat, const char *fname, const char *scheme, mreal v1, mreal v2, int ns) const
     Saves data matrix (or ns-th slice for 3d data) to bitmap file (now support only PNG format). The data values are transformed from range [V1, V2] to RGB pixels of bitmap using color scheme SCHEME (see Color scheme). If V1>=V2 then the values of V1, V2 are automatically determined as minimal and maximal value of the data array.

 -- MGL command: readbin dat 'fname' type
 -- Method on mglData: bool ReadBin (const char *fname, int type)
 -- C function: int mgl_data_read_bin (HMDT dat, const char *fname, int type)
     Reads data from binary file. Parameter TYPE determine the number format: 0 - double, 1 - float, 2 - long double, 3 - long int, 4 - int, 5 - short int, 6 - char. NOTE: this function may not correctly read binary files written in different CPU kind! It is better to use HDF files, see readhdf.

external

Make another data
=================

nav

 -- MGL command: subdata RES dat xx [yy=all zz=all]
 -- Method on mglData: mglData SubData (mreal xx, mreal yy=-1, mreal zz=-1) const
 -- Method on mglDataC: mglData SubData (mreal xx, mreal yy=-1, mreal zz=-1) const
 -- C function: HMDT mgl_data_subdata (HCDT dat, mreal xx, mreal yy, mreal zz)
     Extracts sub-array data from the original data array keeping fixed positive index. For example SubData(-1,2) extracts 3d row (indexes are zero based), SubData(4,-1) extracts 5th column, SubData(-1,-1,3) extracts 4th slice and so on. If argument(s) are non-integer then linear interpolation between slices is used. In MGL version this command usually is used as inline one dat(xx,yy,zz). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: subdata RES dat xdat [ydat zdat]
 -- Method on mglData: mglData SubData (const mglDataA &xx, const mglDataA &yy, const mglDataA &zz) const
 -- Method on mglDataC: mglData SubData (const mglDataA &xx, const mglDataA &yy, const mglDataA &zz) const
 -- Method on mglData: mglData SubData (const mglDataA &xx, const mglDataA &yy) const
 -- Method on mglDataC: mglData SubData (const mglDataA &xx, const mglDataA &yy) const
 -- Method on mglData: mglData SubData (const mglDataA &xx) const
 -- Method on mglDataC: mglData SubData (const mglDataA &xx) const
 -- C function: HMDT mgl_data_subdata_ext (HCDT dat, HCDT xx, HCDT yy, HCDT zz)
 -- C function: HADT mgl_datac_subdata_ext (HCDT dat, HCDT xx, HCDT yy, HCDT zz)
     Extracts sub-array data from the original data array for indexes specified by arrays XX, YY, ZZ (indirect access). This function work like previous one for 1D arguments or numbers, and resulting array dimensions are equal dimensions of 1D arrays for corresponding direction. For 2D and 3D arrays in arguments, the resulting array have the same dimensions as input arrays. The dimensions of all argument must be the same (or to be scalar 1*1*1) if they are 2D or 3D arrays. In MGL version this command usually is used as inline one dat(xx,yy,zz). Function return NULL or create empty data if data cannot be created for given arguments. In C function some of XX, YY, ZZ can be NULL.

 -- MGL command: column RES dat 'eq'
 -- Method on mglData: mglData Column (const char *eq) const
 -- Method on mglDataC: mglData Column (const char *eq) const
 -- C function: HMDT mgl_data_column (HCDT dat, const char *eq)
     Get column (or slice) of the data filled by formula EQ on column ids. For example, Column("n*w^2/exp(t)");. The column ids must be defined first by idset function or read from files. In MGL version this command usually is used as inline one dat('eq'). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: resize RES dat mx [my=1 mz=1]
 -- Method on mglData: mglData Resize (int mx, int my=0, int mz=0, mreal x1=0, mreal x2=1, mreal y1=0, mreal y2=1, mreal z1=0, mreal z2=1) const
 -- Method on mglDataC: mglData Resize (int mx, int my=0, int mz=0, mreal x1=0, mreal x2=1, mreal y1=0, mreal y2=1, mreal z1=0, mreal z2=1) const
 -- C function: HMDT mgl_data_resize (HCDT dat, int mx, int my, int mz)
 -- C function: HMDT mgl_data_resize_box (HCDT dat, int mx, int my, int mz, mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2)
     Resizes the data to new size MX, MY, MZ from box (part) [X1,X2] x [Y1,Y2] x [Z1,Z2] of original array. Initially x,y,z coordinates are supposed to be in [0,1]. If one of sizes MX, MY or MZ is 0 then initial size is used. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: evaluate RES dat idat [norm=on]
 -- MGL command: evaluate RES dat idat jdat [norm=on]
 -- MGL command: evaluate RES dat idat jdat kdat [norm=on]
 -- Method on mglData: mglData Evaluate (const mglDataA &idat, bool norm=true) const
 -- Method on mglData: mglData Evaluate (const mglDataA &idat, const mglDataA &jdat, bool norm=true) const
 -- Method on mglData: mglData Evaluate (const mglDataA &idat, const mglDataA &jdat, const mglDataA &kdat, bool norm=true) const
 -- Method on mglDataC: mglData Evaluate (const mglDataA &idat, bool norm=true) const
 -- Method on mglDataC: mglData Evaluate (const mglDataA &idat, const mglDataA &jdat, bool norm=true) const
 -- Method on mglDataC: mglData Evaluate (const mglDataA &idat, const mglDataA &jdat, const mglDataA &kdat, bool norm=true) const
 -- C function: HMDT mgl_data_evaluate (HCDT dat, HCDT idat, HCDT jdat, HCDT kdat, int norm)
     Gets array which values is result of interpolation of original array for coordinates from other arrays. All dimensions must be the same for data IDAT, JDAT, KDAT. Coordinates from IDAT, JDAT, KDAT are supposed to be normalized in range [0,1] (if NORM=true) or in ranges [0,nx], [0,ny], [0,nz] correspondingly. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: section RES dat ids ['dir'='y' val=nan]
 -- MGL command: section RES dat id ['dir'='y' val=nan]
 -- Method on mglData: mglData Section (const mglDataA &ids, const char *dir='y', mreal val=NAN) const
 -- Method on mglData: mglData Section (long id, const char *dir='y', mreal val=NAN) const
 -- Method on mglDataC: mglData Section (const mglDataA &ids, const char *dir='y', mreal val=NAN) const
 -- Method on mglDataC: mglData Section (long id, const char *dir='y', mreal val=NAN) const
 -- C function: HMDT mgl_data_section (HCDT dat, HCDT ids, const char *dir, mreal val)
 -- C function: HMDT mgl_data_section_val (HCDT dat, long id, const char *dir, mreal val)
 -- C function: HADT mgl_datac_section (HCDT dat, HCDT ids, const char *dir, mreal val)
 -- C function: HADT mgl_datac_section_val (HCDT dat, long id, const char *dir, mreal val)
     Gets array which is ID-th section (range of slices separated by value VAL) of original array DAT. For ID<0 the reverse order is used (i.e. -1 give last section). If several IDS are provided then output array will be result  of sequential joining of sections.

 -- MGL command: solve RES dat val 'dir' [norm=on]
 -- MGL command: solve RES dat val 'dir' idat [norm=on]
 -- Method on mglData: mglData Solve (mreal val, char dir, bool norm=true) const
 -- Method on mglData: mglData Solve (mreal val, char dir, const mglDataA &idat, bool norm=true) const
 -- C function: HMDT mgl_data_solve (HCDT dat, mreal val, char dir, HCDT idat, int norm)
     Gets array which values is indexes (roots) along given direction DIR, where interpolated values of data DAT are equal to VAL. Output data will have the sizes of DAT in directions transverse to DIR. If data IDAT is provided then its values are used as starting points. This allows to find several branches by consequentive calls. Indexes are supposed to be normalized in range [0,1] (if NORM=true) or in ranges [0,nx], [0,ny], [0,nz] correspondingly. Function return NULL or create empty data if data cannot be created for given arguments. Solve sample

 -- MGL command: roots RES 'func' ini ['var'='x']
 -- MGL command: roots RES 'func' ini ['var'='x']
 -- Method on mglData: mglData Roots (const char *func, char var) const
 -- C function: HMDT mgl_data_roots (const char *func, HCDT ini, char var)
 -- C function: mreal mgl_find_root_txt (const char *func, mreal ini, char var)
     Find roots of equation 'func'=0 for variable VAR with initial guess INI. Secant method is used for root finding. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: roots RES 'funcs' 'vars' ini
 -- Method on mglData: mglData MultiRoots (const char *funcs, const char *vars) const
 -- Method on mglDataC: mglDataC MultiRoots (const char *funcs, const char *vars) const
 -- C function: HMDT mgl_find_roots_txt (const char *func, const char *vars, HCDT ini)
 -- C function: HADT mgl_find_roots_txt_c (const char *func, const char *vars, HCDT ini)
     Find roots of system of equations 'funcs'=0 for variables VARS with initial guesses INI. Secant method is used for root finding. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: detect RES dat lvl dj [di=0 minlen=0]
 -- Method on mglData: mglData Detect (mreal lvl, mreal dj, mreal di=0, mreal minlen=0) const
 -- C function: HMDT mgl_data_detect (HCDT dat, mreal lvl, mreal dj, mreal di, mreal minlen)
     Get curves {x,y}, separated by NAN values, for local maximal values of array DAT as function of x-coordinate. Noises below LVL amplitude are ignored. Parameter DJ (in range [0,ny]) set the "attraction" y-distance of points to the curve. Similarly, DI continue curve in x-direction through gaps smaller than DI points. Curves with minimal length smaller than MINLEN will be ignored.

 -- MGL command: hist RES dat num v1 v2 [nsub=0]
 -- MGL command: hist RES dat wdat num v1 v2 [nsub=0]
 -- Method on mglData: mglData Hist (int n, mreal v1=0, mreal v2=1, int nsub=0) const
 -- Method on mglData: mglData Hist (const mglDataA &w, int n, mreal v1=0, mreal v2=1, int nsub=0) const
 -- Method on mglDataC: mglData Hist (int n, mreal v1=0, mreal v2=1, int nsub=0) const
 -- Method on mglDataC: mglData Hist (const mglDataA &w, int n, mreal v1=0, mreal v2=1, int nsub=0) const
 -- C function: HMDT mgl_data_hist (HCDT dat, int n, mreal v1, mreal v2, int nsub)
 -- C function: HMDT mgl_data_hist_w (HCDT dat, HCDT w, int n, mreal v1, mreal v2, int nsub)
     Creates N-th points distribution of the data values in range [V1, V2]. Array W specifies weights of the data elements (by default is 1). Parameter NSUB define the number of additional interpolated points (for smoothness of histogram). If NSUB<0 then linear interpolation is used instead of spline one. Function return NULL or create empty data if data cannot be created for given arguments. See also Data manipulation

 -- MGL command: momentum RES dat 'how' ['dir'='z']
 -- Method on mglData: mglData Momentum (char dir, const char *how) const
 -- Method on mglDataC: mglData Momentum (char dir, const char *how) const
 -- C function: HMDT mgl_data_momentum (HCDT dat, char dir, const char *how)
     Gets momentum (1d-array) of the data along direction DIR. String HOW contain kind of momentum. The momentum is defined like as res_k = \sum_ij how(x_i,y_j,z_k) a_ij/ \sum_ij a_ij if DIR=z and so on. Coordinates x, y, z are data indexes normalized in range [0,1]. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: sum RES dat 'dir'
 -- Method on mglData: mglData Sum (const char *dir) const
 -- Method on mglDataC: mglData Sum (const char *dir) const
 -- C function: HMDT mgl_data_sum (HCDT dat, const char *dir)
     Gets array which is the result of summation in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: max RES dat 'dir'
 -- Method on mglData: mglData Max (const char *dir) const
 -- Method on mglDataC: mglData Max (const char *dir) const
 -- C function: HMDT mgl_data_max_dir (HCDT dat, const char *dir)
     Gets array which is the maximal data values in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: min RES dat 'dir'
 -- Method on mglData: mglData Min (const char *dir) const
 -- Method on mglDataC: mglData Min (const char *dir) const
 -- C function: HMDT mgl_data_min_dir (HCDT dat, const char *dir)
     Gets array which is the maximal data values in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: minmax RES dat
 -- Method on mglData: mglData MinMax () const
 -- C function: HMDT mgl_data_minmax (HCDT dat)
     Gets positions of local maximums and minimums. Function return NULL or create empty data if there is no minimums and maximums.

 -- MGL command: conts RES val dat
 -- Method on mglData: mglData Conts (mreal val) const
 -- C function: HMDT mgl_data_conts (mreal val, HCDT dat)
     Gets coordinates of contour lines for dat[i,j]=val. NAN values separate the the curves. Function return NULL or create empty data if there is contour lines.

 -- MGL command: combine RES adat bdat
 -- Method on mglData: mglData Combine (const mglDataA &a) const
 -- Method on mglDataC: mglData Combine (const mglDataA &a) const
 -- C function: HMDT mgl_data_combine (HCDT dat, HCDT a)
     Returns direct multiplication of arrays (like, res[i,j] = this[i]*a[j] and so on). Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: trace RES dat
 -- Method on mglData: mglData Trace () const
 -- Method on mglDataC: mglData Trace () const
 -- C function: HMDT mgl_data_trace (HCDT dat)
     Gets array of diagonal elements a[i,i] (for 2D case) or a[i,i,i] (for 3D case) where i=0...nx-1. Function return copy of itself for 1D case. Data array must have dimensions ny,nz >= nx or ny,nz = 1. Function return NULL or create empty data if data cannot be created for given arguments.

 -- MGL command: correl RES adat bdat 'dir'
 -- Method on mglData: mglData Correl (const mglDataA &b, const char *dir) const
 -- Method on mglData: mglData AutoCorrel (const char *dir) const
 -- Method on mglDataC: mglDataC Correl (const mglDataA &b, const char *dir) const
 -- Method on mglDataC: mglDataC AutoCorrel (const char *dir) const
 -- C function: HMDT mgl_data_correl (HCDT a, HCDT b, const char *dir)
 -- C function: HADT mgl_datac_correl (HCDT a, HCDT b, const char *dir)
     Find correlation between data A (or this in C++) and B along directions DIR. Fourier transform is used to find the correlation. So, you may want to use functions swap or norm before plotting it. Function return NULL or create empty data if data cannot be created for given arguments.

 -- Method on mglDataC: mglData Real () const
 -- C function: HMDT mgl_datac_real (HCDT dat)
     Gets array of real parts of the data.

 -- Method on mglDataC: mglData Imag () const
 -- C function: HMDT mgl_datac_imag (HCDT dat)
     Gets array of imaginary parts of the data.

 -- Method on mglDataC: mglData Abs () const
 -- C function: HMDT mgl_datac_abs (HCDT dat)
     Gets array of absolute values of the data.

 -- Method on mglDataC: mglData Arg () const
 -- C function: HMDT mgl_datac_arg (HCDT dat)
     Gets array of arguments of the data.

 -- MGL command: pulse RES dat 'dir'
 -- Method on mglData: mglData Pulse (const char *dir) const
 -- C function: HMDT mgl_data_pulse (HCDT dat, const char *dir)
     Find pulse properties along direction DIR: pulse maximum (in column 0) and its position (in column 1), pulse width near maximum (in column 3) and by half height (in column 2), energy in first pulse (in column 4). NAN values are used for widths if maximum is located near the edges. Note, that there is uncertainty for complex data. Usually one should use square of absolute value (i.e. |dat[i]|^2) for them. So, MathGL don't provide this function for complex data arrays. However, C function will work even in this case but use absolute value (i.e. |dat[i]|). Function return NULL or create empty data if data cannot be created for given arguments. See also max, min, momentum, sum. Pulse properties

 -- MGL command: first RES dat 'dir' val
 -- Method on mglData: mglData First (const char *dir, mreal val) const
 -- Method on mglDataC: mglData First (const char *dir, mreal val) const
 -- C function: HMDT mgl_data_first_dir (HCDT dat, const char *dir, mreal val)
     Get array of positions of first value large VAL. For complex data the absolute value is used. See also last.

 -- MGL command: last RES dat 'dir' val
 -- Method on mglData: mglData Last (const char *dir, mreal val) const
 -- Method on mglDataC: mglData Last (const char *dir, mreal val) const
 -- C function: HMDT mgl_data_last_dir (HCDT dat, const char *dir, mreal val)
     Get array of positions of last value large VAL. For complex data the absolute value is used. See also first.

 -- C function: HMDT mgl_formula_calc (const char *str, long n, ...)
 -- C function: HADT mgl_formula_calc_c (const char *str, long n, ...)
     Evaluate formula str for the given list of N data arrays of type HCDT. Variable names correspond to data names. You need to delete returned data array after usage! See also fill.

external

Data changing
=============

nav

These functions change the data in some direction like differentiations, integrations and so on. The direction in which the change will applied is specified by the string parameter, which may contain x, y or z characters for 1-st, 2-nd and 3-d dimension correspondingly.

 -- MGL command: cumsum dat 'dir'
 -- Method on mglData: void CumSum (const char *dir)
 -- Method on mglDataC: void CumSum (const char *dir)
 -- C function: void mgl_data_cumsum (HMDT dat, const char *dir)
 -- C function: void mgl_datac_cumsum (HADT dat, const char *dir)
     Cumulative summation of the data in given direction or directions.

 -- MGL command: integrate dat 'dir'
 -- Method on mglData: void Integral (const char *dir)
 -- Method on mglDataC: void Integral (const char *dir)
 -- C function: void mgl_data_integral (HMDT dat, const char *dir)
 -- C function: void mgl_datac_integral (HADT dat, const char *dir)
     Integrates (like cumulative summation) the data in given direction or directions.

 -- MGL command: diff dat 'dir'
 -- Method on mglData: void Diff (const char *dir)
 -- Method on mglDataC: void Diff (const char *dir)
 -- C function: void mgl_data_diff (HMDT dat, const char *dir)
 -- C function: void mgl_datac_diff (HADT dat, const char *dir)
     Differentiates the data in given direction or directions.

 -- MGL command: diff dat xdat ydat [zdat]
 -- Method on mglData: void Diff (const mglDataA &x)
 -- Method on mglData: void Diff (const mglDataA &x, const mglDataA &y)
 -- Method on mglData: void Diff (const mglDataA &x, const mglDataA &y, const mglDataA &z)
 -- Method on mglDataC: void Diff (const mglDataA &x)
 -- Method on mglDataC: void Diff (const mglDataA &x, const mglDataA &y)
 -- Method on mglDataC: void Diff (const mglDataA &x, const mglDataA &y, const mglDataA &z)
 -- C function: void mgl_data_diff_par (HMDT dat, HCDT x, HCDTy, HCDTz)
 -- C function: void mgl_datac_diff_par (HADT dat, HCDT x, HCDTy, HCDTz)
     Differentiates the data specified parametrically in direction X with Y, Z=constant. Parametrical differentiation uses the formula (for 2D case): da/dx = (a_j*y_i-a_i*y_j)/(x_j*y_i-x_i*y_j) where a_i=da/di, a_j=da/dj denotes usual differentiation along 1st and 2nd dimensions. The similar formula is used for 3D case. Note, that you may change the order of arguments -- for example, if you have 2D data a(i,j) which depend on coordinates {x(i,j), y(i,j)} then usual derivative along x will be Diff(x,y); and usual derivative along y will be Diff(y,x);.

 -- MGL command: diff2 dat 'dir'
 -- Method on mglData: void Diff2 (const char *dir)
 -- Method on mglDataC: void Diff2 (const char *dir)
 -- C function: void mgl_data_diff2 (HMDT dat, const char *dir)
 -- C function: void mgl_datac_diff2 (HADT dat, const char *dir)
     Double-differentiates (like Laplace operator) the data in given direction.

 -- MGL command: sinfft dat 'dir'
 -- Method on mglData: void SinFFT (const char *dir)
 -- C function: void mgl_data_sinfft (HMDT dat, const char *dir)
     Do Sine transform of the data in given direction or directions. The Sine transform is \sum a_j \sin(k j) (see http://en.wikipedia.org/wiki/Discrete_sine_transform#DST-I).

 -- MGL command: cosfft dat 'dir'
 -- Method on mglData: void CosFFT (const char *dir)
 -- C function: void mgl_data_cosfft (HMDT dat, const char *dir)
     Do Cosine transform of the data in given direction or directions. The Cosine transform is \sum a_j \cos(k j) (see http://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-I).

 -- Method on mglDataC: void FFT (const char *dir)
 -- C function: void mgl_datac_fft (HADT dat, const char *dir)
     Do Fourier transform of the data in given direction or directions. If DIR contain i then inverse Fourier is used. The Fourier transform is \sum a_j \exp(i k j) (see http://en.wikipedia.org/wiki/Discrete_Fourier_transform).

 -- MGL command: hankel dat 'dir'
 -- Method on mglData: void Hankel (const char *dir)
 -- Method on mglDataC: void Hankel (const char *dir)
 -- C function: void mgl_data_hankel (HMDT dat, const char *dir)
 -- C function: void mgl_datac_hankel (HADT dat, const char *dir)
     Do Hankel transform of the data in given direction or directions. The Hankel transform is \sum a_j J_0(k j) (see http://en.wikipedia.org/wiki/Hankel_transform).

 -- MGL command: wavelet dat 'dir' k
 -- Method on mglData: void Wavelet (const char *dir, int k)
 -- C function: void mgl_data_wavelet (HMDT dat, const char *dir, int k)
     Apply wavelet transform of the data in given direction or directions. Parameter DIR set the kind of wavelet transform: d for daubechies, D for centered daubechies, h for haar, H for centered haar, b for bspline, B for centered bspline. If string DIR contain symbol i then inverse wavelet transform is applied. Parameter K set the size of wavelet transform.

 -- MGL command: swap dat 'dir'
 -- Method on mglData: void Swap (const char *dir)
 -- Method on mglDataC: void Swap (const char *dir)
 -- C function: void mgl_data_swap (HMDT dat, const char *dir)
 -- C function: void mgl_datac_swap (HADT dat, const char *dir)
     Swaps the left and right part of the data in given direction (useful for Fourier spectrum).

 -- MGL command: roll dat 'dir' num
 -- Method on mglData: void Roll (char dir, num)
 -- Method on mglDataC: void Roll (char dir, num)
 -- C function: void mgl_data_roll (HMDT dat, char dir, num)
 -- C function: void mgl_datac_roll (HADT dat, char dir, num)
     Rolls the data along direction DIR. Resulting array will be out[i] = ini[(i+NUM)%nx] if dir='x'.

 -- MGL command: mirror dat 'dir'
 -- Method on mglData: void Mirror (const char *dir)
 -- Method on mglDataC: void Mirror (const char *dir)
 -- C function: void mgl_data_mirror (HMDT dat, const char *dir)
 -- C function: void mgl_datac_mirror (HADT dat, const char *dir)
     Mirror the left-to-right part of the data in given direction. Looks like change the value index I->N-I. Note, that the similar effect in graphics you can reach by using options (see Command options), for example, surf dat; xrange 1 -1.

 -- MGL command: sew dat ['dir'='xyz' da=2*pi]
 -- Method on mglData: void Sew (const char *dir, mreal da=2*M_PI)
 -- C function: void mgl_data_sew (HMDT dat, const char *dir, mreal da)
     Remove value steps (like phase jumps after inverse trigonometric functions) with period DA in given direction.

 -- MGL command: smooth data ['dir'='xyz']
 -- Method on mglData: void Smooth (const char *dir="xyz", mreal delta=0)
 -- Method on mglDataC: void Smooth (const char *dir="xyz", mreal delta=0)
 -- C function: void mgl_data_smooth (HMDT dat, const char *dir, mreal delta)
 -- C function: void mgl_datac_smooth (HADT dat, const char *dir, mreal delta)
     Smooths the data on specified direction or directions. String DIRS specifies the dimensions which will be smoothed. It may contain characters:

       * xyz for smoothing along x-,y-,z-directions correspondingly,

       * 0 does nothing,

       * 3 for linear averaging over 3 points,

       * 5 for linear averaging over 5 points,

       * d1...d9 for linear averaging over (2*N+1)-th points,

       * p1...p9 for parabolic averaging over (2*N+1)-th points,

       * ^ for finding upper bound,

       * _ for finding lower bound.

     By default quadratic averaging over 5 points is used.

 -- MGL command: envelop dat ['dir'='x']
 -- Method on mglData: void Envelop (char dir='x')
 -- C function: void mgl_data_envelop (HMDT dat, char dir)
     Find envelop for data values along direction DIR.

 -- MGL command: diffract dat 'how' q
 -- Method on mglDataC: void Diffraction (const char *how, mreal q)
 -- C function: void mgl_datac_diffr (HADT dat, const char *how, mreal q)
     Calculates one step of diffraction by finite-difference method with parameter Q=\delta t/\delta x^2 using method with 3-d order of accuracy. Parameter HOW may contain:

       * xyz for calculations along x-,y-,z-directions correspondingly;

       * r for using axial symmetric Laplace operator for x-direction;

       * 0 for zero boundary conditions;

       * 1 for constant boundary conditions;

       * 2 for linear boundary conditions;

       * 3 for parabolic boundary conditions;

       * 4 for exponential boundary conditions;

       * 5 for gaussian boundary conditions.

 -- MGL command: norm dat v1 v2 [sym=off dim=0]
 -- Method on mglData: void Norm (mreal v1=0, mreal v2=1, bool sym=false, long dim=0)
 -- C function: void mgl_data_norm (HMDT dat, mreal v1, mreal v2, int sym, long dim)
     Normalizes the data to range [V1,V2]. If flag SYM=true then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. Modification will be applied only for slices >=DIM.

 -- MGL command: normsl dat v1 v2 ['dir'='z' keep=on sym=off]
 -- Method on mglData: void NormSl (mreal v1=0, mreal v2=1, char dir='z', bool keep=true, bool sym=false)
 -- C function: void mgl_data_norm_slice (HMDT dat, mreal v1, mreal v2, char dir, int keep, int sym)
     Normalizes data slice-by-slice along direction DIR the data in slices to range [V1,V2]. If flag SYM=true then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. If KEEP is set then maximal value of k-th slice will be limited by \sqrt{\sum a_ij(k)/\sum a_ij(0)}.

 -- MGL command: keep dat 'dir' i [j=0]
 -- Method on mglData: void Keep (const char *dir, long i, long j=0)
 -- Method on mglDataC: void Keep (const char *dir, long i, long j=0)
 -- C function: void mgl_data_keep (HMDT dat, const char *dir, long i, long j)
 -- C function: void mgl_datac_keep (HADT dat, const char *dir, long i, long j=0)
     Conserves phase/sign or amplitude (if DIR contain a) of data along directions DIR by fixing one at point {I,J} of the initial slice. The function is useful for removing common phase change of a complex data. keep sample

 -- MGL command: limit dat val
 -- Method on mglData: void Limit (mreal val)
 -- Method on mglDataC: void Limit (mreal val)
 -- C function: void mgl_data_limit (HMDT dat, mreal val)
 -- C function: void mgl_datac_limit (HADT dat, mreal val)
     Limits the data values to be inside the range [-VAL,VAL], keeping the original sign of the value (phase for complex numbers). This is equivalent to operation a[i] *= abs(a[i])<val?1.:val/abs(a[i]);.

 -- MGL command: coil dat v1 v2 [sep=on]
 -- Method on mglData: void Coil (mreal v1, mreal v2, bool sep=true)
 -- C function: void mgl_data_coil (HMDT dat, mreal v1, mreal v2, int sep)
     Project the periodical data to range [V1,V2] (like mod() function). Separate branches by NAN if SEP=true.

 -- MGL command: dilate dat [val=1 step=1]
 -- Method on mglData: void Dilate (mreal val=1, long step=1)
 -- C function: void mgl_data_dilate (HMDT dat, mreal val, long step)
     Return dilated by STEP cells array of 0 or 1 for data values larger VAL.

 -- MGL command: erode dat [val=1 step=1]
 -- Method on mglData: void Erode (mreal val=1, long step=1)
 -- C function: void mgl_data_erode (HMDT dat, mreal val, long step)
     Return eroded by STEP cells array of 0 or 1 for data values larger VAL.

external

Interpolation
=============

nav

MGL scripts can use spline interpolation by evaluate or refill commands. Also you can use resize for obtaining a data array with new sizes.

However, there are much special faster functions in other modes (C/C++/Fortran/Python/...).

 -- Method on mglData: mreal Spline (mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Spline (mreal x, mreal y=0, mreal z=0) const
 -- C function: mreal mgl_data_spline (HCDT dat, mreal x, mreal y, mreal z)
 -- C function: dual mgl_datac_spline (HCDT dat, mreal x, mreal y, mreal z)
     Interpolates data by cubic spline to the given point X in [0...nx-1], Y in [0...ny-1], Z in [0...nz-1].

 -- Method on mglData: mreal Spline1 (mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Spline1 (mreal x, mreal y=0, mreal z=0) const
     Interpolates data by cubic spline to the given point X, Y, Z which assumed to be normalized in range [0, 1].

 -- Method on mglData: mreal Spline (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
 -- C function: mreal mgl_data_spline_ext (HCDT dat, mreal x, mreal y, mreal z, mreal *dx, mreal *dy, mreal *dz)
 -- C function: dual mgl_datac_spline_ext (HCDT dat, mreal x, mreal y, mreal z, dual *dx, dual *dy, dual *dz)
     Interpolates data by cubic spline to the given point X in [0...nx-1], Y in [0...ny-1], Z in [0...nz-1]. The values of derivatives at the point are saved in DIF.

 -- Method on mglData: mreal Spline1 (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
     Interpolates data by cubic spline to the given point X, Y, Z which assumed to be normalized in range [0, 1]. The values of derivatives at the point are saved in DIF.

 -- Method on mglData: mreal Linear (mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Linear (mreal x, mreal y=0, mreal z=0) const
 -- C function: mreal mgl_data_linear (HCDT dat, mreal x, mreal y, mreal z)
 -- C function: dual mgl_datac_linear (HCDT dat, mreal x, mreal y, mreal z)
     Interpolates data by linear function to the given point X in [0...nx-1], Y in [0...ny-1], Z in [0...nz-1].

 -- Method on mglData: mreal Linear1 (mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Linear1 (mreal x, mreal y=0, mreal z=0) const
     Interpolates data by linear function to the given point X, Y, Z which assumed to be normalized in range [0, 1].

 -- Method on mglData: mreal Linear (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Linear (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
 -- C function: mreal mgl_data_linear_ext (HCDT dat, mreal x, mreal y, mreal z, mreal *dx, mreal *dy, mreal *dz)
 -- C function: dual mgl_datac_linear_ext (HCDT dat, mreal x, mreal y, mreal z, dual *dx, dual *dy, dual *dz)
     Interpolates data by linear function to the given point X in [0...nx-1], Y in [0...ny-1], Z in [0...nz-1]. The values of derivatives at the point are saved in DIF.

 -- Method on mglData: mreal Linear1 (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
 -- Method on mglDataC: dual Linear1 (mglPoint &dif, mreal x, mreal y=0, mreal z=0) const
     Interpolates data by linear function to the given point X, Y, Z which assumed to be normalized in range [0, 1]. The values of derivatives at the point are saved in DIF.

external

Data information
================

nav

There are a set of functions for obtaining data properties in MGL language. However most of them can be found using "suffixes". Suffix can get some numerical value of the data array (like its size, maximal or minimal value, the sum of elements and so on) as number. Later it can be used as usual number in command arguments. The suffixes start from point . right after (without spaces) variable name or its sub-array. For example, a.nx give the x-size of data A, b(1).max give maximal value of second row of variable B, (c(:,0)^2).sum give the sum of squares of elements in the first column of C and so on.

 -- MGL command: info dat
 -- Method on mglDataA: const char * PrintInfo () const
 -- Method on mglDataA: void PrintInfo (FILE *fp) const
 -- C function only: const char * mgl_data_info (HCDT dat)
 -- Fortran subroutine: mgl_data_info (long dat, char *out, int len)
     Gets or prints to file FP or as message (in MGL) information about the data (sizes, maximum/minimum, momentums and so on).

 -- MGL command: info 'txt'
     Prints string TXT as message.

 -- MGL command: info val
     Prints value of number VAL as message.

 -- MGL command: print dat
 -- MGL command: print 'txt'
 -- MGL command: print val
     The same as info but immediately print to stdout.

 -- MGL command: echo dat
     Prints all values of the data array DAT as message.

 -- MGL command: progress val max
 -- Method on mglGraph: void Progress (int val, int max)
 -- C function: void mgl_progress (int val, int max)
     Display progress of something as filled horizontal bar with relative length VAL/MAX. Note, it work now only in console and in FLTK-based applications, including mgllab and mglview.

 -- MGL suffix: (dat) .nx
 -- MGL suffix: (dat) .ny
 -- MGL suffix: (dat) .nz
 -- Method on mglDataA: long GetNx ()
 -- Method on mglDataA: long GetNy ()
 -- Method on mglDataA: long GetNz ()
 -- C function: long mgl_data_get_nx (HCDT dat)
 -- C function: long mgl_data_get_ny (HCDT dat)
 -- C function: long mgl_data_get_nz (HCDT dat)
     Gets the x-, y-, z-size of the data.

 -- MGL suffix: (dat) .max
 -- Method on mglDataA: mreal Maximal () const
 -- C function: mreal mgl_data_max (HCDT dat)
     Gets maximal value of the data.

 -- MGL suffix: (dat) .min
 -- Method on mglDataA: mreal Minimal () const
 -- C function: mreal mgl_data_min (HMDT dat) const
     Gets minimal value of the data.

 -- Method on mglDataA: mreal Minimal (int &i, int &j, int &k) const
 -- C function: mreal mgl_data_min_int (HCDT dat, int *i, int *j, int *k)
     Gets position of minimum to variables I, J, K and returns the minimal value.

 -- Method on mglDataA: mreal Maximal (int &i, int &j, int &k) const
 -- C function: mreal mgl_data_max_int (HCDT dat, int *i, int *j, int *k)
     Gets position of maximum to variables I, J, K and returns the maximal value.

 -- Method on mglDataA: mreal Minimal (mreal &x, mreal &y, mreal &z) const
 -- C function: mreal mgl_data_min_real (HCDT dat, mreal *x, mreal *y, mreal *z)
     Gets approximated (interpolated) position of minimum to variables X, Y, Z and returns the minimal value.

 -- MGL suffix: (dat) .mx
 -- MGL suffix: (dat) .my
 -- MGL suffix: (dat) .mz
 -- Method on mglDataA: mreal Maximal (mreal &x, mreal &y, mreal &z) const
 -- C function: mreal mgl_data_max_real (HCDT dat, mreal *x, mreal *y, mreal *z)
     Gets approximated (interpolated) position of maximum to variables X, Y, Z and returns the maximal value.

 -- MGL suffix: (dat) .mxf
 -- MGL suffix: (dat) .myf
 -- MGL suffix: (dat) .mzf
 -- MGL suffix: (dat) .mxl
 -- MGL suffix: (dat) .myl
 -- MGL suffix: (dat) .mzl
 -- Method on mglDataA: long Maximal (char dir, long from) const
 -- Method on mglDataA: long Maximal (char dir, long from, long &p1, long &p2) const
 -- C function: mreal mgl_data_max_firstl (HCDT dat, char dir, long from, long *p1, long *p2)
     Get first starting FROM give position (or last one if FROM<0) maximum along direction DIR, and save its orthogonal coordinates in P1, P2.

 -- MGL suffix: (dat) .sum
 -- MGL suffix: (dat) .ax
 -- MGL suffix: (dat) .ay
 -- MGL suffix: (dat) .az
 -- MGL suffix: (dat) .aa
 -- MGL suffix: (dat) .wx
 -- MGL suffix: (dat) .wy
 -- MGL suffix: (dat) .wz
 -- MGL suffix: (dat) .wa
 -- MGL suffix: (dat) .sx
 -- MGL suffix: (dat) .sy
 -- MGL suffix: (dat) .sz
 -- MGL suffix: (dat) .sa
 -- MGL suffix: (dat) .kx
 -- MGL suffix: (dat) .ky
 -- MGL suffix: (dat) .kz
 -- MGL suffix: (dat) .ka
 -- Method on mglDataA: mreal Momentum (char dir, mreal &a, mreal &w) const
 -- Method on mglDataA: mreal Momentum (char dir, mreal &m, mreal &w, mreal &s, mreal &k) const
 -- C function: mreal mgl_data_momentum_val (HCDT dat, char dir, mreal *a, mreal *w, mreal *s, mreal *k)
     Gets zero-momentum (energy, I=\sum dat_i) and write first momentum (median, a = \sum \xi_i dat_i/I), second momentum (width, w^2 = \sum (\xi_i-a)^2 dat_i/I), third momentum (skewness, s = \sum (\xi_i-a)^3 dat_i/ I w^3) and fourth momentum (kurtosis, k = \sum (\xi_i-a)^4 dat_i / 3 I w^4) to variables. Here \xi is corresponding coordinate if DIR is 'x', 'y' or 'z'. Otherwise median is a = \sum dat_i/N, width is w^2 = \sum (dat_i-a)^2/N and so on.

 -- MGL suffix: (dat) .fst
 -- Method on mglDataA: mreal Find (const char *cond, int &i, int &j, int &k) const
 -- C function: mreal mgl_data_first (HCDT dat, const char *cond, int *i, int *j, int *k)
     Find position (after specified in I, J, K) of first nonzero value of formula COND. Function return the data value at found position.

 -- MGL suffix: (dat) .lst
 -- Method on mglDataA: mreal Last (const char *cond, int &i, int &j, int &k) const
 -- C function: mreal mgl_data_last (HCDT dat, const char *cond, int *i, int *j, int *k)
     Find position (before specified in I, J, K) of last nonzero value of formula COND. Function return the data value at found position.

 -- Method on mglDataA: int Find (const char *cond, char dir, int i=0, int j=0, int k=0) const
 -- C function: mreal mgl_data_find (HCDT dat, const char *cond, int i, int j, int k)
     Return position of first in direction DIR nonzero value of formula COND. The search is started from point {i,j,k}.

 -- Method on mglDataA: bool FindAny (const char *cond) const
 -- C function: mreal mgl_data_find_any (HCDT dat, const char *cond)
     Determines if any nonzero value of formula in the data array.

 -- MGL suffix: (dat) .a
     Give first (for .a, i.e. dat->a[0]).

external

Operators
=========

nav

 -- MGL command: copy DAT dat2 ['eq'='']
 -- Method on mglData: void operator= (const mglDataA &d)
     Copies data from other variable.

 -- MGL command: copy dat val
 -- Method on mreal: void operator= (mreal val)
     Set all data values equal to VAL.

 -- MGL command: multo dat dat2
 -- MGL command: multo dat val
 -- Method on mglData: void operator*= (const mglDataA &d)
 -- Method on mglData: void operator*= (mreal d)
 -- C function: void mgl_data_mul_dat (HMDT dat, HCDT d)
 -- C function: void mgl_data_mul_num (HMDT dat, mreal d)
     Multiplies data element by the other one or by value.

 -- MGL command: divto dat dat2
 -- MGL command: divto dat val
 -- Method on mglData: void operator/= (const mglDataA &d)
 -- Method on mglData: void operator/= (mreal d)
 -- C function: void mgl_data_div_dat (HMDT dat, HCDT d)
 -- C function: void mgl_data_div_num (HMDT dat, mreal d)
     Divides each data element by the other one or by value.

 -- MGL command: addto dat dat2
 -- MGL command: addto dat val
 -- Method on mglData: void operator+= (const mglDataA &d)
 -- Method on mglData: void operator+= (mreal d)
 -- C function: void mgl_data_add_dat (HMDT dat, HCDT d)
 -- C function: void mgl_data_add_num (HMDT dat, mreal d)
     Adds to each data element the other one or the value.

 -- MGL command: subto dat dat2
 -- MGL command: subto dat val
 -- Method on mglData: void operator-= (const mglDataA &d)
 -- Method on mglData: void operator-= (mreal d)
 -- C function: void mgl_data_sub_dat (HMDT dat, HCDT d)
 -- C function: void mgl_data_sub_num (HMDT dat, mreal d)
     Subtracts from each data element the other one or the value.

 -- Library Function: mglData operator+ (const mglDataA &a, const mglDataA &b)
 -- Library Function: mglData operator+ (mreal a, const mglDataA &b)
 -- Library Function: mglData operator+ (const mglDataA &a, mreal b)
     Adds the other data or the number.

 -- Library Function: mglData operator- (const mglDataA &a, const mglDataA &b)
 -- Library Function: mglData operator- (mreal a, const mglDataA &b)
 -- Library Function: mglData operator- (const mglDataA &a, mreal b)
     Subtracts the other data or the number.

 -- Library Function: mglData operator* (const mglDataA &a, const mglDataA &b)
 -- Library Function: mglData operator* (mreal a, const mglDataA &b)
 -- Library Function: mglData operator* (const mglDataA &a, mreal b)
     Multiplies by the other data or the number.

 -- Library Function: mglData operator/ (const mglDataA &a, const mglDataA &b)
 -- Library Function: mglData operator/ (const mglDataA &a, mreal b)
     Divides by the other data or the number.

external

Global functions
================

nav

These functions are not methods of mglData class. However it provide additional functionality to handle data. So I put it in this chapter.

 -- MGL command: transform DAT 'type' real imag
 -- Global function: mglData mglTransform (const mglDataA &real, const mglDataA &imag, const char *type)
 -- C function: HMDT mgl_transform (HCDT real, HCDT imag, const char *type)
     Does integral transformation of complex data REAL, IMAG on specified direction. The order of transformations is specified in string TYPE: first character for x-dimension, second one for y-dimension, third one for z-dimension. The possible character are: f is forward Fourier transformation, i is inverse Fourier transformation, s is Sine transform, c is Cosine transform, h is Hankel transform, n or   is no transformation.

 -- MGL command: transforma DAT 'type' ampl phase
 -- Global function: mglData mglTransformA const mglDataA &ampl, const mglDataA &phase, const char *type)
 -- C function: HMDT mgl_transform_a HCDT ampl, HCDT phase, const char *type)
     The same as previous but with specified amplitude AMPL and phase PHASE of complex numbers.

 -- MGL command: fourier reDat imDat 'dir'
 -- MGL command: fourier complexDat 'dir'
 -- Global function: void mglFourier const mglDataA &re, const mglDataA &im, const char *dir)
 -- Method on mglDataC: void FFT (const char *dir)
 -- C function: void mgl_data_fourier HCDT re, HCDT im, const char *dir)
 -- C function: void mgl_datac_fft (HADT dat, const char *dir)
     Does Fourier transform of complex data RE+i*IM in directions DIR. Result is placed back into RE and IM data arrays. If DIR contain i then inverse Fourier is used.

 -- MGL command: stfad RES real imag dn ['dir'='x']
 -- Global function: mglData mglSTFA (const mglDataA &real, const mglDataA &imag, int dn, char dir='x')
 -- C function: HMDT mgl_data_stfa (HCDT real, HCDT imag, int dn, char dir)
     Short time Fourier transformation for real and imaginary parts. Output  is amplitude of partial Fourier of length DN. For example if DIR=x, result will have size {int(nx/dn), dn, ny} and it will contain res[i,j,k]=|\sum_d^dn exp(I*j*d)*(real[i*dn+d,k]+I*imag[i*dn+d,k])|/dn.

 -- MGL command: triangulate dat xdat ydat
 -- Global function: mglData mglTriangulation (const mglDataA &x, const mglDataA &y)
 -- C function: void mgl_triangulation_2d (HCDT x, HCDT y)
     Do Delone triangulation for 2d points and return result suitable for triplot and tricont. Making regular data

 -- MGL command: tridmat RES ADAT BDAT CDAT DDAT 'how'
 -- Global function: mglData mglTridMat (const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataA &D, const char *how)
 -- Global function: mglDataC mglTridMatC (const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataA &D, const char *how)
 -- C function: HMDT mgl_data_tridmat (HCDT A, HCDT B, HCDT C, HCDT D, const char*how)
 -- C function: HADT mgl_datac_tridmat (HCDT A, HCDT B, HCDT C, HCDT D, const char*how)
     Get array as solution of tridiagonal system of equations A[i]*x[i-1]+B[i]*x[i]+C[i]*x[i+1]=D[i]. String HOW may contain:

       * xyz for solving along x-,y-,z-directions correspondingly;

       * h for solving along hexagonal direction at x-y plain (require square matrix);

       * c for using periodical boundary conditions;

       * d for for diffraction/diffuse calculation (i.e. for using -A[i]*D[i-1]+(2-B[i])*D[i]-C[i]*D[i+1] at right part instead of D[i]).

     Data dimensions of arrays A, B, C should be equal. Also their dimensions need to be equal to all or to minor dimension(s) of array D. PDE solving hints

 -- MGL command: pde RES 'ham' ini_re ini_im [dz=0.1 k0=100]
 -- Global function: mglData mglPDE (HMGL gr, const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100, const char *opt="")
 -- Global function: mglDataC mglPDEc (HMGL gr, const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100, const char *opt="")
 -- C function: HMDT mgl_pde_solve (HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt)
 -- C function: HADT mgl_pde_solve_c (HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt)
     Solves equation du/dz = i*k0*HAM(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters INI_RE, INI_IM specify real and imaginary part of initial field distribution. Parameters MIN, MAX set the bounding box for the solution. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter DZ set the step along evolutionary coordinate z. At this moment, simplified form of function HAM is supported -- all ``mixed'' terms (like x*p->x*d/dx) are excluded. For example, in 2D case this function is effectively ham = f(p,z) + g(x,z,u). However commutable combinations (like x*q->x*d/dy) are allowed. Here variable u is used for field amplitude |u|. This allow one solve nonlinear problems -- for example, for nonlinear Shrodinger equation you may set ham="p^2 + q^2 - u^2". You may specify imaginary part for wave absorption, like ham = "p^2 + i*x*(x>0)". See also apde, qo2d, qo3d. PDE solving hints

 -- MGL command: apde RES 'ham' ini_re ini_im [dz=0.1 k0=100]
 -- Global function: mglData mglAPDE (HMGL gr, const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100, const char *opt="")
 -- Global function: mglDataC mglAPDEc (HMGL gr, const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100, const char *opt="")
 -- C function: HMDT mgl_pde_solve_adv (HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt)
 -- C function: HADT mgl_pde_solve_adv_c (HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt)
     Solves equation du/dz = i*k0*HAM(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters INI_RE, INI_IM specify real and imaginary part of initial field distribution. Parameters MIN, MAX set the bounding box for the solution. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter DZ set the step along evolutionary coordinate z. The advanced and rather slow algorithm is used for taking into account both spatial dispersion and inhomogeneities of media [see A.A. Balakin, E.D. Gospodchikov, A.G. Shalashov, JETP letters v.104, p.690-695 (2016)]. Variable u is used for field amplitude |u|. This allow one solve nonlinear problems -- for example, for nonlinear Shrodinger equation you may set ham="p^2 + q^2 - u^2". You may specify imaginary part for wave absorption, like ham = "p^2 + i*x*(x>0)". See also pde. PDE solving hints

 -- MGL command: ray RES 'ham' x0 y0 z0 p0 q0 v0 [dt=0.1 tmax=10]
 -- Global function: mglData mglRay (const char *ham, mglPoint r0, mglPoint p0, mreal dt=0.1, mreal tmax=10)
 -- C function: HMDT mgl_ray_trace (const char *ham, mreal x0, mreal y0, mreal z0, mreal px, mreal py, mreal pz, mreal dt, mreal tmax)
     Solves GO ray equation like dr/dt = d HAM/dp, dp/dt = -d HAM/dr. This is Hamiltonian equations for particle trajectory in 3D case. Here HAM is Hamiltonian which may depend on coordinates x, y, z, momentums p=px, q=py, v=pz and time t: ham = H(x,y,z,p,q,v,t). The starting point (at t=0) is defined by variables R0, P0. Parameters DT and TMAX specify the integration step and maximal time for ray tracing. Result is array of {x,y,z,p,q,v,t} with dimensions {7 * int(TMAX/DT+1) }.

 -- MGL command: ode RES 'df' 'var' ini [dt=0.1 tmax=10]
 -- Global function: mglData mglODE (const char *df, const char *var, const mglDataA &ini, mreal dt=0.1, mreal tmax=10)
 -- Global function: mglDataC mglODEc (const char *df, const char *var, const mglDataA &ini, mreal dt=0.1, mreal tmax=10)
 -- C function: HMDT mgl_ode_solve_str (const char *df, const char *var, HCDT ini, mreal dt, mreal tmax)
 -- C function: HADT mgl_ode_solve_str_c (const char *df, const char *var, HCDT ini, mreal dt, mreal tmax)
 -- C function: HMDT mgl_ode_solve (void (*df)(const mreal *x, mreal *dx, void *par), int n, const mreal *ini, mreal dt, mreal tmax)
 -- C function: HMDT mgl_ode_solve_ex (void (*df)(const mreal *x, mreal *dx, void *par), int n, const mreal *ini, mreal dt, mreal tmax, void (*bord)(mreal *x, const mreal *xprev, void *par))
     Solves ODE equations dx/dt = df(x). The functions DF can be specified as string of ';'-separated textual formulas (argument VAR set the character ids of variables x[i]) or as callback function, which fill dx array for give x's. Parameters INI, DT, TMAX set initial values, time step and maximal time of the calculation. Function stop execution if NAN or INF values appears. Result is data array with dimensions {N * NT}, where NT <= int(TMAX/DT+1).

     If DT*TMAX<0 then regularization is switched on, which change equations to dx/ds = df(x)/max(|df(x)|) to allow accurately passes region of strong df variation or quickly bypass region of small df. Here s is the new "time". At this, real time is determined as dt/ds=max(|df(x)|). If you need real time, then add it into equations manually, like ode res 'y;-sin(x);1' 'xyt' [3,0] 0.3 -100. This also preserve accuracy at stationary points (i.e. at small df in periodic case).

 -- MGL command: ode RES 'df' 'var' 'brd' ini [dt=0.1 tmax=10]
 -- Global function: mglData mglODEs (const char *df, const char *var, char brd, const mglDataA &ini, mreal dt=0.1, mreal tmax=10)
 -- Global function: mglDataC mglODEcs (const char *df, const char *var, char brd, const mglDataA &ini, mreal dt=0.1, mreal tmax=10)
 -- C function: HMDT mgl_ode_solve_set (const char *df, const char *var, char brd, HCDT ini, mreal dt, mreal tmax)
 -- C function: HADT mgl_ode_solve_set_c (const char *df, const char *var, char brd, HCDT ini, mreal dt, mreal tmax)
     Solves difference approximation of PDE as a set of ODE dx/dt = df(x,j). Functions DF can be specified as string of ';'-separated textual formulas, which can depend on index J and current time t. Argument VAR set the character ids of variables x[i]. Parameter BRD sets the kind of boundary conditions on J: 0 or z -- zero at border, 1 or c -- constant at border, 2 or l -- linear at border (laplacian is zero), 3 or s -- square at border, 4 or e -- exponential at border, 5 or g -- gaussian at border. The cases e and g are applicable for the complex variant only. Parameters INI, DT, TMAX set initial values, time step and maximal time of the calculation. Function stop execution if NAN or INF values appears. Result is data array with dimensions {N * NT}, where NT <= int(TMAX/DT+1). For example, difference aprroximation of diffusion equation with zero boundary conditions can be solved by call: ode res 'u(j+1)-2*u(j)+u(j-1)' 'u' '0' u0, where u0 is an initial data array.

     If DT*TMAX<0 then regularization is switched on, which change equations to dx/ds = df(x)/max(|df(x)|) to allow accurately passes region of strong df variation or quickly bypass region of small df. Here s is the new "time". At this, real time is determined as dt/ds=max(|df(x)|). If you need real time, then add it into equations manually, like ode res 'y;-sin(x);1' 'xyt' [3,0] 0.3 -100. This also preserve accuracy at stationary points (i.e. at small df in periodic case).

 -- MGL command: qo2d RES 'ham' ini_re ini_im ray [r=1 k0=100 xx yy]
 -- Global function: mglData mglQO2d (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100)
 -- Global function: mglData mglQO2d (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100)
 -- Global function: mglDataC mglQO2dc (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100)
 -- Global function: mglDataC mglQO2dc (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100)
 -- C function: HMDT mgl_qo2d_solve (const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy)
 -- C function: HADT mgl_qo2d_solve_c (const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy)
 -- C function: HMDT mgl_qo2d_func (dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy)
 -- C function: HADT mgl_qo2d_func_c (dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy)
     Solves equation du/dt = i*k0*HAM(p,q,x,y,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators (see mglPDE() for details). Parameters INI_RE, INI_IM specify real and imaginary part of initial field distribution. Parameters RAY set the reference ray, i.e. the ray around which the accompanied coordinate system will be maked. You may use, for example, the array created by ray function. Note, that the reference ray must be smooth enough to make accompanied coodrinates unambiguity. Otherwise errors in the solution may appear. If XX and YY are non-zero then Cartesian coordinates for each point will be written into them. See also pde, qo3d. PDE solving hints

 -- MGL command: qo3d RES 'ham' ini_re ini_im ray [r=1 k0=100 xx yy zz]
 -- Global function: mglData mglQO3d (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100)
 -- Global function: mglData mglQO3d (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100)
 -- Global function: mglDataC mglQO3dc (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100)
 -- Global function: mglDataC mglQO3dc (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100)
 -- C function: HMDT mgl_qo3d_solve (const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz)
 -- C function: HADT mgl_qo3d_solve_c (const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz)
 -- C function: HMDT mgl_qo3d_func (dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz)
 -- C function: HADT mgl_qo3d_func_c (dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz)
     Solves equation du/dt = i*k0*HAM(p,q,v,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy, v=-i/k0*d/dz are pseudo-differential operators (see mglPDE() for details). Parameters INI_RE, INI_IM specify real and imaginary part of initial field distribution. Parameters RAY set the reference ray, i.e. the ray around which the accompanied coordinate system will be maked. You may use, for example, the array created by ray function. Note, that the reference ray must be smooth enough to make accompanied coodrinates unambiguity. Otherwise errors in the solution may appear. If XX and YY and ZZ are non-zero then Cartesian coordinates for each point will be written into them. See also pde, qo2d. PDE solving hints

 -- MGL command: jacobian RES xdat ydat [zdat]
 -- Global function: mglData mglJacobian (const mglDataA &x, const mglDataA &y)
 -- Global function: mglData mglJacobian (const mglDataA &x, const mglDataA &y, const mglDataA &z)
 -- C function: HMDT mgl_jacobian_2d (HCDT x, HCDT y)
 -- C function: HMDT mgl_jacobian_3d (HCDT x, HCDT y, HCDT z)
     Computes the Jacobian for transformation {i,j,k} to {X,Y,Z} where initial coordinates  {i,j,k} are data indexes normalized in range [0,1]. The Jacobian is determined by formula det||dr_\alpha/d\xi_\beta|| where r={X,Y,Z} and \xi={i,j,k}. All dimensions must be the same for all data arrays. Data must be 3D if all 3 arrays {X,Y,Z} are specified or 2D if only 2 arrays {X,Y} are specified.

 -- MGL command: triangulation RES xdat ydat
 -- Global function: mglData mglTriangulation (const mglDataA &x, const mglDataA &y)
 -- C function: HMDT mgl_triangulation_2d (HCDT x, HCDT y)
     Computes triangulation for arbitrary placed points with coordinates {X,Y} (i.e. finds triangles which connect points). MathGL use s-hull (http://www.s-hull.org/) code for triangulation. The sizes of 1st dimension must be equal for all arrays x.nx=y.nx. Resulting array can be used in triplot or tricont functions for visualization of reconstructed surface. Making regular data

 -- Global function: mglData mglGSplineInit (const mglDataA &x, const mglDataA &y)
 -- Global function: mglDataC mglGSplineCInit (const mglDataA &x, const mglDataA &y)
 -- C function: HMDT mgl_gspline_init (HCDT x, HCDT y)
 -- C function: HADT mgl_gsplinec_init (HCDT x, HCDT y)
     Prepare coefficients for global cubic spline interpolation.

 -- Global function: mreal mglGSpline (const mglDataA &coef, mreal dx, mreal *d1=0, mreal *d2=0)
 -- Global function: dual mglGSplineC (const mglDataA &coef, mreal dx, dual *d1=0, dual *d2=0)
 -- C function: mreal mgl_gspline (HCDT coef, mreal dx, mreal *d1, mreal *d2)
 -- C function: dual mgl_gsplinec (HCDT coef, mreal dx, dual *d1, dual *d2)
     Evaluate global cubic spline (and its 1st and 2nd derivatives D1, D2 if they are not NULL) using prepared coefficients COEF at point DX+X0 (where X0 is 1st element of data X provided to mglGSpline*Init() function).

 -- MGL command: ifs2d RES dat num [skip=20]
 -- Global function: mglData mglIFS2d (const mglDataA &dat, long num, long skip=20)
 -- C function: HMDT mgl_data_ifs_2d (HCDT dat, long num, long skip)
     Computes NUM points {x[i]=res[0,i], y[i]=res[1,i]} for fractal using iterated function system. Matrix DAT is used for generation according the formulas
     x[i+1] = dat[0,i]*x[i] + dat[1,i]*y[i] + dat[4,i];
     y[i+1] = dat[2,i]*x[i] + dat[3,i]*y[i] + dat[5,i];
     Value dat[6,i] is used as weight factor for i-th row of matrix DAT. At this first SKIP iterations will be omitted. Data array DAT must have x-size greater or equal to 7. See also ifs3d, flame2d. ifs2d sample

 -- MGL command: ifs3d RES dat num [skip=20]
 -- Global function: mglData mglIFS3d (const mglDataA &dat, long num, long skip=20)
 -- C function: HMDT mgl_data_ifs_3d (HCDT dat, long num, long skip)
     Computes NUM points {x[i]=res[0,i], y[i]=res[1,i], z[i]=res[2,i]} for fractal using iterated function system. Matrix DAT is used for generation according the formulas
     x[i+1] = dat[0,i]*x[i] + dat[1,i]*y[i] + dat[2,i]*z[i] + dat[9,i];
     y[i+1] = dat[3,i]*x[i] + dat[4,i]*y[i] + dat[5,i]*z[i] + dat[10,i];
     z[i+1] = dat[6,i]*x[i] + dat[7,i]*y[i] + dat[8,i]*z[i] + dat[11,i];
     Value dat[12,i] is used as weight factor for i-th row of matrix DAT. At this first SKIP iterations will be omitted. Data array DAT must have x-size greater or equal to 13. See also ifs2d. ifs3d sample

 -- MGL command: ifsfile RES 'fname' 'name' num [skip=20]
 -- Global function: mglData mglIFSfile (const char *fname, const char *name, long num, long skip=20)
 -- C function: HMDT mgl_data_ifs_file (const char *fname, const char *name, long num, long skip)
     Reads parameters of IFS fractal named NAME from file FNAME and computes NUM points for this fractal. At this first SKIP iterations will be omitted. See also ifs2d, ifs3d.

     IFS file may contain several records. Each record contain the name of fractal (binary in the example below) and the body of fractal, which is enclosed in curly braces {}. Symbol ; start the comment. If the name of fractal contain (3D) or (3d) then the 3d IFS fractal is specified. The sample below contain two fractals: binary -- usual 2d fractal, and 3dfern (3D) -- 3d fractal. See also ifs2d, ifs3d.

      binary
      { ; comment allowed here
       ; and here
       .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here
       .5  .0 .0 .5  2.436544 -0.000003 .333333
       .0 -.5 .5 .0  4.873085  7.563492 .333333
       }

      3dfern (3D) {
        .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01
        .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85
        .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
       -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
       }

 -- MGL command: flame2d RES dat func num [skip=20]
 -- Global function: mglData mglFlame2d (const mglDataA &dat, const mglDataA &func, long num, long skip=20)
 -- C function: HMDT mgl_data_flame_2d (HCDT dat, HCDT func, long num, long skip)
     Computes NUM points {x[i]=res[0,i], y[i]=res[1,i]} for "flame" fractal using iterated function system. Array FUNC define "flame" function identificator (FUNC[0,i,j]), its weight (FUNC[0,i,j]) and arguments (FUNC[2 ... 5,i,j]). Matrix DAT set linear transformation of coordinates before applying the function. The resulting coordinates are
     xx = dat[0,i]*x[j] + dat[1,j]*y[i] + dat[4,j];
     yy = dat[2,i]*x[j] + dat[3,j]*y[i] + dat[5,j];
     x[j+1] = sum_i @var{func}[1,i,j]*@var{func}[0,i,j]_x(xx, yy; @var{func}[2,i,j],...,@var{func}[5,i,j]);
     y[j+1] = sum_i @var{func}[1,i,j]*@var{func}[0,i,j]_y(xx, yy; @var{func}[2,i,j],...,@var{func}[5,i,j]);
     The possible function ids are: mglFlame2d_linear=0,	mglFlame2d_sinusoidal,	mglFlame2d_spherical,	mglFlame2d_swirl,		mglFlame2d_horseshoe,
     mglFlame2d_polar,		mglFlame2d_handkerchief,mglFlame2d_heart,		mglFlame2d_disc,		mglFlame2d_spiral,
     mglFlame2d_hyperbolic,	mglFlame2d_diamond,		mglFlame2d_ex,			mglFlame2d_julia,		mglFlame2d_bent,
     mglFlame2d_waves,		mglFlame2d_fisheye,		mglFlame2d_popcorn,		mglFlame2d_exponential,	mglFlame2d_power,
     mglFlame2d_cosine,		mglFlame2d_rings,		mglFlame2d_fan,			mglFlame2d_blob,		mglFlame2d_pdj,
     mglFlame2d_fan2,		mglFlame2d_rings2,		mglFlame2d_eyefish,		mglFlame2d_bubble,		mglFlame2d_cylinder,
     mglFlame2d_perspective,	mglFlame2d_noise,		mglFlame2d_juliaN,		mglFlame2d_juliaScope,	mglFlame2d_blur,
     mglFlame2d_gaussian,	mglFlame2d_radialBlur,	mglFlame2d_pie,			mglFlame2d_ngon,		mglFlame2d_curl,
     mglFlame2d_rectangles,	mglFlame2d_arch,		mglFlame2d_tangent,		mglFlame2d_square,		mglFlame2d_blade,
     mglFlame2d_secant,		mglFlame2d_rays,		mglFlame2d_twintrian,	mglFlame2d_cross,		mglFlame2d_disc2,
     mglFlame2d_supershape,	mglFlame2d_flower,		mglFlame2d_conic,		mglFlame2d_parabola,	mglFlame2d_bent2,
     mglFlame2d_bipolar,		mglFlame2d_boarders,	mglFlame2d_butterfly,	mglFlame2d_cell,		mglFlame2d_cpow,
     mglFlame2d_curve,		mglFlame2d_edisc,		mglFlame2d_elliptic,	mglFlame2d_escher,		mglFlame2d_foci,
     mglFlame2d_lazySusan,	mglFlame2d_loonie,		mglFlame2d_preBlur,		mglFlame2d_modulus,		mglFlame2d_oscope,
     mglFlame2d_polar2,		mglFlame2d_popcorn2,	mglFlame2d_scry,		mglFlame2d_separation,	mglFlame2d_split,
     mglFlame2d_splits,		mglFlame2d_stripes,		mglFlame2d_wedge,		mglFlame2d_wedgeJulia,	mglFlame2d_wedgeSph,
     mglFlame2d_whorl,		mglFlame2d_waves2,		mglFlame2d_exp,			mglFlame2d_log,			mglFlame2d_sin,
     mglFlame2d_cos,			mglFlame2d_tan,			mglFlame2d_sec,			mglFlame2d_csc,			mglFlame2d_cot,
     mglFlame2d_sinh,		mglFlame2d_cosh,		mglFlame2d_tanh,		mglFlame2d_sech,		mglFlame2d_csch,
     mglFlame2d_coth,		mglFlame2d_auger,		mglFlame2d_flux.
     Value dat[6,i] is used as weight factor for i-th row of matrix DAT. At this first SKIP iterations will be omitted. Sizes of data arrays must be: DAT.nx>=7, FUNC.nx>=2 and FUNC.nz=DAT.ny. See also ifs2d, ifs3d. flame2d sample

external

Evaluate expression
===================

nav

MathGL have a special classes mglExpr and mglExprC for evaluating of formula specified by the string for real and complex numbers correspondingly. These classes are defined in #include <mgl2/data.h> and #include <mgl2/datac.h> correspondingly. It is the fast variant of formula evaluation. At creation it will be recognized and compiled to tree-like internal code. At evaluation stage only fast calculations are performed. There is no difference between lower or upper case in formulas. If argument value lie outside the range of function definition then function returns NaN. See Textual formulas.

 -- Constructor on mglExpr: mglExpr (const char *expr)
 -- Constructor on mglExprC: mglExprC (const char *expr)
 -- C function: HMEX mgl_create_expr (const char *expr)
 -- C function: HAEX mgl_create_cexpr (const char *expr)
     Parses the formula EXPR and creates formula-tree. Constructor recursively parses the formula and creates a tree-like structure containing functions and operators for fast further evaluating by Calc() or CalcD() functions.

 -- Destructor on mglExpr: ~mglExpr ()
 -- Destructor on mglExprC: ~mglExprC ()
 -- C function: void mgl_delete_expr (HMEX ex)
 -- C function: void mgl_delete_cexpr (HAEX ex)
     Deletes the instance of class  mglExpr.

 -- Method on mglExpr: mreal Eval (mreal x, mreal y, mreal z)
 -- Method on mglExprC: dual Eval (dual x, dual y, dual z)
 -- C function: mreal mgl_expr_eval (HMEX ex, mreal x, mreal y, mreal z)
 -- C function: dual mgl_cexpr_eval (HAEX ex, dual x, dual y, dual z)
     Evaluates the formula for 'x','r'=X, 'y','n'=Y, 'z','t'=Z, 'a','u'=U.

 -- Method on mglExpr: mreal Eval (mreal var[26])
 -- Method on mglExprC: dual Eval (dual var[26])
 -- C function: mreal mgl_expr_eval_v (HMEX ex, mreal *var)
 -- C function: dual mgl_expr_eval_v (HAEX ex, dual *var)
     Evaluates the formula for variables in array VAR[0,...,'z'-'a'].

 -- Method on mglExpr: mreal Diff (char dir, mreal x, mreal y, mreal z)
 -- C function: mreal mgl_expr_diff (HMEX ex, char dir, mreal x, mreal y, mreal z)
     Evaluates the formula derivation respect to DIR for 'x','r'=X, 'y','n'=Y, 'z','t'=Z, 'a','u'=U.

 -- Method on mglExpr: mreal Diff (char dir, mreal var[26])
 -- C function: mreal mgl_expr_diff_v (HMEX ex, char dir, mreal *var)
     Evaluates the formula derivation respect to DIR for variables in array VAR[0,...,'z'-'a'].

external

Special data classes
====================

nav

This section describe special data classes mglDataV, mglDataF, mglDataT and mglDataR which sometime can noticeable speed up drawing or data handling. These classes are defined in #include <mgl2/data.h>. Note, that all plotting and data handling routines can be done using usual mglData or mglDataC classes. Also these special classes are usable in C++ code only.

Class mglDataV
==============

represent variable with values equidistantly distributed in given range.
 -- Constructor on mglDataV: mglDataV (const mglDataV & d)
     Copy constructor.

 -- Constructor on mglDataV: mglDataV (long nx=1, long ny=1, long nz=1, mreal v1=0, mreal v2=NaN, char dir='x')
     Create variable with "sizes" NXxNYxNZ which changes from V1 to V2 (or is constant if V2=NaN) along DIR direction.

 -- Method on mglDataV: void Create (long nx=1, long ny=1, long nz=1)
     Set "sizes" NXxNYxNZ.

 -- Method on mglDataV: void Fill (mreal x1, mreal x2=NaN, char dir='x')
     Set ranges of the variable.

 -- Method on mglDataV: void Freq (mreal dp, char dir='x')
     Set as frequency variable with increment DP.

Class mglDataF
==============

represent function which values are evaluated (instead of access to data array as in mglData).
 -- Constructor on mglDataF: mglDataF (const mglDataF & d)
     Copy constructor.

 -- Constructor on mglDataF: mglDataF (long nx=1, long ny=1, long nz=1)
     Create variable with "sizes" NXxNYxNZ with zero function.

 -- Method on mglDataF: void Create (long nx=1, long ny=1, long nz=1)
     Set "sizes" NXxNYxNZ.

 -- Method on mglDataF: void SetRanges (mglPoint p1, mglPoint p2)
     Set ranges for internal x,y,z variables.

 -- Method on mglDataF: void SetFormula (const char *func)
     Set string which will be evaluated at function calls. Note this variant is about 10 times slower than SetFunc() one.

 -- Method on mglDataF: void SetFunc (mreal (*f)(mreal x,mreal y,mreal z,void *p), void *p=NULL)
     Set pointer to function which will be used for data.

Class mglDataT
==============

represent named reference to column of another data array.
 -- Constructor on mglDataT: mglDataT (const mglDataT & d)
     Copy constructor.

 -- Constructor on mglDataT: mglDataT (const mglDataA & d, long col=0)
     Create variable which reference COL-th column of data D.

 -- Method on mglDataT: void SetInd (long col, wchar_t name)
 -- Method on mglDataT: void SetInd (long col, const wchar_t * name)
     Set reference to another column of the same data and its name.

Class mglDataR
==============

represent named reference to row of another data array.
 -- Constructor on mglDataR: mglDataR (const mglDataR & d)
     Copy constructor.

 -- Constructor on mglDataR: mglDataR (const mglDataA & d, long row=0)
     Create variable which reference ROW-th row of data D.

 -- Method on mglDataR: void SetInd (long row, wchar_t name)
 -- Method on mglDataR: void SetInd (long row, const wchar_t * name)
     Set reference to another row of the same data and its name.

Class mglDataW
==============

represent FFT frequency as data array.
 -- Constructor on mglDataW: mglDataW (const mglDataW & d)
     Copy constructor.

 -- Constructor on mglDataW: mglDataW (long xx=1, long yy=1, long zz=1, double dp=0, char dir='x')
     Set frequency sizes, direction DIR and increment DP.

 -- Method on mglDataR: void Freq (double dp, char dir='x')
     Equidistantly fill the data with step DP in direction DIR.

Class mglDataS
==============

incapsulate std::vector and present it as data array.
 -- Variable of mglDataS: std::vector<mreal> dat
     Data array itself.

 -- Constructor on mglDataS: mglDataS (const mglDataS & d)
     Copy constructor.

 -- Constructor on mglDataS: mglDataS (const std::vector<mreal> & d)
     Create copy data from D.

 -- Constructor on mglDataS: mglDataS (size_t s)
     Allocate memory for S .

 -- Method on mglDataS: void reserve (size_t num)
     Reserve space for NUM elements.

 -- Method on mglDataS: void push_back (double v)
     Appends value V to the end of data.

external