| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Class for working with data array. This class is defined in #include <mgl/mgl_data.h>. The class has functions for easy and safe allocation, resizing, loading and saving, modifying of data arrays. Also it can numerically differentiate and integrate data, interpolate, fill data by formula and so on. Class supports data with dimensions up to 3 (like function of 3 variables - x,y,z). The internal representation of numbers is float. Float type was chosen because it has smaller size in memory and usually it has enough precision in plotting purposes.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
float * aData 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).
int nxNumber of points in 1st dimensions (’x’ dimension).
int nyNumber of points in 2nd dimensions (’y’ dimension).
int nzNumber of points in 3d dimensions (’z’ dimension).
char * idColumn (or slice if nz>1) names – one character per column.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mglData (int mx=1, int my=1, int mz=1)Default constructor. Allocates the memory for data array and initializes it by zero.
mglData (const char *fname)Initializes the data by reading from file.
mglData (const mglData &dat)Initiates by other mglData instance.
void Create (int mx, int my=1, int mz=1)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.
void Set (const float *A, int NX, int NY=1, int NZ=1)Allocates memory and copies the data from the flat float* array.
void Set (const double *A, int NX, int NY=1, int NZ=1)Allocates memory and copies the data from the flat double* array.
void Set (const float **A, int N1, int N2)Allocates memory and copies the data from the float** array with dimensions N1, N2, i.e. from array defined as float a[N1][N2];.
void Set (const double **A, int N1, int N2)Allocates memory and copies the data from the double** array with dimensions N1, N2, i.e. from array defined as double a[N1][N2];.
void Set (const float ***A, int N1, int N2)Allocates memory and copies the data from the float*** array with dimensions N1, N2, N3, i.e. from array defined as float a[N1][N2][N3];.
void Set (const double ***A, int N1, int N2)Allocates memory and copies the data from the double*** array with dimensions N1, N2, N3, i.e. from array defined as double a[N1][N2][N3];.
void Set (gsl_vector *v)Allocates memory and copies the data from the gsl_vector * structure.
void Set (gsl_matrix *m)Allocates memory and copies the data from the gsl_matrix * structure.
inline void Set (const mglData &dat)Copies the data from mglData instance dat.
void Set (const std::vector<int> &d)void Set (const std::vector<float> &d)void Set (const std::vector<double> &d)Allocates memory and copies the data from the std::vector<T> array.
void Set (const char *str, int NX, int NY=1, int NZ=1)Allocates memory and scanf the data from the string.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Fill (float x1, float x2, char dir='x')Equidistantly fills the data values to range [x1, x2] in direction dir={‘x’,‘y’,‘z’}.
void Fill (const char *eq, mglPoint Min, mglPoint Max, const mglData *vdat=0, const mglData *wdat=0)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 range Min x Max (in difference from Modify functions). 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).
void Modify (const char *eq, int dim=0)Function fills the value of array according to the formula in string eq. Formula is an arbitrary expression depending on variables ‘x’, ‘y’, ‘z’, ‘u’. Coordinates ‘x’, ‘y’, ‘z’ are data indexes normalized in range [0,1]. Variable ‘u’ is the original value of the array. Modification will be fulfilled only for slices >=dim.
void Modify (const char *eq, const mglData &v)void Modify (const char *eq, const mglData &v, const mglData &w)Function 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 data indexes normalized in range [0,1]. Variable ‘u’ is the original value of the array. Variables ‘v’ and ‘w’ are values of vdat, wdat.
void Put (float val, int i=-1, int j=-1, int k=-1)Function 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).
void Put (const mglData &v, int i=-1, int j=-1, int k=-1)Function 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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Rearrange (int mx, int my=0, int mz=0)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 will be 1.
void Extend (int n1, int n2=0)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|.
void Transpose (const char *dim="yx")Transposes (shift order of) dimensions of the data. New order of dimensions is specified int string dim. This function may be useful also for the reading of one-dimensional data.
void Squeeze (int rx, int ry=1, int rz=1, bool smooth=true)Reduces the data size by excluding data elements which indexes are not divisible by rx, ry, rz correspondingly.
void Crop (int n1, int n2, char dir='x') 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.
void InsertRows (int at, int num=1, const char *eq=NULL)Insert num rows (slice along y-direction) at position at and fill it by formula eq (if eq!=0) or by zeros.
void InsertColumns (int at, int num=1, const char *eq=NULL)Insert num columns (slice along x-direction) at position at and fill it by formula eq (if eq!=0) or by zeros.
void InsertSlices (int at, int num=1, const char *eq=NULL)Insert num slices (slice along z-direction) at position at and fill it by formula eq (if eq!=0) or by zeros.
void DeleteRows (int at, int num=1)Delete num rows (slice along y-direction) at position at.
void DeleteColumns (int at, int num=1)Delete num columns (slice along x-direction) at position at.
void DeleteSlices (int at, int num=1)Delete num slices (slice along z-direction) at position at.
void Insert (char dir, int pos=0, int num=1)Insert num slices along dir-direction at position pos and fill it by zeros.
void Delete (char dir, int pos=0, int num=1)Delete num slices along dir-direction at position pos.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Read (const char *fname)Reads data from tab-separated text file with auto determining sizes of the data.
void Read (const char *fname, int mx, int my=1, int mz=1)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.
void ReadMat (const char *fname, int dim=2)Read data from text file with size specified at beginning of the file by first dim numbers. At this, variable dim set data dimensions.
void ReadRange (const char *templ, float from, float to, float step=1.f, bool as_slice=false)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.
void ReadAll (const char *templ, bool as_slice=false)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.
void Save (const char *fname, int ns=-1) constSaves the whole data array (for ns=-1) or only ns-th slice to text file. If ns>0 then only ns-th slice (or column for 2D array) will be saved.
void ReadHDF (const char *fname, const char *dname)Reads data array named dname from HDF file. This function does nothing if NO_HDF5 was defined during library compilation.
void SaveHDF (const char *fname, const char *dname, bool rewrite=false) constSaves data array named dname from HDF file. This function does nothing if NO_HDF5 was defined during library compilation.
void Import (const char *fname, const char *scheme, float v1=0, float v2=1)Reads data from bitmap file (now support only PNG format). The RGB values of bitmap pixels are transformed to float values in range [v1, v2] using color scheme scheme (see section Color scheme).
void Export (const char *fname, const char *scheme, float v1=0, float v2=0, int ns=-1) constSaves 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 section Color scheme). If v1>=v2 then the values of v1, v2 are automatically determined as minimal and maximal value of the data array.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mglData SubData (int xx, int yy=-1, int zz=-1) constExtracts 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. The most convenient way is to use this function as initialization of other mglData variable like mglData a1(a.SubData(-1,-1,3)).
mglData SubData (const mglData &xx, const mglData &yy, const mglData &zz) constExtracts sub-array data from the original data array for indexes specified by arrays xx, yy, zz (indirect access). The resulting array have the same dimensions as input arrays for 2D and 3D arguments. This function work like previous one for 1D arguments (or numbers). The dimensions of all argument must be the same if they are 2D or 3D arrays.
mglData Column (const char *eq) constGet column (or slice) of the data filled by formula eq of other named columns. For example, Column("n*w^2/exp(t)");. The column ids must be defined first by SetColumnId() function.
void SetColumnId (const char *ids)Set the symbol id for data columns. The string must contain one symbol ’a’...’z’ per column (without spaces).
mglData Trace () constGets 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.
mglData Hist (int n, float v1=0, float v2=1, int nsub=0) constCreates n-th points distribution of the data values in range [v1, v2]. Parameter nsub define the number of additional interpolated points (for smoothness of histogram).
mglData Hist (const mglData &w, int n, float v1=0, float v2=1, int nsub=0) constCreates n-th points distribution of the data values in range [v1, v2]. Array w specifies weights of the data elements. Parameter nsub define the number of additional interpolated points (for smoothness of histogram).
mglData Momentum (char dir, const char *how) constGet 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 var=‘z’ and so on. Coordinates ‘x’, ‘y’, ‘z’ are data indexes normalized in range [0,1].
mglData Sum (const char *dir) constGets array which is the result of summation in given direction or direction(s).
mglData Max (const char *dir) constGets array which is the maximal data values in given direction or direction(s).
mglData Min (const char *dir) constGets array which is the maximal data values in given direction or direction(s).
mglData Combine (const mglData &a) constReturn direct multiplication of arrays (like, res[i,j] = this[i]*a[j] and so on).
mglData Evaluate (const mglData &idat, bool norm=true) constmglData Evaluate (const mglData &idat, const mglData &jdat, bool norm=true) constmglData Evaluate (const mglData &idat, const mglData &jdat, const mglData &kdat, bool norm=true) constGet 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 range [0,nx], [0,ny], [0,nz] correspondingly.
mglData Resize (int mx, int my=1, int mz=1, float x1=0, float x2=1, float y1=0, float y2=1, float z1=0, float z2=1) constResizes 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].
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 correspondengly.
void CumSum (const char *dir)Cumulative summation of the data in given direction or directions.
void Integral (const char *dir)Integrates (like cumulative summation) the data in given direction or directions.
void Diff (const char *dir)Differentiates the data in given direction or directions.
void Diff (const mglData &x, const mglData &y)void Diff (const mglData &x, const mglData &y, const mglData &z)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);.
void Diff2 (const char *dir)Double-differentiates (like Laplace operator) the data in given direction.
void Swap (const char *dir)Swaps the left and right part of the data in given direction (useful for Fourier spectrum).
void Mirror (const char *dir)Mirror the left-to-right part of the data in given direction. Looks like change the value index i->n-i.
void Sew (const char *dir, float da=2*M_PI)Remove value steps (like phase jumps after inverse trigonometric functions) with period da in given direction.
void Smooth (int Type, const char *dir, float delta=0)Smooths the data on specified direction or directions by method Type. Now 4 methods are supported: SMOOTH_NONE does nothing for delta=0 or approaches data to zero with the step delta, SMOOTH_LINE_3 linear averaging by 3 points, SMOOTH_LINE_5 linear averaging by 5 points, SMOOTH_QUAD_5 quadratic averaging by 5 points. Parameter delta forbids to change values of array more than delta from the original ones. String dirs specifies the dimensions which will be smoothed. It may contain characters: ’x’ for 1st dimension, ’y’ for 2nd dimension, ’z’ for 3d dimension.
void Smooth (const char *dir)Smooths the data on specified direction(s). This is the same as Smooth() but argument Type is specified in string as ‘0’ for SMOOTH_NONE, ‘3’ for SMOOTH_LINE_3, ‘5’ for SMOOTH_LINE_5. If string dir don’t contain digits ‘035’ then Type=SMOOTH_QUAD_5 is used.
void Envelop (char dir='x')Find envelop for data values along direction dir.
void NormSl (float v1=0, float v2=1, char dir='z', bool keep_en=true, bool sym=false)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_en is set then maximal value of k-th slice will be limited by
\sqrt\sum a_ij(k)/\sum a_ij(0).
void Norm (float v1=0, float v2=1, bool sym=false, int dim=0)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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
float Spline (float x, float y=0, float z=0) constInterpolates data by cubic spline to the given point x in [0...nx-1], y in [0...ny-1], z in [0...nz-1].
float Spline1 (float x, float y=0, float z=0) constInterpolates data by cubic spline to the given point x, y, z which assumed to be normalized in range [0, 1].
float Linear (float x, float y=0, float z=0) constInterpolates data by linear function to the given point x in [0...nx-1], y in [0...ny-1], z in [0...nz-1].
float Linear1 (float x, float y=0, float z=0) constInterpolates data by linear function to the given point x, y, z which assumed to be normalized in range [0, 1].
float v (int i, int j=0, int k=0) constGets the value in specified cell of the data with border checking.
float Spline5 (float x, float y, float z, float &dx, float &dy, float &dz) constInterpolate by 5-th order splain the data to given point x, y, z which normalized in range [0, 1] and evaluate its derivatives.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void PrintInfo (char *buf, bool all=false) constPrint information about the data (sizes and momentum) to string buf. Parameter all set to print most of information (if true) or just basic one like dimensions, maximal an minimal values.
void PrintInfo (FILE *fp) constPrint information about the data (sizes and momentum) to FILE (for example, stdout)
float Maximal () constGets maximal value of the data.
float Minimal () constGets minimal value of the data.
float Maximal (int &i, int &j, int &k) constGets maximal value of the data and its position in the array to variables i, j, k.
float Minimal (int &i, int &j, int &k) constGets minimal value of the data and its position in the array to variables i, j, k.
float Maximal (float &i, float &j, float &k) constGets maximal value of the data and its approximated (interpolated) position to variables i, j, k.
float Minimal (float &i, float &j, float &k) constGets minimal value of the data and its approximated (interpolated) position to variables i, j, k.
float Momentum (char dir, float &m, float &w) constGets zero-momentum (energy, I=\sum a_i) and write first momentum (median, m = \sum \xi_i a_i/I) and second momentum (width, w^2 = \sum (\xi_i-m)^2 a_i/I) to variables. Here \xi is corresponding coordinate if dir is ‘'x'’, ‘'y'’ or ‘'z'’. Otherwise median is m = \sum a_i/N, width is w^2 = \sum (a_i-m)^2/N.
float Momentum (char dir, float &m, float &w, float &s, float &k) constGets zero-momentum (energy, I=\sum a_i) and write first momentum (median, m = \sum \xi_i a_i/I), second momentum (width, w^2 = \sum (\xi_i-m)^2 a_i/I, third momentum (skewness, s = \sum (\xi_i-m)^3 a_i/ I w^3) and fourth momentum (kurtosis, k = \sum (\xi_i-m)^4 a_i / 3 I w^4)) to variables. Here \xi is corresponding coordinate if dir is ‘'x'’, ‘'y'’ or ‘'z'’. Otherwise median is m = \sum a_i/N, width is w^2 = \sum (a_i-m)^2/N and so on.
float Find (const char *cond, int &i, int &j, int &k) constFind position (after specified in i, j, k) of first nonzero value of formula cond. Function return the data value at found position.
float Last (const char *cond, int &i, int &j, int &k) constFind position (before specified in i, j, k) of last nonzero value of formula cond. Function return the data value at found position.
int Find (const char *cond, char dir, int i=0, int j=0, int k=0) constReturn position of first in direction dir nonzero value of formula cond. The search is started from point {i,j,k}.
bool FindAny (const char *cond) constDetermines if any nonzero value of formula in the data array.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void operator= (const mglData &d)Copies data from other variable.
void operator*= (const mglData &d)Multiplies the data by the other one for each element.
void operator/= (const mglData &d)Divides the data by the other one for each element.
void operator+= (const mglData &d)Adds the other data.
void operator-= (const mglData &d)Subtracts the other data.
void operator*= (float d)Multiplies each element by the number.
void operator/= (float d)Divides each element by the number.
void operator+= (float d)Adds the number to each element.
void operator-= (float d)Subtracts the number to each element.
const mglData &a, const mglData &b)Adds the other data.
float a, const mglData &b)Adds the number.
const mglData &a, float b)Adds the number.
const mglData &a, const mglData &b)Subtracts the other data.
float a, const mglData &b)Subtracts from the number.
const mglData &a, float b)Subtracts the number.
const mglData &a, const mglData &b)Multiplies by the other data.
float a, const mglData &b)Multiplies by the number.
const mglData &a, float b)Multiplies by the number.
const mglData &a, const mglData &b)Divides by the other data.
const mglData &a, float b)Divides by the number.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions are not methods of mglData class. However it have additional functionality to handle data. So I put it in this chapter.
mglData mglTransform (const mglData &real, const mglData &imag, const char *type)Do integral transformation of complex data real, imag on specified direction. Now only Fourier transformation is supported. 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, ‘n’ or ‘ ’ is no transformation.
mglData mglTransformA const mglData &l, const mglData &phase, const char *type)Do integral transformation of complex data ampl, phase on specified direction. Now only Fourier transformation is supported. 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, ‘n’ or ‘ ’ is no transformation.
mglData mglSTFA (const mglData &real, const mglData &imag, int dn, char dir='x')Short time Fourier analysis 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.
mglData mglPDE (const char *ham, const mglData &ini_re, const mglData &ini_im, mglPoint Min, mglPoint Max, float dz=0.1, float k0=100)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)", but only if dependence on variable ‘i’ is linear (i.e. ham = hre+i*him). See section PDE sample, for sample code and picture.
mglData mglRay (const char *ham, mglPoint r0, mglPoint p0, float dt=0.1, float tmax=10)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) }.
mglData mglQO2d (const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, float r=1, float k0=100, mglData *xx=0, mglData *yy=0, bool UseR=true)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 mglRay() 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 section Beam tracing sample, for sample code and picture.
mglData mglJacobian (const mglData &x, const mglData &y)mglData mglJacobian (const mglData &x, const mglData &y, const mglData &z)Computates 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.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 26, 2010 using texi2html 1.82.