Copyright: (c) 1998 H. Lohninger, Vienna, Austria


MATH2
Math2 - Version 1.7

The unit MATH2 offers some of the most fundamental procedures of univariate statistics (such as mean values, standard deviations, or the correlation coefficient for a series of data pairs). In addition, several more advanced mathematical methods (such as the calculation of eigenvectors and principal components, a simple clustering algorithm, and the smoothing of data) are contained in this unit. The unit MATH2 also contains a simple, yet powerful class (TCurveFit) which supports curve fitting of bivariate data.

MATH2 is released under the shareware concept. The unregistered version is fully functional with one exception: the shareware version runs properly only when the Delphi, or C++Builder IDE is also up and running.

Product information

Interface of unit MATH2

Installation of MATH2

Delphi and C++Builder issues

Frequently Asked Questions

Class TCurveFit:

CalcGaussFit	CalcHyperbolFit

CalcLinFit	CalcLogFit

CalcParabolFit	CalcPolyFit

CalcReciLinFit	CalcStatistics

CorrCoeff	EnterStatValue

Init	MaxPolyFitOrder

MeanDiff	MeanX

MeanY	NumData

StdDevDiff	StdDevX

StdDevY

Various procedures and functions:

AgglomClustering	CalcCovar

CalcEigVec	CalcGaussKernel

CalcGaussKernelMat	CalcPrincComp

FindCenters	FindNearestNeighbors

FirstDeriv	GetEigenResult

GetEigenSize	MeanDistanceKNN

PolynomialSmooth	RemoveEigenMatrix


 TCurveFit

See also:

The class TCurveFit provides a means of calculating regression estimators for certain types of functions. In addition, TCurveFit calculates the most important statistical parameters, such as the mean values, the standard deviation, and the correlation coefficient of a series of data pairs. In order to utilize the class TCurveFit, you have to enter the data pairs (x and y) by the method EnterStatValue. The regression parameters can be obtained then by calling the appropriate regression method.

The following table summarizes the routines of TCurveFit:

Init	initialize the processing machine

EnterStatValue	enter a pair of data

CalcStatistics	calculate mean values, standard deviations, and the correlation coefficient

CalcGaussFit	calculate the best Gaussean fit (normal distribution)

CalcHyperbolFit	calculate the best hyperbolic fit to the data

CalcLinFit	calculate the best linear fit to the data

CalcLogFit	calculate the best logarithmic fit

CalcParabolFit	calculate the best parabolic fit to the data

CalcPolyFit	calculate a best fitting polynomial

CalcReciLinFit	calculate the best reciprocal linear fit to the data

In addition, TCurveFit also provides all important univariate parameters for the entered data pairs:

CorrCoeff	correlation coefficient

MeanDiff	mean of differences between x and y

MeanX	mean of x values

MeanY	mean of y values

NumData	number of data pairs

StdDevDiff	standard deviation of differences between x and y

StdDevX	standard deviation of x values

StdDevY	standard deviation of y values


 CalcCovar

See also:	CorrCoeff

Class:	none

Declaration:	function CalcCovar (InData, CovarMat: TMatrix; LoC, HiC: integer; LoR, HiR: integer; Scaling: integer): boolean;

The routine CalcCovar calculates the covariance matrix, or alternatively, the scatter matrix, or the correlation matrix for a given data matrix. The resulting covariance matrix is of the dimension (HiC-LoC+1)*(HiC-LoC+1), this means that the rows of the data matrix are seen as objects and the columns are seen as variables.

The parameter InData contains the input data. The parameter CovarMat holds a pointer to a matrix which will contain the covariance matrix to be calculated.

The parameters LoC, HiC, LoR, and HiR specify the range of the data matrix, which should be used for the calculation. This enables the user to calculate 'local' covariance matrices which originate only from a part of the data.

The parameter Scaling determines how to scale the data before calculating the result matrix. This will lead to three different matrices, depending on the value of Scaling:

Scaling	Action	Resulting matrix

0	none	scatter matrix of InData

1	mean centering	covariance matrix of InData

2	standardization	correlation matrix of InData

Standardization of the data (sometimes called 'autoscaling') is performed by scaling the data in a way that the mean of each columns becomes zero and the variance becomes 1.0. The covariance matrix of standardized data is usually called 'correlation matrix'.

The function CalcCovar returns the value TRUE if the calculation of the covariance matrix has been performed successfully. A FALSE value indicates that the calculation has not been completed successfully (mostly due to lack of memory or too small a matrix of CovarMat).

CalcCovar increments the global variable ProcStat and calls the feedback routine MathFeedBackProc in order to allow feedback to the user during time consuming calculations.

Hint:	The user is responsible by his own that the matrix CovarMat has been declared large enough to hold the resulting covariance matrix. This matrix has to be quadratic and of size (HiC-LoC+1)*(HiC-LoC+1). If the matrix CovarMat is too large the covariance matrix is stored in the matrix elements with the lowest indices (starting at 1). The unused elements are not changed at all.

Example:	COVAR.DPR

The example program COVAR.DPR shows the application of the function CalcCovar. The user can enter values into a matrix and calculate either the scatter matrix, the covariance matrix, or the correlation matrix.


 CalcDiffMat

See also:	CalcCovar

Class:	none

Declaration:	function CalcDiffMat (InData, DiffMat: TMatrix; LoC, HiC: integer; LoR, HiR: integer; Scaling: integer): boolean;

The routine CalcDiffMat calculates the difference matrix from a given data matrix. The resulting matrix is of the dimension (HiC-LoC+1)*(HiC-LoC+1), this means that the rows of the data matrix are seen as objects and the columns are seen as variables.

The parameter InData holds a pointer to the matrix of the input data. This matrix is an object of the class TMatrix. The parameter DiffMat holds a pointer to a matrix which will contain the difference matrix to be calculated.

The parameters LoC, HiC, LoR, and HiR specify the range of the data matrix, which should be used for the calculation. This enables to calculate 'local' difference matrices which originates from only a part of the data. Normally the calculation will be performed for the whole data matrix InData (LoC=1, HiC=InData.NrOfColumns, LoR=1, and HiR=InData.NrOfRows).

The parameter Scaling determines how to scale the data before calculating the result matrix. This will lead to three different matrices, depending on the parameter Scaling:

Scaling	Action	Resulting matrix

0	none	difference matrix of InData

1	mean centering	??? matrix of InData

2	standardization	??? matrix of InData

Standardization of the data (sometimes called 'autoscaling') is performed by scaling the data in a way that the mean of each columns becomes zero and the variance becomes 1.0.

The function CalcDiffMat returns the value TRUE if the calculation of the difference matrix has been performed successfully. A returned value of FALSE indicates that the calculation could not finished properly (mostly due to lack of memory or too small a matrix DiffMat).

Hint:	The user is responsible by his own that the matrix DiffMat has been declared large enough to hold the resulting difference matrix. This matrix has to be quadratic and of size (HiC-LoC+1)*-(HiC-LoC+1). If the matrix DiffMat is too large the difference matrix is stored in the matrix elements with the lowest indices (starting at 1). The unused elements are not changed at all.


 CalcEigVec

See also:	CalcPrincComp, GetEigenResult, GetEigenSize, RemoveEigenMatrix

Class:	none

Declaration:	function CalcEigVec (InMat: TMatrix): boolean;

The routine CalcEigVec calculates the eigenvectors and eigenvalues of a symmetrical matrix InMat. The parameter InMat is a pointer to an instance of the class Matrix. The function CalcEigVec returns the value TRUE, if the calculations have been completed successfully.

The results of CalcEigVec (i.e. the eigenvalues and the eigenvectors) are stored in memory and can be read by the routine GetEigenResult. Please note that the 16-bit version of the unit MATH2 allows only a maximum of 90 eigenvectors, whereas the 32-bit version allows 1000 eigenvectors.

CalcEigVec increments the global variable ProcStat and calls the feedback routine MathFeedBackProc in order to allow feedback to the user during time consuming calculations.

Hint:	The eigenvalues and eigenvectors are stored in memory as long as either a new calculation is performed or the results are removed from the memory by explicitly calling the routine RemoveEigenMatrix.

Example:	The statement success := CalcEigVec (data); calculates the eigenvectors and eigenvalues of the matrix data. The variable success is set TRUE, if the calculation has been performed successfully.


 CalcGaussKernel

See also:	CalcGaussKernelMat

Class:	none

Declaration:	function CalcGaussKernel (Probe, RefCenter: TVector; Width: Double): Double;

The function CalcGaussKernel calculates the value of a given n-dimensional Gaussean kernel. The parameters RefCenter and Width define the position and the width of the kernel. The parameter Probe specifies the position in the n-dimensional space where to calculate the value of the kernel.

Hint:	The user has to ensure that the dimensionalities of the vectors Probe and RefCenter are equal. A mismatch of these would result in erroneous results without notification.


 CalcGaussKernelMat

See also:	CalcGaussKernel

Class:	none

Declaration:	function CalcGaussKernelMat (Probe: TVector; RefCenterMat: TMatrix; RefCenterIx: integer; Width: Double): Double;

The function CalcGaussKernelMat calculates the value of a given n-dimensional Gaussean kernel. The parameters RefCenterMat, RefCenterIx, and Width define the position and the width of the Gaussean kernel. The parameter Probe specifies a point in the n-dimensional space where to calculate the value of the kernel.

The routine CalcGaussKernelMat is equivalent to CalcGaussKernel with the exception that the position of the kernel is defined by the row RefCenterIx of the matrix RefCenterMat. This can be of some benefit when calculating the effect of several Gaussean kernels which are defined by the rows of a matrix.

Hint:	The user has to ensure that the dimension of the vector Probe and the first dimension of the matrix RefCenterMat are equal. A mismatch of these would result in erroneous results without notification.


 CalcGaussFit

See also:	CalcLinFit, CalcLogFit

Class:	TCurveFit

Declaration:	procedure CalcGaussFit (var k0, k1, k2, FitQual: double);

The procedure CalcGaussFit calculates the best fitting Gaussean curve (normal distribution) for a given set of data. The curve is determined by the equation

The values of x and y are given by the data samples, the parameters k0, k1, and k2 are estimated by CalcGaussFit using a least squares approximation.

The data points [x,y] have to be entered using the routine EnterStatValue. A minimum number of 3 values is required in order to apply CalcGaussFit. Do not forget to reset the statistics calculation before entering any new data sets (use the method Init)

In addition to the parameters k0, k1, and k2, CalcGaussFit returns the goodness of fit FitQual. This parameter may vary between 0.0 and 1.0, indicating the best possible fit if FitQual equals 1.0.

Hint:	The quality of fit calculated by CalcGaussFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcHyperbolFit

See also:	CalcReciLinFit

Class:	TCurveFit

Declaration:	CalcHyperbolFit (var k0,k1: double; var FitQual: double);

The procedure CalcHyperbolFit calculates the best fitting Hyperbola for a given set of data. The Hyperbola is determined by the equation

The values of x and y are given by the data samples, the parameters k0, and k1 are estimated by CalcHyperbolFit using a least squares approximation.

The data points [x,y] have to be entered using the routine EnterStatValue. A minimum number of 2 values is required in order to apply CalcHyperbolFit. Do not forget to reset the statistics calculation before entering any new data sets (use Init)

In addition to the parameters k0, and k1, CalcHyperbolFit returns the goodness of fit in the parameter FitQual. This quality of fit may vary between 0.0 and 1.0, indicating the best possible fit if FitQual equals 1.0.

Hint:	The quality of fit calculated by CalcHyperbolFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcLinFit

See also:	CalcLogFit, CalcParabolFit, CalcReciLinFit

Class:	TCurveFit

Declaration:	CalcLinFit (var k, d, FitQual: Double);

The procedure CalcLinFit estimates the best fit of a straight line to a sample of two-dimensional data points using linear regression. The line is defined by the equation

y = kx + d.

The data points have to be entered by using the procedure EnterStatValue. A minimum number of 2 values is required in order to apply CalcLinFit. Do not forget to reset the statistics calculation before entering any new data sets (use Init)

The procedure CalcLinFit returns the following parameters: k and d define the slope and the offset of the line, and FitQual returns the goodness of fit of the regression. FitQual equals the square of the correlation coefficient. A good representation of the data samples yields a value near to 1.0 for FitQual.

Hint:	The quality of fit calculated by CalcLinFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcLogFit

See also:	CalcLinFit

Class:	TCurveFit

Declaration:	procedure CalcLogFit (var k0, k1, FitQual: double);

The procedure CalcLogFit calculates the best fitting logarithmic curve for a given set of data. The curve is determined by the equation

y = k0 + k1 * ln(x)

The values of x and y are given by the data samples, the parameters k0, and k1 are estimated by CalcLogFit using a least squares approximation.

The data points [x,y] have to be entered using the routine EnterStatValue. A minimum number of 2 values is required in order to apply CalcLogFit. Do not forget to reset the statistics calculation before entering any new data sets (use the method Init)

In addition to the parameters k0, and k1, CalcLogFit the quality of fit FitQual. This parameter may vary between 0.0 and 1.0, indicating the best possible fit if FitQual equals 1.0.

Hint:	The quality of fit calculated by CalcLogFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcParabolFit

See also:	CalcHyperbolFit, CalcLinFit, CalcPolyFit

Class:	TCurveFit

Declaration:	CalcParabolFit (var k0,k1,k2: Double; var FitQual: Double);

The procedure CalcParabolFit calculates the best fitting parabola for a given set of data. The parabola is determined by the equation

The values of x and y are given by the data samples, the parameters k0, k1, and k2 are estimated by CalcParabolFit using a least squares approximation.

The data points [x,y] have to be entered using the routine EnterStatValue. A minimum number of 3 values is required in order to apply CalcParabolFit. Do not forget to reset the statistics calculation before entering any new data sets (use the method Init)

In addition to the parameters k0, k1, and k2, CalcParabolFit returns the goodness of fit FitQual. This parameter may vary between 0.0 and 1.0, indicating the best possible fit if FitQual equals 1.0.

Hint:	The quality of fit calculated by CalcParabolFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcReciLinFit

See also:	CalcHyperbolFit, CalcLinFit, CalcParabolFit

Class:	TCurveFit

Declaration:	procedure CalcReciLinFit (var k0, k1, FitQual: double);

The procedure CalcReciLinFit calculates the best fitting reciprocal line curve for a given set of data. The curve is determined by the equation

The values of x and y are given by the data samples, the parameters k0, and k1 are estimated by CalcReciLinFit using a least squares approximation.

The data points [x,y] have to be entered using the routine EnterStatValue. A minimum number of 2 values is required in order to apply CalcReciLinFit. Do not forget to reset the statistics calculation before entering any new data sets (use the method Init)

In addition to the parameters k0, and k1 CalcReciLinFit returns the goodness of fit FitQual. This parameter may vary between 0.0 and 1.0, indicating the best possible fit if FitQual = 1.0.

Hint:	The quality of fit calculated by CalcReciLinFit is not adjusted for the degree of freedoms in the regression parameters.

Example:	CURVEFIT.DPR

This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 CalcPrincComp

See also:	RemoveEigenMatrix, GetEigenResult

Class:	none

Declaration:	function CalcPrincComp (InData: TMatrix; LoC, HiC: integer; LoR, HiR: integer; Scaling: integer): boolean;

The procedure CalcPrincComp calculates the principal components of the matrix Indata (Principal Component Analysis, PCA). The rows of the data matrix are objects, the columns are variables. The resulting principal components can be read using the routine GetEigenResult. All eigenvalues are scaled to their sum equal 1.0. The eigenvectors are arranged according to decreasing eigenvalues, thus the first eigenvector corresponds to the first principal component.

The function CalcPrincComp allocates some memory for the storage of the covariance and the eigenvector matrix. The memory for the eigenvector matrix is not deallocated after finishing CalcPrincComp and must be deallocated explicitly by calling the routine RemoveEigenMatrix. If CalcPrincComp is called several times the old eigenvector matrix is released and a new one is allocated.

The parameters LoC, HiC, LoR, and HiR specify the area of the matrix which is used for the principal component analysis. This facilitates the calculation of the principal components of only parts of the input data. Usually, the PCA is applied to all the available data (LoC=1, HiC=InData.NrOfColumns, LoR=1, and HiR=InData.NrOfRows).

The parameter Scaling determines, whether the data should be before calculating the principal components:

Scaling	Result

0	PCA is based on scatter matrix of InData

1	PCA is based on covariance matrix of InData

2	PCA is based on correlation matrix of InData

The function CalcPrincComp returns a TRUE value, if the PCA has been completed successfully. If FALSE is returned, the calculation has been aborted (mostly due to lack of memory).

CalcPrincComp increments the global variable ProcStat and calls the feedback routine MathFeedBackProc in order to allow feedback to the user during time consuming calculations.


 CalcStatistics

See also:	Init, EnterStatValue, CalcLinFit

Class:	TCurveFit

Declaration:	CalcStatistics (var NumData: longint; var MeanX, MeanY, StdevX, StdevY, MeanDiff, StdevDiff, rxy: Double);

The procedure CalcStatistics calculates the mean values, the standard deviations and the correlation coefficient of pairs of numbers. In addition, the mean and the standard deviation of the difference of the pairs are calculated.

In order to make use of CalcStatistics the user has first initialize the internal registers (Init). Thereafter the pairs of x-y-values have to be entered to the register by using the procedure EnterStatValue. The procedure CalcStatistics evaluates the parameters using the data entered to far. It calculates the mean values and the standard deviations of x, y, and the difference x-y, as well as the correlation coefficient between x and y. In addition, the number of data points entered is returned in the parameter NumData.

This procedure can also be used to calculate the mean value and standard deviation for a single series of data. In this case one of the values of the data pair [x,y] should be set to zero when using the procedure EnterStatValue. The calculated correlation coefficient is then, of course, invalid.

Hint 1:	Since it is only meaningful to calculate the standard deviation and the correlation coefficient with at least 3 data points the procedure CalcStatistics refuses to calculate these measures if less than 3 data points have been entered. The standard deviations and the correlation coefficient are set to 0.0 in this case.

Hint 2:	All the parameters returned by CalcStatistics can also be accessed individually by the appropriate properties (CorrCoeff, MeanDiff, MeanX, MeanY, NumData, StdDevDiff, StdDevX, StdDevY).


CorrCoeff property
 CorrCoeff

See also:	EnterStatValue, CalcStatistics, NumData

Class:	TCurveFit

Declaration:	property CorrCoeff: double;

The read-only property CorrCoeff returns the correlation coefficient between the x- and y-values entered by the method EnterStatValue. Note, that at least 3 data pairs have to be entered to calculate a valid correlation coefficient.


 GetEigenSize

See also:	CalcEigVec, CalcPrincComp

Class:	none

Declaration:	function GetEigenSize: integer;

The function GetEigenSize returns the size of the eigenvectors.


 EnterStatValue

See also:	Init, CalcStatistics, CalcLinFit

Class:	TCurveFit

Declaration:	EnterStatValue (x,y: double);

The procedure EnterStatValue is used to enter data points for later statistical evaluation. The parameters x and y are of the type double. A maximum of approx. 2 billion data pairs can be stored; a larger number of calls to EnterStatValue results in a corrupted calculation of the statistical parameters.


 FindCenters

See also:	MeanDistanceKNN, FindNearestNeighbors, AgglomClustering

Class:	none

Declaration:	FindCenters (InMat: TMatrix; RowLo, RowHi: integer; NumCent: integer;  var Centers: TMatrix; var MeanDist: double);

If a matrix is seen as a collection of measurements (rows=objects, columns=variables) it is sometimes useful to calculate prototype objects which are representative for the whole data set. This calculation of the prototypes is equal to the searching of clusters in an n-dimensional space, where n is the number of variables per object.

The procedure FindCenters calculates the specified number of centers NumCent. The parameters RowLo and RowHi determine which objects are used for the calculation.

The centers are calculated as follows: First, the two objects are searched which exhibit the smallest distance of each other. This pair of data is now replaced by their center of gravity. The calculation of the center of gravity allows for the number of data points already used in preceding unifications. Now the unification is repeated until only NumCent points are left. These points are equal to the inquired centers.

The procedure FindCenters returns the found prototypes in the matrix Centers and the mean distance between them in the parameter MeanDist. The user has to take care of by himself that the matrix Centers is large enough to accept all calculated prototype points (i.e. Centers has to have at least NumCent rows and InMat.NrOfCOlumns columns). If the matrix 'Centers' is too small the result will be truncated accordingly. If it is too large, rows from NumCent+1 on are not defined and excess columns are set to zero values.

FindCenters increments the global variable ProcStat and calls the feedback routine MathFeedBackProc in order to allow feedback to the user during time consuming calculations.

Hint 1:	The time it takes to compute the prototypes increases with the third power of the number of objects. Thus it is strongly recommended not to use this algorithm for more than approx. 200 objects.

Hint 2:	FindCenters stores the original data of the matrix in a file named MAT.$$$ in order to reload the data after the calculation of the prototype points. The auxiliary file MAT.$$$ is automatically deleted after the execution of FindCenters.

Example:	FINDCENT.DPR

The example application FINDCENT shows the usage of FindCenters to find centers in a two-dimensional data array. Note, that FINDCENT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included with the MATH2 package.


 FindNearestNeighbors

See also:	FindCenters, MeanDistanceKNN

Class:	none

Declaration:	FindNearestNeighbors (k: integer; InMat: TMatrix; FirstObj, LastObj: integer; DatVec: TVector; KNNList: TMatrix);

This routine calculates the k nearest neighbors of the vector DatVec in the matrix InMat. The rows are considered to be objects, the columns are the variables. The user has to ensure that both the x-dimension of InMat and the length of DatVec are equal to each other. The result is returned as an ordered list in the matrix KNNList (size 2 x k), the first row specifying the nearest neighbor. The first column of KNNList holds the indices into the data matrix InMat, the second column holds the distances to these neighbors. The parameters FirstObj and LastObj define the index of the first and the last object of matrix Inmat to be included with the kNN search.


 GetEigenResult

See also:	CalcEigVec, CalcPrincComp

Class:	none

Declaration:	function GetEigenResult (EigVecNum: integer; VecElem: integer): real;

The routine GetEigenResult returns one element of a specific eigenvector. The parameter EigVecNum defines the number of the eigenvector, the parameter VecElem specifies the number of the element of that vector. If VecElem is set to zero the routine returns the eigenvalue of the eigenvector EigVecNum. Any invalid parameters result in a zero return value.

Hint:	The function GetEigenResult is also used in connection with the procedure CalcPrincComp to read the principal components.

Example:	The statement "if (GetEigenResult (2,0) > 0.1) then ..." checks if the eigenvalue of the second eigenvector is larger than 0.1.


 Init

See also:	EnterStatValue, CalcStatistics, CalcLinFit, CalcParabolFit

Class:	TCurveFit

Declaration:	Init;

The procedure Init initializes the internal variables which are used to calculate fundamental statistical parameters (cf. CalcStatistics). Be sure to apply Init before entering any data.


MeanDiff property
 MeanDiff

See also:	EnterStatValue, CalcStatistics, NumData, MeanX, MeanY

Class:	TCurveFit

Declaration:	property MeanDiff: double;

The read-only property MeanDiff returns the mean value of the difference between the x- and the y-values entered by the method EnterStatValue:


MeanX property
 MeanX

See also:	EnterStatValue, CalcStatistics, NumData, MeanDiff, MeanY

Class:	TCurveFit

Declaration:	property MeanX: double;

The read-only property MeanX returns the mean value of the x-values entered by the method EnterStatValue.


MeanY property
 MeanY

See also:	EnterStatValue, CalcStatistics, NumData, MeanX, MeanDiff

Class:	TCurveFit

Declaration:	property MeanY: double;

The read-only property MeanY returns the mean value of the y-values entered by the method EnterStatValue.


 MeanDistanceKNN

See also:	FindCenters

Class:	none

Declaration:	MeanDistanceKNN (InMat: TMatrix; kn: integer; var DistVec: TVector);

The procedure MeanDistanceKNN calculates the mean distance of the kn nearest neighbors of each sample in the matrix InMat. The rows of the matrix InMat are seen as objects (samples), the columns are regarded as variables (measurements) which define the data space.

The results are stored in the vector DistVec. The user has to assure that the vector DistVec is large enough to accept the distances of all objects (DistVec has to have at least InMat.NrOfRows rows). If the vector DistVec is too small the result will be truncated accordingly.


NumData property
 NumData

See also:	EnterStatValue, CalcStatistics

Class:	TCurveFit

Declaration:	property NumData: longint;

The read-only property NumData returns the number of data pairs entered so far by the method EnterStatValue. The method Init resets NumData to zero.


 RemoveEigenMatrix

See also:	CalcEigVec, CalcPrincComp

Class:	none

Declaration:	RemoveEigenMatrix;

The procedure RemoveEigenMatrix removes an eigenvector matrix from the memory. If no matrix is stored in the memory, the call to RemoveEigenMatrix is without any consequence.


StdDevDiff property
 StdDevDiff

See also:	EnterStatValue, CalcStatistics, NumData, StdDevX, StdDevY

Class:	TCurveFit

Declaration:	property StdDevDiff: double;

The read-only property StdDevDiff returns the standard deviation of the difference between the x- and the y-values entered by the method EnterStatValue.


StdDevX property
 StdDevX

See also:	EnterStatValue, CalcStatistics, NumData, StdDevDiff, StdDevY

Class:	TCurveFit

Declaration:	property StdDevX: double;

The read-only property StdDevX returns the standard deviation of the x-values entered by the method EnterStatValue.


StdDevY property
 StdDevY

See also:	EnterStatValue, CalcStatistics, NumData, StdDevX, StdDevDiff

Class:	TCurveFit

Declaration:	property StdDevY: double;

The read-only property StdDevY returns the standard deviation value of the y-values entered by the method EnterStatValue.


 Registration of Math2

See also:	How to order

The unit Math2 is a shareware component. You can register it for US$ 29.60. In return, you get the newest version of Math2 and unlimited free updates by email. The registered version is, of course, fully functional and does no longer need the Delphi, or the C++Builder IDE. The user may then create stand-alone programs which can be deployed without paying any further licences.

Please note, that the unit MATH2 is based on three other units (Math1, Vector, and Matrix), which are included with the registered version of MATH2. The sources of MATH2 are available separately at a price of US$ 150,- (again, including the sources of Math1, Vector, and Matrix).

 Click here for further details and infos on available discounts.


 Installation of Math2

See also:	Delphi and C++Builder Issues

The installation of the unit is a two-part process. First you have to copy the DCU file(s) to the Delphi (C++ Builder) library. Secondly, you should install the help file of this component into the help system of Delphi (C++ Builder).

Note:	The unit MATH2 is not a visual component. You therefore cannot install it in the VCL palette. The routines of MATH2 are used by including MATH2 into the 'uses' statement of your program.

Delphi installation

C++ Builder installation


 Interface of Math2

Note: you may have to switch to small fonts to get a legible interface list.

interface

  uses

    sysutils, math1, matrix, vector;

  const

    MaxPolyFitOrder = 8;  { maximum number of polynomial terms in CurveFit,

                          do not increase it - higher orders yield poor

                          results due to round-off errors }

  type

    ESDLMath2Error = class(Exception);     { exception type to indicate errors }

    TClusterMethod = (cmSingleLink, cmCompleteLink, cmWard, cmAvgLink, cmFlexLink);

    TCurveFit =

      class (TObject)

      private

        sumx, sumy        : double;

        sumxq, sumyq      : double;

        sumDiff, SumDiffq : double;

        sumxy             : double;

        sumx2y, sumx3     : double;

        sumx4             : double;

        sum1byy           : double;

        sum1byyq          : double;

        sumxbyy           : double;

        sumybyx           : double;

        sum1byx           : double;

        sum1byxq          : double;

        sumlnx            : double;

        sumlnxq           : double;

        sumylnx           : double;

        sumlny            : double;

        sumlnyq           : double;

        sumxlny           : double;

        sumxqlny          : double;

        FNumData          : longint;

        SumXArray         : TVector;

        RHS               : TVector;

        function GetMeanX: double;

        function GetMeanY: double;

        function GetStdDevX: double;

        function GetStdDevY: double;

        function GetMeanDiff: double;

        function GetStdDevDiff: double;

        function GetRxy: double;

      public

        constructor Create;

        destructor Destroy; override;

        procedure Init;

        procedure EnterStatValue (x,y: double);

        procedure CalcStatistics (var NumData: longint;

             var MeanX, MeanY, StdevX, StdevY, MeanDiff,

             StdevDiff, rxy: double);

        procedure CalcGaussFit (var k0, k1, k2, FitQual: double);

        procedure CalcLinFit (var k, d, FitQual: double);

        procedure CalcLogFit (var k0, k1, FitQual: double);

        procedure CalcParabolFit (var k0, k1, k2, FitQual: double);

        function  CalcPolyFit (const nOrder: byte; var kArray: array of double;

                              var FitQual: double): boolean;

        procedure CalcReciLinFit (var k0, k1, FitQual: double);

        procedure CalcHyperbolFit (var k0, k1, FitQual: double);

        property  NumData: longint read FNumData;

        property  MeanX: double read GetMeanX;

        property  MeanY: double read GetMeanY;

        property  StdDevX: double read GetStdDevX;

        property  StdDevY: double read GetStdDevY;

        property  MeanDiff: double read GetMeanDiff;

        property  StdDevDiff: double read GetStdDevDiff;

        property  CorrCoeff: double read GetRxy;

      end;

  function  AgglomClustering

              (InMat : TMatrix;

     DistanceMeasure : TDistMode;

       ClusterMethod : TClusterMethod;

               alpha : double;

     var ClustResult : TIntMatrix;

       var ClustDist : TVector;

    var DendroCoords : TVector)

                     : integer;

  function  CalcCovar

             (InData : TMatrix;                         { input data }

            CovarMat : TMatrix;                  { covariance matrix }

            LoC, HiC : integer;                   { range of columns }

            LoR, HiR : integer;                      { range of rows }

             Scaling : integer)   { 0=none, 1=mean cent., 2=autoscl. }

                     : boolean;                    { TRUE if success }

  function  CalcEigVec

              (InMat : TMatrix)             { symmetric input matrix }

                     : boolean;                    { TRUE if success }

  function  CalcFishQ

              (m1,m2,                     { mean values, class 1 & 2 }

               s1,s2 : double)                 { standard deviations }

                     : double;                        { Fisher ratio }

  function  CalcGaussKernel

              (Probe : TVector;                     { probe position }

           RefCenter : TVector;                   { center of kernel }

               Width : double)                     { width of kernel }

                     : double;                              { result }

  function  CalcGaussKernelMat

              (Probe : TVector;                     { probe position }

        RefCenterMat : TMatrix;           { matrix of kernel centers }

         RefCenterIx : integer;       { index into the kernel matrix }

               Width : double)                     { width of kernel }

                     : double;                              { result }

  function  CalcPrincComp

             (InData : TMatrix;              { pointer to data array }

            LoC, HiC : integer;                   { range of columns }

            LoR, HiR : integer;                      { range of rows }

             Scaling : integer)  { 0=none, 1=mean cent., 2=autoscal. }

                     : boolean;                    { TRUE if success }

  procedure FindCenters

              (InMat : TMatrix;                        { data matrix }

        RowLo, RowHi : integer;                { first & last object }

             NumCent : integer;                  { number of centers }

         var Centers : TMatrix;                  { matrix of centers }

        var MeanDist : double);                      { mean distance }

  procedure FindNearestNeighbors

                  (k : integer;                { number of neighbors }

               InMat : TMatrix;              { matrix to be searched }

            FirstObj : integer;                       { first object }

             LastObj : integer;                        { last object }

              DatVec : TVector;              { vector to be searched }

             KNNList : TMatrix);                            { result }

  procedure FirstDeriv

          (SourceVec : TVector;{ vector with the data to be smoothed }

           FirstElem,                   { start index into SourceVec }

            LastElem : integer;          { stop index into SourceVec }

             DestVec : TVector;                      { result vector }

          WindowSize : integer);              { length of polynomial }

  function  GetEigenResult

          (EigVecNum : integer;              { number of eigenvector }

             VecElem : integer)                     { vector element }

                     : double;                      { matrix element }

  function  GetEigenSize

                     : integer;               { size of eigenvectors }

  procedure MeanDistanceKNN

              (InMat : TMatrix;                        { data matrix }

                  kn : integer;             { # of nearest neighbors }

            FirstRow : integer;            { first object to be used }

             LastRow : integer;             { last object to be used }

          var DistVec: TVector);               { result for each obj }

  procedure PolynomialSmooth

          (SourceVec : TVector;{ vector with the data to be smoothed }

           FirstElem,                   { start index into SourceVec }

            LastElem : integer;          { stop index into SourceVec }

             DestVec : TVector;                      { result vector }

          WindowSize : integer);              { length of polynomial }

  procedure RemoveEigenMatrix;


CalcPolyFit

See also:	CalcParabolFit, MaxPolyFitOrder

Class:	TCurveFit

Declaration:	function CalcPolyFit (const nOrder: byte; var kArray: array of double; var FitQual: double): boolean;  {Pascal}
bool __fastcall CalcPolyFit(const Byte nOrder, double * kArray, const int kArray_Size, double &FitQual);  {C++}

The method CalcPolyFit calculates the best fit for a polynomial of order nOrder. The order of the polynomial is restricted to values between 1 and MaxPolyFitOrder. Higher orders will result in numerical instabilities. The variable array parameter kArray returns the polynomial coefficients, the variable parameter FitQual returns the goodness of fit. The function CalcPolyFit returns a TRUE value if the fit has been calculated successfully, and the returned parameters are valid.

Hint 1:	The number of data used for the polynomial fit has to exceed the order of the polynomial at least by one.

Hint 2:	The declaration of CalcPolyFit in C++ slightly differs from the Pascal declaration (note the extra parameter kArray_Size):
bool __fastcall CalcPolyFit(const Byte nOrder, double * kArray, const int kArray_Size, double &FitQual);

Note:	The method CalcPolyFit has been originally provided by Kerry L. Davison (kerry@lucent.com) and has been adapted to the MATH2 unit by permission of Kerry - thanks Kerry !


MaxPolyFitOrder

See also:	CalcPolyFit

The constant MaxPolyFitOrder defines the maximum allowed order of a polynomial fitted to some data by means of CalcPolyFit. MaxPolyFitOrder is currently set to 8. Note, that a higher value of 8 is not meaningful due to numerical problems with higher orders.


FirstDeriv

See also:	PolynomialSmooth

Class:	none

Declaration:	procedure FirstDeriv (SourceVec: TVector; FirstElem, LastElem: integer; DestVec: TVector; WindowSize: integer);

The procedure FirstDeriv calculates the smoothed first derivative of a series of data by fitting a second order polynomial to the (unsmoothed) first derivative. The number of data points used for estimating the smoothed derivative can be adjusted by setting the parameter WindowSize. It may take values between 5 and 25 and has to be an odd number; any invalid number triggers an ESDLMath2Error exception (see below). The source data series is contained in the vector SourceVec. You may restrict the range of data to be submitted to the derivation algorithm by setting the parameters FirstElem, and LastElem properly. The resulting data series is stored in the vector DestVec (starting at position 1). Please note that the first, and the last (WindowSize div 2) elements cannot be processed and are replaced by the nearest available smoothed value.

Hint:	See also the documentation of the procedure PolynomialSmooth for an example which shows the relationships between the various parameters.

FirstDeriv may create the following exceptions of type ESDLMath2Error:

'FirstDeriv: either SourceVec or DestVec is undefined'

'FirstDeriv: specified range for smoothing is smaller than the length of the polynomial'

'FirstDeriv: length of polynomial is out of range'

'FirstDeriv: length of polynomial must be odd'

Note:	The algorithm of FirstDeriv has been implemented according to the following paper:
A. Savitzky, M.J.E. Golay: Anal.Chem. 36 (1964) 1627


 PolynomialSmooth

See also:	FirstDeriv

Class:	none

Declaration:	procedure PolynomialSmooth (SourceVec: TVector; FirstElem,LastElem: integer; DestVec: TVector; WindowSize: integer);

The procedure PolynomialSmooth smoothes a series of data by fitting a second order polynomial to it. The number of data points used for estimating the smoothed data can be adjusted by setting the parameter WindowSize. It may take values between 5 and 25 and has to be an odd number; any invalid number triggers an ESDLMath2Error exception (see below). The source data series is contained in the vector SourceVec. You may restrict the range of data to be submitted to the smoothing algorithm by setting the parameters FirstElem, and LastElem properly. The resulting smoothed data series is stored in the vector DestVec (starting at position 1). Please note that the first, and the last (WindowSize div 2) elements cannot be smoothed and are replaced by the nearest available smoothed value.

PolynomialSmooth may create the following exceptions of type ESDLMath2Error:

'PolynomialSmooth: either SourceVec or DestVec is undefined'

'PolynomialSmooth: specified range for smoothing is smaller than the length of the polynomial'

'PolynomialSmooth: length of polynomial is out of range'

'PolynomialSmooth: length of polynomial must be odd'

Note:	The algorithm of PolynomialSmooth has been implemented according to the following paper:
A. Savitzky, M.J.E. Golay: Anal.Chem. 36 (1964) 1627

Following is an example for smoothing a data series of 185 points. The elements between 30 and 155 are submitted to the smoothing algorithm using a smoothing window size of 25 elements. Note that the first 12 (=WindowSize div 2), and the last 12 elements of the smoothed series are constant.


 AgglomClustering

See also:	FindCenters

Class:	none

Declaration:	function AgglomClustering (InMat: TMatrix; DistanceMeasure: TDistMode; ClusterMethod: TClusterMethod; alpha: double; var ClustResult: TIntMatrix; var ClustDist: TVector; var DendroCoords: TVector): integer;

The function AgglomClustering performs an agglomerative hierarchical cluster analysis on data contained in matrix InMat. Each data object is represented as one row of the matrix, the columns are forming the variables. The parameter DistanceMeasure specifies the type of distance measurement.

The parameter ClusterMethod specifies the type of clustering method used. If cmFlexLink is used as clustering method, the parameter alpha has to be additionally specified. Alpha may take any value between 0.5 and 1.0. A value of 0.5 results in an average linkage clustering (cmAvgLink). Higher values increase the divisive effects of the clustering process. Usually a value between 0.6 and 0.7 is preferred.

The result of the clustering process is returned in the parameters ClustResult, ClustDist, and DendroCoords. The integer array ClustResult contains the clustering information, describing which clusters (or objects) are joined to form a new cluster. This matrix consists of InMat.NrOfRows-1 rows and three columns. The rows are ordered by increasing cluster distance, which is stored in the parameter ClustDist.

An example should clarify the situation. The results of the cluster analysis shown below have been obtained from a set of 20 observations (objects) with four variables by applying Ward's algorithm (ClusterMethod = cmWard) to it.

------------- ClustResult --------------	ClustDist

number of 	number of 	number of

cluster 1	cluster 2	new cluster	distance

-----------------------------------------------------------

2	19	21	5.0945

1	16	22	5.3573

3	6	23	7.2815

9	10	24	10.2774

8	14	25	10.6847

12	18	26	13.0239

4	25	27	13.5628

24	15	28	16.0441

5	13	29	16.5704

7	17	30	19.2583

23	27	31	24.1079

11	29	32	24.2236

26	20	33	24.6635

22	21	34	26.9456

31	34	35	39.2175

32	28	36	52.7880

36	30	37	90.4147

35	33	38	109.4378

37	38	39	315.1660

-----------------------------------------------------------

The table above is to interpret as follows: clusters (objects) 2 and 19 are joined to form the new cluster 2; the distance between the two original clusters is 5.09. Next, clusters 1 and 16 are joined to form cluster 22 at a distance of 7.28, and so on. Note that any cluster numbers below or equal to InMat.NrOfRows designate the original objects, whereas higher numbers designate clusters built up of other objects and/or clusters. The results of a cluster analysis are normally displayed as a dendrogram:

In order to facilitate the drawing of a dendrogram, the parameter DendroCoords (a vector of 2*InMat.NrOfRows-1 elements) contains the coordinates of the lines of the corresponding dendrogram. The first InMat.NrOfRows coordinates are those of the objects, the rest refer to the clusters as numbered in the matrix ClustResult (see the example program CLUSTER on details how to use the array DendroCoords).


TClusterMethod

See also:	AgglomClustering

Class:	none

Declaration:	TClusterMethod = (cmSingleLink, cmCompleteLink, cmWard, cmAvgLink, cmFlexLink);

The type TClusterMethod defines the type of clustering method:

cmSingleLink	single linkage

cmCompleteLink	complete linkage

cmWard	Ward's method

cmAvgLink	average linkage

cmFlexLink	flexible approach


MathFeedBackProc [Math1]
 MathFeedBackProc

This routine is part of the unit MATH1

For technical reasons the help file for unit MATH1 is a separate file. You may obtain further information either by using the help file MATH1.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


MouseAction [RChart]
 MouseAction

This routine is part of the unit RCHART

For technical reasons the help file for unit RCHART is a separate file. You may obtain further information either by using the help file RCHART.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


ProcStat [Math1]
 ProcStat

This routine is part of the unit MATH1

For technical reasons the help file for unit MATH1 is a separate file. You may obtain further information either by using the help file MATH1.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


Installation [RChart]
 Installation of RChart

This routine is part of the unit RCHART

For technical reasons the help file for unit RCHART is a separate file. You may obtain further information either by using the help file RCHART.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


SetRange [RChart]
 SetRange

This routine is part of the unit RCHART

For technical reasons the help file for unit RCHART is a separate file. You may obtain further information either by using the help file RCHART.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


ShowGraf [RChart]
 ShowGraf

This routine is part of the unit RCHART

For technical reasons the help file for unit RCHART is a separate file. You may obtain further information either by using the help file RCHART.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


AutoRedraw [RChart]
 AutoRedraw

This routine is part of the unit RCHART

For technical reasons the help file for unit RCHART is a separate file. You may obtain further information either by using the help file RCHART.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


CalcPrincComp [Math2]
 CalcPrincComp

This routine is part of the unit MATH2

For technical reasons the help file for unit MATH2 is a separate file. You may obtain further information either by using the help file MATH2.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


Create [Matrix]
 Create

This routine is part of the unit MATRIX

For technical reasons the help file for unit MATH2 is a separate file. You may obtain further information either by using the help file MATH2.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/


TDistMode [Matrix]
 TDistMode

This routine is part of the unit MATRIX

For technical reasons the help file for unit MATRIX is a separate file. You may obtain further information either by using the help file MATRIX.HLP, or by using the SDL component suite help SDLSUITE.HLP. Both files can be downloaded from our webserver http://www.lohninger.com/

----------

Declaration:	TDistMode = (dmJaccard, dmManhattan, dmEuclid, dmEuclidSqr);

The type declaration TDistMode defines the possible operating modes of the method CalcDistMat. Currently the following distances can be calculated:

dmJaccard	similarity measure first defined by P. Jaccard (sometimes also referred to as Tanimoto coefficient)

dmManhattan	Manhattan or city block distance

dmEuclid	Euclidean distance

dmEuclidSqr	squared Euclidean distance


Unit Plot3D
Plot3D

The unit Plot3D contains a Delphi / C++ Builder visual component which supports the display of three dimensioal surfaces. The surfaces are defined by a rectangular grid of height values, and can be viewed from any angle and in any direction. numeric labels. The component TPlot3D comes together with this help file and a sample program (both Pascal and C++).

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Kohonen
Kohonen

The unit KOHONEN provides a selforganizing map (SOM) as it has been described by Teuvo Kohonen. These SOMs are also known as Kohonen maps, or Kohonen neural networks. The unit KOHONEN contains the class TKohonen which simulates a Kohonen neural network.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Statis
Statis

The unit STATIS offers some of the most fundamental procedures of mathematical statistics. Along with the Gamma and the Beta function, all major types of distributions are implemented (normal, t, F, and chi-square distribution). A major benefit of this package is that the distribution functions are calculated analytically and not by approximations, or by table lookup. Thus the precision is at least eight digits.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit CData
CData

The unit CDATA consists of some important chemical data tables and conversion routines as well as some basic routines processing chemical information. Among these are the conversion of atom symbols to atomic numbers, the chemical atomic weight of all chemical elements, the atom symbols of all elements, the atomic weight of the most abundant isotope of each chemical element, the support of a graphical display of a periodic table of the elements, several important chemical constants, the calculation of the molecular weight, the checking for a correct CAS registry number, and the number of valence electrons.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit DStruct
DStruct

The unit DStruct contains routines, which support the implementation of commonly used data structures (FIFO registers, and bit fields).

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Vector
Vector

The unit Vector offers some of the more important operations for processing floating point vectors. It hides all stuff dealing with array addressing and memory management. Thus, the user may fully concentrate on his/her work with vectors.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Math1
Math1

The unit MATH1 offers several fundamental arithmetic operators and mathematical/logical routines which have not been implemented in Delphi (e.g. hyperbolic functions, tangens, cotangens, or common logarithm). The unit also contains routines to sort data, to produce different numeric formats, to generate random numbers of special distributions, etc. In addition, a special version of the Delphi str procedure is offered which is declared as a function returning the formatted string. This considerably eases the display of numeric values.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit StringL
StringL

The unit StringL offers some means to process strings. A collection of procedures and functions provide several often used string formatting functions. In addition, StringL contains the class TGrep which offers a versatile string search utility using the wide spread definition of regular expressions as e.g. in the Unix command "grep".

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit CForm
CForm

The unit CForm contains a class (TMolForm) which supports the handling and display of molecular formulas.  Apart from displaying chemical formulas using the usual notation (subscripted number of atoms, superscripted isotopic labels), CForm also provides several methods supporting some calculations around chemical formulas:

calculating the molecular weight

comparison of formulas

finding formulas for a given molecular weight

scanning strings for molecular formulas

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit ColSel
ColSel

The unit ColSel contains a Delphi visual component which supports the display of the predefined system colors in a combo box.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit DirTree
DirTree

This component provides a directory tree similar to the one provided by Borland with their sample component TDirectoryOutline. Horwever, TDirTree is much more carefully designed, has less bugs and is much faster. Currently, TDirTree is limited to a maximum of 1900 directories per drive.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Fourier
Fourier

The unit FOURIER contains a visual component for FFT (Fast Fourier Transform).

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Indexer
Indexer

The unit Indexer contains a text indexing machine. The indexes may be created either by use of a thesaurus, or a list of masked keywords, or by indexing every word which is not contained in a list of stop words. Indexer supports the use of regular expressions.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Matrix
Matrix

The unit MATRIX offers some of the most important operations to manage and process two-dimensional real and integer matrices. The object oriented approach of the unit MATRIX hides all stuff dealing with array addressing and memory management. Thus the user may fully concentrate on his/her work.

The unit MATRIX provides two classes, TMatrix and TIntMatrix, which contain a floating point and an integer matrix, respectively. MATRIX offers solutions for the following tasks:

- creation and management of matrices

- filling of matrices

- copying matrices

- matrix arithmetics

- determination of statistical parameters about the matrix elements

- inversion of a square matrix (TMatrix only)

- sorting of elements

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Meter
Meter

The unit Meter contains a Delphi visual component which supports the display of analog meters (the good old index instruments). The component is named TMeter and comes together with this help file and a sample application.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit MatView
MatView

The unit MatView provides a class which visualizes the contents of a matrix by displaying rectangles proportional to the values of the single matrix elements. MatView is especially useful to select matrix cells, rows, or columns in a visual way.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit NumLab
NumLab

The unit NumLab contains a Delphi / C++ Builder visual component which supports the display of numeric labels. The component TNumLab comes together with this help file and a sample program (both Pascal and C++).

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit NumIO
NumIO

The unit NumLab contains a Delphi / C++ Builder visual component which supports the input of numeric data in various formats. The component TNumIO comes together with this help file and a sample program (both Pascal and C++).

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit NTabed
NTabEd

The unit NTabEd contains a Delphi visual component which supports the display and editing of numeric tables. Each table consists of the data table, column and row attributes, column and row headers, and a comment line. All of these items can be manipulated either interactively or programmatically. The data table is based on the class TMatrix.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit RChart
RChart

The unit RChart contains a Delphi visual component which supports the display of scientific graphs. The component is named TRChart and comes together with this help file and several example programs.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


Unit Rot3D
Rot3D

The unit ROT3D displays three-dimensional data and supports flickerfree rotation of the 3D view. The rotation can be achieved either by mouse interaction, or by using built-in methods of the class TRot3D. The data can be viewed from any direction, and can be zoomed and panned. Optionally, axes and/or a bounding box may be displayed.

For technical reasons, this help file is restricted to a single component or unit. If you want to have the cumulative help for all components available from SDL, you may download a free copy of the cumulative help from our web site:

http://www.lohninger.com/


 Type Ambiguities

See also:

Some of the components of SDL have type definitions which are syntactically equal to each other. For organizational reasons they are declared separately in each unit. However, this approach may result in ambigous type declarations, if two or more of these components are used within the same program. The compiler generates the following error message:

Delphi:	Incompatible Types

C++Builder:	Ambiguity between 'xxx::ttt' and 'zzz::ttt'

If such a problem occurs, the user has to explicitely specify the unit, or name space of the type declaration by using the name of the unit preceding the actual identifier. The unit name is separated by a dot (or two colons in case of C++) from the identifier.

Example:	Suppose you are using the components Meter and Numlab on the same form. Both components have defined the property FrameStyle which is of the type TFrameStyle. In order to assign a new frame style during run-time you have to explicitely specify the unit which is used for the type definition:

NumLab1.FrameStyle := Numlab.fsRaised;

Meter1.FrameStyle := Meter.fsRaised;

or the same in C++:

NumLab1->FrameStyle = Numlab::fsRaised;

Meter1->FrameStyle = Meter::fsRaised;


How to order

Back to the Contents

For registration please run the program REGISTER.EXE (which prints the registration form) and send the printed form together with the proper amount of money (preferrably credit cards or cash, for cheques please add US$ 5,-) to the following address:

   SDL

   Software Development Lohninger

   P.O.B. 123

   A-1061 Vienna

   Austria, Europe

   email: helpdesk@lohninger.com

The components are preferrably delivered by electronic means (download from our update server after authorization by email). For quick delivery (within 24 hours), please fax the order form (credit card orders, only) to the fax number indicated at our home page:

http://www.lohninger.com/

There are several additional Delphi / C++Builder components, and other software products available from SDL. Ordering several components (w/o source code) together will entitle you to a discount:

2 components	-10 %

3..5 components	-20 %

more than 5	-30 %

Special Offer 1:

SDL Component Suite: Take all of our Delphi / C++Builder (w/o sources) and pay only US$ 55.

This offer includes:

* unlimited free updates via our webserver

* free support for both the Delphi and the C++Builder versions of the components

Special Offer 2:

SLD Component Suite Pro: Purchase the sources of all of our components and get a free subscription to all future components for only US$ 399. This offer includes:

* full source code of all components

* unlimited free updates via our webserver

* free subscription to future components: your component library is thus automatically growing month by month at no extra costs

* free support for both the Delphi and the C++Builder versions of the components

For the latest release of SDL´s Delphi and C++Builder components and for pricing information see http://www.lohninger.com/ or write to the address above.


A  Personal  Remark

We are putting much effort into the production of  most reliable components and units for other programmers. Everybody  who is using our software gets our expertise at a competitive price. But this is only possible if everybody who uses our software, registers it and pays for it. So, if you don't want to kill the shareware idea, don't hesitate to support our work and register this piece of software.

Hans Lohninger of SDL

Vienna, Austria.


Installing under C++Builder - Non Visual Component
 C++Builder Installation - Non Visual Component

See also:	Delphi installation, SDL Component Suite Help

Please mind that the unit is not a visual component. Therefore, this unit cannot be installed in the C++Builder VCL.

1. Installing the component under C++ Builder 1.0

1.1	Copy the OBJ file(s) to the directory where the C++Builder library is located  (XXX/CBuilder/Lib, or XXX/CBuilder/Lib/Obj).

1.2	Copy the HPP file(s) into the include directory (XXX/CBuilder/Include)

2. Installing the package under C++Builder 3.0

2.1	Copy all HPP files to the include directory of C++Builder (XXX/CBuilder3/Include)

2.2	Copy all DFM, RES, and OBJ files to the object directory of C++Builder (XXX/CBuilder3/lib/obj)

2.3	Copy all BPL files to the binaries directory of C++Builder (XXX/CBuilder3/bin)

2.4	Copy all BPI, DCR, and LIB files to the library directory of C++Builder (XXX/CBuilder3/lib)

2.5	In the C++Builder main menu click on "Component", and then on "Install Packages". This starts the package installation window.

2.6a	If you have previously installed an earlier version of the package, select this earlier version and remove it by clicking on the "Remove" button.

2.6b	Now click on "Add" and select the package to be installed (all package names start with "sdl"). The packages can be found in the binaries directory of C++Builder (XXX/CBuilder3/bin). You may repeat step 2.6 for installing several packages

2.7	When done, click on OK. C++ Builder will then add the selected components to its package library. Note that installed component is not visible in the VCL palette.

Note:	If you are installing several or all of the SDL components, the order of installation is important because some packages require others to be already installed. Here is a sample order which works: CDATA, CFORM, STRINGL, MATH1, VECTOR, MATRIX, MATH2, NTABED, NUMLAB, RCHART, ROT3D, NUMIO, STATIS, DSTRUCT, DIRTREE, COLSEL, FOURIER, METER

2. Adding the help file to the C++Builder help system

2.1  (optional) Copy the HLP file(s) to the help directory of C++Builder

2.2  Run the OpenHelp application from the C++Builder group menu.

2.3  Click on the "Add" button, and add the help file(s) to the "Available Help Files" list

2.4  Select the help file(s) and click on ">"

2.5  Click on OK. Thereafter the C++Builder help system knows about the new component(s).

As an alternative, you could install the cumulative help file SDLSUITE.HLP which covers all components of SDL. The cumulative help is available for free at the following web site:

http://www.lohninger.com/


Installing under Delphi - non visual component
 Delphi Installation - Non Visual Component

See also:	C++ Builder installation, SDL Component Suite Help

1. Installing the unit under Delphi

Please mind that the unit is not a visual component. Therefore, this unit cannot be installed in the Delphi VCL.

1.1. Installation under Delphi, versions 1, 2, and 3

1.1 	Copy the DCU file(s) to the directory where the Delphi library is located.

1.2. Installing the components under Delphi 4

1.2.1. If not already running, start up Delphi 4.

1.2.2. If you have installed a previous (shareware) copy, uninstall it

1.2.3. Select the subdirectory delphi40 of the distribution files

1.2.4. Copy all files of this directory to the Delphi compiler directory (usually  'XYZ\Delphi 4.0\Bin')

1.2.5. Click on "Component" and then on "Install Packages ..."

1.2.6. Click on "Add.." and browse the Delphi library path for sdl*.dpl files

1.2.7. Select the package to be installed

1.2.8. Optinonally, repeat the addition of other packages

1.2.9. Click on OK. Thereafter the selected package(s) is(are) available, but not visible in the VCL palette

Note:	If you are installing several or all of the SDL components, the order of installation is important because some packages require others to be already installed. Here is a sample order which works: CDATA, CFORM, STRINGL, MATH1, VECTOR, MATRIX, MATH2, NTABED, NUMLAB, RCHART, ROT3D, NUMIO, STATIS, DSTRUCT, DIRTREE, COLSEL, FOURIER, METER

2. Merging the help keywords into the master help index

2.1  Copy the HLP and the KWF files to the directory where the master help file DELPHI.HLP is located (usually \DELPHI\BIN).

2.2  Run the HELPINST application from the Delphi group menu.

2.3  Open the master index DELPHI.HDX

2.4  Add the keyword file (.KWF)

2.5 	Save and compile the new index. Thereafter the Delphi master help index includes the keywords for the component's Help screens.

As an alternative, you could install the cumulative help file SDLSUITE.HLP into the Delphi Tools menu. This approach is far better and much more reliable than merging the help files into the master help index. The cumulative help is available for free at the following web site:

http://www.lohninger.com/

-------------------------------

Note:	Assure yourself that the PATH environment variable includes the directory where the help file is stored. Otherwise the Windows help system will not find the new help file. Alternatively, you can copy the help file to the Windows directory.


Delphi and C++Builder Issues

See also:

C++Builder users of class TVector:

Don’t mix up the class TVector with the vector class of the Rogue Wave Standard C++ Library. (Sorry for the duplicate naming).

Any component of SDL comes both for the Delphi and the C++Builder environment. Thus, you get full support both for Delphi and C++Builder with our components. The following general directory layout of the delivered zip files makes it easier to access the parts you need:

Please note, that the RES files of the sample applications are supplied both as a 16-bit and a 32-bit version (denoted by the extension RES16, and RES32). You have to rename the proper version to RES before compiling the sample applications.


Installing the SDL Component Suite Help
 Installation of the SDL Component Suite Help

See also:	C++ Builder installation, Delphi installation

If you want to install the SDL Component Suite help file into the tools menu of the Delphi or C++Builder IDE, you have to perform the folowing steps:

Delphi 1.0

1.	Click on the "Options" command in the main menu

2.	Click on "Tools..." in the submenu

3.	Click on "Add..." in the tools window

4a.	Enter a title for the help file (e.g. "SDL Help")

4b.	Browse your computer for the program "Winhelp.exe" (which is normally located in the Windows directory "c:\windows")

4c.	In the "Parameters" box, enter the full path of the help file (e.g. "d:\delphi20\compiler\help\sdl16.hlp")

4d.	Click on "OK", and then on "Close"

The cumulative help of the Delphi Componente Suite should now be available from the "Tools" menu of Delphi 1

Delphi 2.0/3.0/4.0, C++Builder 1.0/3.0

1.	Delphi 2, and 3: Click on the "Tools" command in the main menu

2a.	Delphi 2: Click on "Tools..." in the submenu

2b.	Delphi 3 & 4, C++Builder: Click on "Configure Tools..." in the submenu

3.	Click on "Add..." in the tools window

4a.	Enter a title for the help file (e.g. "SDL Help")

4b.	Browse your computer for the program "Winhlp32.exe" (which is normally located in the Windows directory "c:\windows")

4c.	In the "Parameters" box, enter the full path of the help file (e.g. "d:\delphi20\compiler\help\sdl32.hlp")

4d.	Click on "OK", and then on "Close"

The cumulative help of the Delphi Componente Suite should now be available from the "Tools" menu of the IDE.


Nag Hints in the Registered Version
 How to get rid of the nag hints in the registered versions

See also:

Question:

I recently registered this component and installed what I downloaded from the SDL update area. However, the component still lists itself to be the unregistered version.

Answer:

1) you have an old unregistered version of the component somewhere lurking on your harddisk (use the file find utility of the Windows explorer to check that). If so, remove it, deinstall the shareware copy from the VCL and install the registered version again.

2) another often experienced reason can be found in the fact that the Hint property is just set to the shareware message (from previous usage of the unregistered component). In this case, you should simply change the Hint property and/or turn the ShowHint property off.

A simple check whether the registered or the unregistered component has been linked into your program can be performed by starting the application program without running Delphi and/or C++Builder on the system. If the application uses the unregistered component, the program should overwrite the component area with a copyright message. In this case see point 1 above, otherwise point 2.


Linker error when installing RChart
I run into linker error when installing RChart

See also:	Installation of RChart

Question:

I followed the installation instructions but got a linker error when installing RChart:

[Linker Err] Undefined symbol Rcbakbmp::Register[] __fastcall referenced ....

[Linker Err] Undefined symble Rccommon::Register[] __fastcall referenced .....

What's wrong ?

Answer:

Previous versions of RChart (earlier than release 4.00) needed two additional files, RCBAKBMP and RCCOMMON, which contained some basic routines and declarations. These files are not for VCL installation. The only purpose for these files was to circumvent the 64k restrictions of Delphi 1.0. Release 4.00 and higher of RChart does no longer support Delphi 1.0 and thus does not need these files anymore.

In case you encounter this error (if you use an older version of RChart), you tried to install one of these additional files along with RCHART into the VCL. Do not install them, just copy these files to the library directory of Delphi/C++Builder.


Moving the viewing port of RChart
How to quickly move the viewing port of RChart

See also:

With charts containing a large number of graphics items, you have to be careful to avoid triggering the OnPaint event more than once. One way to get the most speed is as follows:

1) Set the property AutoRedraw to false

2) Use the method SetRange to set the coordinates of the new viewing port at once.

3) Call the method ShowGraf

As a rule of thumb on the maximum speed of changing the viewport, you should compare to the pan action if the mouse property MouseAction is set to maPan.


PCA is too slow
The calculation if the principal components is too slow

See also:	CalcPrincComp

Question:

The principal component calculation of unit Math2 is so slow if there are many variables involved.

Answer:

If the calculation of the principal components is too slow, this usually arises from a transposed data matrix with a lot of columns but only a few rows. If you face such a problem you can dramatically speed up the calculations by transposing the data matrix prior to the calculation, and exchanging loadings and scores after it. Note that this trick only works if the number of rows is considerably less than the number of columns of the data matrix.


Frequently asked questions
 Frequently Asked Questions  /  Tips and Tricks

See also:

Registered vs. shareware versions; license and update policy

I can't get rid of the nag hints after buying the registered version

Do I have to pay any royalties if I develop a commercial application using your components ?

How many licenses are required, given that several programmers of our team are using SDL's components ?

If I purchase SDL components now, do I get any updates for the next release of Delphi/C++Builder ?

I loaded the registered version from your update area, however it seems that the downloaded software is a shareware copy

Tips and tricks, common problems

How to quickly move the viewing port of RChart

The principal component analysis is so slow with many variables

What is the maximum number of points RChart can display ?

The mouse cursor does not change to its default state when moved outside RChart.

I get an "access violation error", when using TMatrix.

Installation problems

I run into linker error when installing RChart

How to get SDL help suite installed so that Delphi help recognizes it.

I cannot install unit XYZ into the Delphi/C++Builder VCL


Royalties

See also:

Question:

Do I have to pay any royalties if I develop a commercial application using your components ?

Answer:

No, definitely not. You are free to use the registered components in your commerical applications without paying any royalties to us. However, you (1) must not give away any DCU or PAS files bought from us, and (2) you must not create and deploy any similar components based on our components.


Max. Number of Data Points
Maximum number of points RChart can display ?

See also:

Question:

What is the maximum number of points RChart can display ?

Answer:

The maximum number of points is limited only by computer memory. However, the display gets slower with more points in the chart. We have tested it with up to 100000 data points.


Site Licenses

See also:

Question:

Our development team consists of five programmers. How many licenses do you require to be purchased, given that each programmer will need a copy of the component installed on their machine? Are there any discounts available in this situation?

Answer:

You need a license for each of the programmers working with our components. However we offer the following discounts

2 licenses: -10%

3..5 licenses: -20%

6..10 licenses: -30%

more than 10 licenses: please ask

Each programmer of your team will be supported by our update policy as if he/she had ordered it by their own. This includes regular updates and hotline support by email.


Installation of SDL Help
Installation of SDL Help into Delphi/C++Builder

See also:

Question:

How to get SDL help suite installed so Delphi help recognizes it.

Answer:

Help files are a still unresolved problem with Delphi. If the keyword file is getting too large, then the help system crashes. So we recommend to install the SDL help into the Tools section of the Delphi IDE. This is less convenient but it works.


Access Violation Error
Access violation errors with TMatrix and TVector

See also:	TMatrix.Create

Question:

I am having some difficulty with matrix assignments. The following code produces access violation errors:

procedure TForm1.XXX (Sender: TObject);

var

  userdata : Tmatrix;

begin

userdata.Create(5,5);

userdata.elem[1,1] := 2.332;  <--- this assignment causes the problems

....

Answer:

You made a mistake in creating the matrix. The correct statement should read like this:

...

begin

userdata := TMatrix.Create (5,5);   <--- mind the difference !

userdata.elem[1,1] := 2.332;        <--- no problems any more

...


Mouse Cursor in RChart
Mouse cursor behavior in connection with RChart

See also:	MouseAction

Question:

When the mouse cursor moves out of the RChart component fast, it retains the cursor type assigned by the component (say, cross or hand). It does not happen when the mouse is moved slowly.

Answer:

This is not a problem of RChart but of the Windows messaging system. See also hint 1 in the MouseAction page of the RChart help file.


Updates
Updates for new compiler releases

See also:

Question:

If I purchase SDL components now, do I get any updates for the next release of Delphi/C++Builder ?

Answer:

If you purchase our components, you get all upgrades for future compiler versions for free (via our update server). More information on our update policy can be found on our web site: http://www.lohninger.com/udarea.html


Installation of non-visual components

See also:

Question:

I cannot install unit XYZ into the Delphi/C++Builder VCL. I get an undefined reference in the XYZ object that goes something like this:

Undefined reference XYA::Register() in .....

Answer:

Some of the SDL units are non-visual components (for example MATH1, or MATRIX, or CDATA, ...) which cannot be installed into the VCL palette. The units are to be used in your application by simply including the unit name into the uses statement of your program (don't forget to set the library path to your unit files).


Registered and Shareware Copies
 Registered version behaves like shareware copy

See also:	shareware Hint property

Question:

I loaded the registered version from the SDL update area, however it seems that the downloaded software is a shareware copy

Answer:

You can be assured that any copy obtained from our update server is registered. The most common reason for this problem is that there are several copies of the software (some shareware, some registered) lurking somewhere on your hard disk, and the linker/procject pathes point to an unregistered copy.