Zenautics::Matrix Class Reference

#include <Matrix.h>

List of all members.


Detailed Description

The matrix/vector class. Both real and complex data are inherently supported. One and two dimensional data.

The matrix class supports advanced real and complex functionality. It is optimized for columnwise operations. Refer to example_main.cpp for a complete example program using the Matrix.

Definition at line 131 of file Matrix.h.


Public Member Functions

 Matrix ()
 The default constructor (no data allocated yet).
 Matrix (const unsigned nrows)
 A vector style constructor.
 Matrix (const unsigned nrows, const unsigned ncols, const bool isReal=true)
 A matrix style constructor.
 Matrix (const Matrix &mat)
 The copy constructor.
 Matrix (const char *path, bool &itWorked)
 A constructor reading data from a file.
 Matrix (const double mat[], const unsigned nrows, const unsigned ncols=1)
 The constructor as a copy from a static matrix.
virtual ~Matrix ()
 The destructor.
Matrixoperator= (const Matrix &mat)
 The assignment operator from another matrix.
Matrixoperator= (const double value)
 The assignment operator from a scalar double value.
Matrixoperator= (const std::complex< double > value)
 The assignment operator from a std::complex<double> value.
Matrixoperator= (const char *strMatrix)
 The assignement operator from a string matrix.
bool Clear ()
 Clear the matrix memory. Set the matrix to size 0x0.
bool isEmpty () const
 Is this matrix empty?
bool isConformal (const Matrix &mat) const
 Is the matrix mat conformal for multiplication (*this * mat)?
bool isSameSize (const Matrix &mat) const
 Is this matrix the same size as mat?
bool isSquare () const
 Is this a square matrix?
bool isStoredAsComplex ()
 Check if this matrix is stored as a complex matrix.
bool isReal ()
 Check if this a real matrix.
bool isComplex ()
 Check if this a complex matrix.
bool isVector ()
 Check if this is a vector. Is the matrix either nx1 or 1xn.
unsigned GetNrCols () const
 return no. of cols
unsigned ncols () const
 return no. of cols
unsigned GetNrElems () const
 return total no. of elements
unsigned nelems () const
 return total no. of elements
unsigned GetNrRows () const
 return no. of rows
unsigned nrows () const
 return no. of rows
unsigned GetLength () const
 return the maximum dimension either nrows or ncols whichever is greater.
double real (const unsigned row, const unsigned col)
 Return the real part of the matrix at this row and column.
double real (const unsigned index)
 Return the real part of the matrix at this vector index.
double imag (const unsigned row, const unsigned col)
 Return the imaginary part of the matrix at this row and column.
double imag (const unsigned index)
 Return the imaginary part of the matrix at this vector index.
bool ReadFromFile (const char *path)
 Read the matrix from an ASCII file with the path given by the 'c' style string (with automatric support for many delimiters, whitespace, or ',', or ';', or many others) or a compressed BINARY matrix file used in the Save function. Complex and real data input are supported. A non-numeric header line can be present which will be skipped.
bool ReadFromFile (std::string path)
 Read the matrix from a file given the file path as a standard string.
bool Copy (Matrix &src)
 A safe function for performing a copy of another matrix.
bool Copy (const double &value)
 A safe function for setting the matrix from a double.
bool Copy (const std::complex< double > &cplx)
 A safe function for setting the matrix from a std::complex<double>.
bool Save (const char *path)
 Saves a matrix to the specified file path (a 'c' style string) using a proprietary compressed format. ADVANCED EDITION ONLY. BASIC EDITION will return false.
bool Save (std::string path)
 Saves a matrix to the specified file path (a std::string) using a proprietary compressed format. ADVANCED EDITION ONLY. BASIC EDITION will return false.
bool Print (const char *path, const unsigned precision, bool append=false)
 Print the matrix to a file with automatically determined column width and the specified precision, uses "%'blank''-'autowidth.precision'g'", to the 'c' style path string provided.
bool Print (std::string path, const unsigned precision, bool append=false)
 Print the matrix to a file with automatically determined column width and the specified precision, uses "%'blank''-'autowidth.precision'g'", to the std:string path provided.
bool PrintStdout (const unsigned precision=6)
 Print the matrix to the standard output (stdout) with automatically determined column width and the specified precision, uses "%'blank''-'autowidth.precision'g'".
bool PrintToBuffer (char *buffer, const unsigned maxlength, const unsigned precision)
 Print the matrix to a buffer of maxlength with automatically determined column width and the specified precision, uses "%'blank''-'autowidth.precision'g'".
bool PrintFixedWidth (const char *path, const unsigned width, const unsigned precision, bool append=false)
 Print the matrix to a file with specifed width and precision PrintAutoWidth is recommended over this function, "%'blank''-'width.precision'g'" to file specified with the 'c' style path string provided.
bool PrintFixedWidth (std::string path, const unsigned width, const unsigned precision, bool append=false)
 Print the matrix to a file with specifed width and precision PrintAutoWidth is recommended over this function, "%'blank''-'width.precision'g'" to file specified with the std::string path string provided.
bool PrintFixedWidthToBuffer (char *buffer, const unsigned maxlength, const unsigned width, const unsigned precision)
 Print the matrix to a buffer of maxlength with specifed width and precision PrintAutoWidth is recommended over this function, "%'blank''-'width.precision'g'".
bool PrintDelimited (const char *path, const unsigned precision, const char delimiter, bool append=false)
 Print the matrix to a file path specified by the 'c' style string with specifed precision and delimiter.
bool PrintDelimited (std::string path, const unsigned precision, const char delimiter, bool append=false)
 Print the matrix to a file path specified by the std::string with specifed precision and delimiter.
bool PrintDelimitedToBuffer (char *buffer, const unsigned maxlength, const unsigned precision, const char delimiter)
 Print the matrix to a 'c' style string buffer of maxlength with specifed precision and delimiter.
bool PrintRowToString (const unsigned row, char *buffer, const unsigned maxlength, const int width, const int precision)
 Print a row to a 'c' style string buffer.
bool RemoveColumn (const unsigned col)
 Remove a single column from the matrix.
bool RemoveColumnsAfterIndex (const unsigned col)
 Remove all the columns 'after' the column index given.
bool RemoveRowsAndColumns (const unsigned nrows, const unsigned rows[], const unsigned ncols, const unsigned cols[])
 Remove the rows and columns specified by the indices in the rows[] and cols[] arrays.
bool InsertColumn (const Matrix &src, const unsigned dst_col, const unsigned src_col)
 Insert a column matrix into the matrix.
bool AddColumn (const Matrix &src, const unsigned src_col)
 Add a column to the end of the matrix.
bool Concatonate (const Matrix &src)
 Combine two matrices with the same nrows, A becomes A|B.
bool Redim (const unsigned nrows, const unsigned ncols=1)
 Redimension the matrix, original data is saved in place, new data is set to zero. The default value for ncols allows redimensioning as a vector.
bool Resize (const unsigned nrows, const unsigned ncols=1)
 Resize the matrix, original data is lost, new data is set to zero. The default value for ncols allows resizing as a vector.
bool SetFromStaticMatrix (const double mat[], const unsigned nrows, const unsigned ncols)
 Set the matrix from the static 'c' style matrix indexed by mat[i*ncols + j].
bool SetFromMatrixString (const char *strMatrix)
 Setting the matrix values from a string matrix.
bool CopyColumn (const unsigned src_col, Matrix &dst)
 Copy the src data in column col to dst matrix, resize dst if possible and necessary.
bool InsertSubMatrix (const Matrix &src, const unsigned dst_row, const unsigned dst_col)
 Insert a submatrix (src) into dst, starting at indices dst(row,col).
bool Zero ()
 Zero the entire matrix.
bool ZeroColumn (const unsigned col)
 Zero all elements in a specified column.
bool ZeroRow (const unsigned row)
 Zero all elements in a specified row.
bool Fill (const double value)
 Fill the matrix with the given value.
bool FillColumn (const unsigned col, const double value)
 Fill the matrix column with the given value.
bool FillRow (const unsigned row, const double value)
 Fills the matrix row with the given value.
bool FlipColumn (const unsigned col)
 Reverse the order of elements of a column.
bool FlipRow (const unsigned row)
 Reverse the order of elements of a row.
bool Identity ()
 Set the matrix to identity using the current dimensions.
bool Identity (const unsigned dimension)
 Set the matrix to identity using the specified dimension (nxn).
bool Inplace_Transpose ()
 Transpose the matrix as an inplace operation.
bool Inplace_Round (const unsigned precision=0)
 Round the matrix elements to the specified presision.
e.g. precision = 0 1.8 -> 2 (default)
e.g. precision = 1, 1.45 -> 1.5
e.g. precision = 2 1.456 -> 1.46
e.g. precision = 3, 1.4566 -> 1.457
.
bool Inplace_Floor ()
 Round the matrix elements to the nearest integers towards minus infinity.
bool Inplace_Ceil ()
 Round the matrix elements to the nearest integers towards infinity.
bool Inplace_Fix ()
 Rounds the matrix elements of X to the nearest integers towards zero.
bool Inplace_AddScalar (const double scalar)
 Add a scaler double (ie: M += 5).
bool Inplace_SubtractScalar (const double scalar)
 Subtract a scaler double (ie: M -= 5).
bool Inplace_MultiplyScalar (const double scalar)
 Multiply by scaler double (ie: M *= 5).
bool Inplace_DivideScalar (const double scalar)
 Divide by scaler double (ie: M /= 5).
bool Inplace_PowerScalar (const double scalar)
 Raise the matrix to a power scaler double (ie: M ^= 5).
bool Inplace_AddScalarComplex (const std::complex< double > cplx)
 Add a scaler double (ie: M += (4+2i)).
bool Inplace_SubtractScalarComplex (const std::complex< double > cplx)
 Subtract a scaler double (ie: M -= (5+2i)).
bool Inplace_MultiplyScalarComplex (const std::complex< double > cplx)
 Multiply by scaler double (ie: M *= (5+2i)).
bool Inplace_DivideScalarComplex (const std::complex< double > cplx)
 Divide by scaler double (ie: M /= (5+1i)).
bool Inplace_PowerScalarComplex (const std::complex< double > cplx)
 Raise the matrix to a power scaler double (ie: M ^= (5+2i)).
bool Inplace_Abs ()
 Compute the absolute value of each element in the matrix.
bool Inplace_Sqr ()
 Compute the value^2 of each element in the matrix.
bool Inplace_Sqrt ()
 Computes the sqrt(value) of each element in the matrix.
bool Inplace_Exp ()
 Computes the exp(value) of each element in the matrix.
bool Inplace_Ln ()
 Computes the natural logarithm, ln(value) of each element in the matrix.
bool Inplace_Increment ()
 Add +1.0 to all elements, e.g. M++.
bool Inplace_Decrement ()
 Subtract 1.0 from all elements, e.g. M--.
bool Inplace_Add (const Matrix &B)
 Add matrix B to this matrix inplace. A += B, inplace.
bool Inplace_Subtract (const Matrix &B)
 Subtract matrix B from this matrix inplace. A -= B, inplace.
bool Inplace_PreMultiply (const Matrix &B)
 Pre-Multiply this matrix by B. A = B*A, inplace.
bool Inplace_PostMultiply (const Matrix &B)
 Post-Multiply this matrix by B. A = A*B, inplace.
bool Inplace_DotMultiply (const Matrix &B)
 Dot multiply A .*= B, inplace. A and B must have the same dimensions.
bool Inplace_DotDivide (const Matrix &B)
 Dot divide A ./= B, inplace. A and B must have the same dimensions.
bool Inplace_SortAscending ()
 Sorts each column of the matrix in ascending order. If complex, sorts based on magnitude.
bool Inplace_SortDescending ()
 Sorts each column of M in descending order. If complex, sorts based on magnitude.
bool Inplace_SortColumnAscending (const unsigned col)
 Sorts a specific column in ascending order. If complex, sorts based on magnitude.
bool Inplace_SortColumnDescending (const unsigned col)
 Sorts a specific column in descending order. If complex, sorts based on magnitude.
bool Inplace_SortColumnIndexed (const unsigned col, Matrix &Index)
 Sorts a specific column in ascending order and fills a column vector with the sorted index. The index vector will be resized if needed. If complex, sorts based on magnitude.
bool Inplace_SortByColumn (const unsigned col)
 Sorts the entire matrix by a specific column. If complex, sorts based on magnitude.
bool Inplace_Invert ()
 Computes the inplace inverse of the matrix.
bool Inplace_InvertRobust ()
 Perfroms an inplace inverse using Gaussian Elimination methods.
bool Inplace_LowerTriangularInverse ()
 Compute the inplace inverse of a unit lower triangular matrix.
bool Inplace_FFT ()
 Compute the inplace Fourier Transform of each column of the matrix.
bool Inplace_IFFT ()
 Compute the inplace inverse Fourier Transform of each column of the matrix.
bool Add (const Matrix &B, const Matrix &C)
 Add A = B+C. The result, A, is stored in this matrix.
bool Subtract (const Matrix &B, const Matrix &C)
 Subtract A = B-C. The result, A, is stored in this matrix.
bool Multiply (const Matrix &B, const Matrix &C)
 Multiply A = B*C. The result, A, is stored in this matrix.
bool Inplace_abs ()
 Compute the absolute value of each element of the matrix inplace.
bool Inplace_acos ()
 Compute the arc-cosine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1). Results in radians.
bool Inplace_acosd ()
 Compute the arc-cosine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1). Results in degrees.
bool Inplace_acosh ()
 Compute the inverse hyperbolic cosine of each element of the matrix inplace. Results in radians.
bool Inplace_angle ()
 Compute the phase angle in radians of the elements of the matrix.
bool Inplace_asin ()
 Compute the arc-sine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1). Results in radians.
bool Inplace_asind ()
 Compute the arc-sine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1). Results in degrees.
bool Inplace_asinh ()
 Compute the inverse hyperbolic sine of each element of the matrix inplace. Results in radians.
bool Inplace_atan ()
 Compute the arc-tangent of each element of the matrix inplace. Results in radians bounded [-pi/2, pi/2].
bool Inplace_atand ()
 Compute the arc-tangent of each element of the matrix inplace. Results in degrees bounded [-90, 90].
bool Inplace_atanh ()
 Compute the inverse hyperbolic tangent of each element of the matrix inplace.
bool Inplace_colon (double start, double increment, double end)
 Create a column vector [start:increment:end) beginning at start with step size of increment until less than or equal to end. Note that arguments must be real scalars.
.
bool Inplace_cos ()
 Compute the cosine of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_cosh ()
 Compute the hyperbolic cosine of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_cot ()
 Compute the cotangent of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_coth ()
 Compute the hyperbolic cotangent of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_conj ()
 Complex conjugate. z = x+yi. conj(z) = x-yi.
bool Inplace_exp ()
 Compute the exponential of each element of the matrix inplace. If real, computes the exp(value) of each element in the matrix. If complex, computes exp(M) = exp(real)*(cos(imag)+i*sin(imag)).
bool Inplace_eye (const unsigned nrows, const unsigned ncols)
 Create an indentity matrix with nrows and ncols.
bool Inplace_imag ()
 Imaginary part of the complex matrix. z = x+yi. real(z) = y.
bool Inplace_log2 ()
 Compute the log base 2 of the elements of the matrix. Complex results if elements are negative.
bool Inplace_log10 ()
 Compute the log base 10 of the elements of the matrix. Complex results if elements are negative.
bool Inplace_ones (const unsigned nrows, const unsigned ncols)
 Create a matrix of nrows by ncols filled with 1.0.
bool Inplace_real ()
 Real part of the complex matrix. z = x+yi. real(z) = x.
bool Inplace_sin ()
 Compute the sine of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_sinc ()
 Compute the sinc of each element*pi of the matrix inplace. i.e. y = sin(pi*x)./(pi*x).
bool Inplace_sinh ()
 Compute the hyperbolic sine of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_sqrt ()
 Compute the sqrt of each element of the matrix inplace.
bool Inplace_tan ()
 Compute the tangent of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_tanh ()
 Compute the hyperbolic tangent of each element of the matrix inplace. This function assumes radian values in the matrix.
bool Inplace_zeros (const unsigned nrows, const unsigned ncols)
 Create a matrix of nrows by ncols filled with 0.0.
bool GetStats_MaxAbs (unsigned &row, unsigned &col, double &value)
 Computes the value of the largest absolute element and its index.
bool GetStats_Max (unsigned &row, unsigned &col, double &re, double &im)
 Computes the value (re+im*j) of the maximum element and its index. When complex the maximum absolute value is determined.
bool GetStats_MaxVal (double &re, double &im)
 Computes the value (re+im*j) of the maximum element. When complex the maximum absolute value is determined.
bool GetStats_MaxAbsCol (const unsigned col, double &value, unsigned &row)
 Computes the value of the largest absolute column element and its row index.
bool GetStats_MaxCol (const unsigned col, double &re, double &im, unsigned &row)
 Computes the value (re+im*j) of the maximum column element and its row index.
bool GetStats_MaxColVal (const unsigned col, double &re, double &im)
 Computes the value (re+im*j) of the maximum column element.
bool GetStats_MaxAbsRow (const unsigned row, double &value, unsigned &col)
 Computes the value of the largest absolute row element and its column index.
bool GetStats_MaxRow (const unsigned row, double &re, double &im, unsigned &col)
 Computes the value (re+im*j) of the maximum row element and its column index.
bool GetStats_MaxRowVal (const unsigned row, double &re, double &im)
 Computes the value (re+im*j) of the maximum row element.
bool GetStats_MinAbs (unsigned &row, unsigned &col, double &value)
 Computes the value of the smallest absolute element and its index.
bool GetStats_Min (unsigned &row, unsigned &col, double &re, double &im)
 Computes the value (re+im*j) of the minimum element and its index.
bool GetStats_MinVal (double &re, double &im)
 Computes the value (re+im*j) of the minimum element.
bool GetStats_MinAbsCol (const unsigned col, double &value, unsigned &row)
 Computes the value of the smallest absolute column element and its row index.
bool GetStats_MinCol (const unsigned col, double &re, double &im, unsigned &row)
 Computes the value (re+im*j) of the minimum column element and its row index.
bool GetStats_MinColVal (const unsigned col, double &re, double &im)
 Computes the value (re+im*j) of the minimum column element.
bool GetStats_MinAbsRow (const unsigned row, double &value, unsigned &col)
 Computes the value of the smallest absolute row element and its column index.
bool GetStats_MinRow (const unsigned row, double &re, double &im, unsigned &col)
 Computes the value (re+im*j) of the minimum row element and its column index.
bool GetStats_MinRowVal (const unsigned row, double &re, double &im)
 Computes the value (re+im*j) of the minimum row element.
bool GetStats_ColRange (const unsigned col, double &re, double &im)
 Computes the range of the data in the specified column. Range = MaxVal - MinVal. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_RowRange (const unsigned row, double &re, double &im)
 Computes the range of the data in the specified row. Range = MaxVal - MinVal. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_Range (double &re, double &im)
 Computes the range of the data in the matrix. Range = MaxVal - MinVal. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_ColumnSum (const unsigned col, double &re, double &im)
 Computes the sum for the specified column. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_RowSum (const unsigned row, double &re, double &im)
 Computes the sum for the specified row. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_Sum (double &re, double &im)
 Computes the sum for the matrix. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_ColumnMean (const unsigned col, double &re, double &im)
 Computes the sample mean for the specified column. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_RowMean (const unsigned row, double &re, double &im)
 Computes the sample mean for the specified row. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_Mean (double &re, double &im)
 Computes the sample mean for the matrix. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_ColumnStdev (const unsigned col, double &value)
 Computes the sample standard deviation for the specified column.
bool GetStats_RowStdev (const unsigned row, double &value)
 Computes the sample standard deviation for the specified row.
bool GetStats_Stdev (double &value)
 Computes the sample standard deviation for the matrix.
bool GetStats_ColumnVar (const unsigned col, double &value)
 Computes the sample variance for the specified column.
bool GetStats_RowVar (const unsigned row, double &value)
 Computes the sample variance for the specified row.
bool GetStats_Var (double &value)
 Computes the sample variance for the matrix.
bool GetStats_ColumnNorm (const unsigned col, double &value)
 Computes the norm of the specified column. If real, norm = sqrt( sum( val*val ) ). If complex, norm = sqrt( sum( val*conjugate(val) ) ).
bool GetStats_RowNorm (const unsigned row, double &value)
 Computes the norm of the specified row. If real, norm = sqrt( sum( val*val ) ). If complex, norm = sqrt( sum( val*conjugate(val) ) ).
bool GetStats_Norm (double &value)
 Computes the norm of the matrix. If real, norm = sqrt( sum( val*val ) ). If complex, norm = sqrt( sum( val*conjugate(val) ) ).
bool GetStats_ColumnRMS (const unsigned col, double &value)
 Computes the sample RMS value for the specified column.
bool GetStats_RowRMS (const unsigned row, double &value)
 Computes the sample RMS value for the specified row.
bool GetStats_RMS (double &value)
 Computes the sample RMS value for the matrix.
bool GetStats_ColumnSkewness (const unsigned col, double &re, double &im)
 Computes the sample skewness value for the specified column. The skewness is the third central moment divided by the cube of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_RowSkewness (const unsigned row, double &re, double &im)
 Computes the sample skewness value for the specified row. The skewness is the third central moment divided by the cube of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_Skewness (double &re, double &im)
 Computes the sample skewness value for the matrix. The skewness is the third central moment divided by the cube of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set.
bool GetStats_ColumnKurtosis (const unsigned col, double &re, double &im)
 Computes the sample kurtosis value for the specified column. The kurtosis is the fourth central moment divided by fourth power of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set. To adjust the computed kurtosis value for bias, subtract 3 from the real component. Reference: http://en.wikipedia.org/wiki/Kurtosis. Reference: http://mathworld.wolfram.com/Kurtosis.html (kurtosis proper is computed).
bool GetStats_RowKurtosis (const unsigned row, double &re, double &im)
 Computes the sample kurtosis value for the specified row. The kurtosis is the fourth central moment divided by fourth power of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set. To adjust the computed kurtosis value for bias, subtract 3 from the real component. Reference: http://en.wikipedia.org/wiki/Kurtosis. Reference: http://mathworld.wolfram.com/Kurtosis.html (kurtosis proper is computed).
bool GetStats_Kurtosis (double &re, double &im)
 Computes the sample kurtosis value for the matrix. The kurtosis is the fourth central moment divided by fourth power of the standard deviation. If the matrix is real, only the real value, re is set, im = 0. If the matrix is complex, both re and im are set. To adjust the computed kurtosis value for bias, subtract 3 from the real component. Reference: http://en.wikipedia.org/wiki/Kurtosis. Reference: http://mathworld.wolfram.com/Kurtosis.html (kurtosis proper is computed).
bool GetTrace (double &re, double &im)
 Computes the trace of M where M is a square matrix. / Trace = Sum of diagonal elements. / If the matrix is real, only the real value, re is set, im = 0. / If the matrix is complex, both re and im are set. /.
bool GetDeterminant (double &re, double &im)
 Computes the determinatnt of the square matrix M. / If the matrix is real, only the real value, re is set, im = 0. / If the matrix is complex, both re and im are set.
bool GetDiagonal (Matrix &DiagonalVector)
 Sets the diagonal elements of the matrix into DiagonalVector as a column vector. /.
bool GetColumnMovAvg (const unsigned col, const unsigned lead, const unsigned lag, Matrix &MovAvg)
 Computes a moving average using N lead samples and M lagging samples / for the specified column and stores it in MovAvg. /.
bool GetMovAvg (const unsigned lead, const unsigned lag, Matrix &MovAvg)
 Computes a moving average using N lead samples and M lagging samples / for the matrix and stores it in MovAvg. /.
bool GetATAInverse (Matrix &InvATA)
 Computes: InvATA = inverse( transpose(A) * A ). Assumes this matrix is A. / e.g. Matrix A; Matrix InvATA; A = ...; bool result = A.GetATAInverse( InvATA ); /.
bool GetLUFactorization (bool &isFullRank, Matrix &P, Matrix &L, Matrix &U)
 LU factorization. / Performs a factorization to produce a unit lower triangular matrix, L, / an upper triangular matrix, U, and permutation matrix P so that / P*X = L*U. / P, L and U are copmuted correctly if IsFullRank is set to true. / e.g. Matrix A; A = ...; bool isFullRank, Matrix L,U,P; bool result = A.GetLUFactorization( isFullRank, P, L, U ); /.
bool GetIndexedValues (Matrix &RowIndex, Matrix &ColIndex, Matrix &Result)
 Retrieve the elements of the matrix specified by the index vectors. / The index vectors must be nx1 and preferably not complex. / /.
bool SetIndexedValues (Matrix &RowIndex, Matrix &ColIndex, Matrix &SourceData)
 Set the elements of the matrix specified by the index vectors. / The index vectors must be nx1 and preferably not complex. / /.
std::string GetMatrixComment ()
 Retrieve the matrix comment string. The string will be empty if none is available. The matrix comment string is often the header line read when using ReadFromFile().
e.g. file.txt has: time(s) x(m) y(m) 1.0 20.0 30.0.
bool TimeWindow (const unsigned timeColumn, const double startTime, const double duration, const double rolloverTime)
 Alter the matrix so that its data is within the startTime to the startTime+duration and compensate for any rollovers in the time system (e.g. GPS time in seconds rolls over at 604800.0 s). This function assumes that time is one of the matrix columns and requires this index, the timeColumn.
bool TimeLimit (const unsigned timeColumn, const double startTime, const double endTime)
 Alter the matrix so that its data is within [startTime endTime]. This function assumes that time is one of the matrix columns and requires this index, the timeColumn.
Matrix Column (const unsigned col)
 Return the column matrix specified by the column index. Returns (nrows x 1).
Matrix Row (const unsigned row)
 Return the row matrix specified by the column index. Returns (ncols x 1).
Matrix Transpose ()
 Return the tranpose of the matrix.
Matrix T ()
 Return the tranpose of the matrix.
Matrix Diagonal ()
 Return the diagonal of the matrix as a vector.
Matrix Inverse ()
 Return the inverse of the matrix.
Matrix Inv ()
 Return the inverse of the matrix.
Matrix FFT ()
 Return the Fourier Transform of each column of the matrix. Power of two uses FFT, otherwise fast DFT.
Matrix IFFT ()
 Return the inverse Fourier Transform of each column of the matrix. Power of two uses IFFT, otherwise fast IDFT.
Elementoperator() (unsigned row, unsigned col)
 Get a reference to an element in the matrix to set or get its value.
Elementoperator() (unsigned index)
 Get a reference to an element in the matrix as a column or row vector to set or get its value. This can be used to access a matrix of (col,row), col = index/nrows, row = index/ncols. Matrix A(10); // The matrix is real with dimensions 10x1 A(0) = 10.0; // The matrix is real. stComplex cplx = {1.0,2.0}; A(1) = cplx; // The matrix is now complex with dimensions 10x1.
bool operator+= (const int scalar)
 add a scaler int (shorthand notation: A += 5).
bool operator+= (const float scalar)
 add a scaler float (shorthand notation: A += 5).
bool operator+= (const double scalar)
 add a scaler double (shorthand notation: A += 5).
bool operator+= (const std::complex< double > cplx)
 add a scaler complex (shorthand notation: A += (5+2i)).
bool operator-= (const int scalar)
 subtract a scaler int (shorthand notation: A -= 5).
bool operator-= (const float scalar)
 subtract a scaler float (shorthand notation: A -= 5).
bool operator-= (const double scalar)
 subtract a scaler double (shorthand notation: A -= 5).
bool operator-= (const std::complex< double > cplx)
 subtract a scaler complex (shorthand notation: A -= (5+2i)).
bool operator *= (const int scalar)
 multiply a scalar int (shorthand notation: A *= 5).
bool operator *= (const float scalar)
 multiply a scalar float (shorthand notation: A *= 5).
bool operator *= (const double scalar)
 multiply a scalar double (shorthand notation: A *= 5).
bool operator *= (const std::complex< double > cplx)
 multiply a scaler complex (shorthand notation: A *= (5+2i)).
bool operator/= (const int scalar)
 divide a scalar int (shorthand notation: A /= 5).
bool operator/= (const float scalar)
 divide a scalar float (shorthand notation: A /= 5).
bool operator/= (const double scalar)
 divide a scalar double (shorthand notation: A /= 5).
bool operator/= (const std::complex< double > cplx)
 divide a scaler complex (shorthand notation: A /= (5+2i)).
bool operator+= (const Matrix &mat)
 add a matrix (shorthand notation: A += B).
bool operator-= (const Matrix &mat)
 subtract a matrix (shorthand notation: A -= B).
RealOnlyAccess operator[] (const unsigned row)
 Retrieve a copy of a RealOnlyAccess object which is then used for the second [] overload.
void MatrixError (const char *error)
 Clear the matrix from memory and handle the error message.
void MatrixError (const char *function, const char *error)
 Clear the matrix from memory and handle the error message.

Static Public Member Functions

static void Treat1x1MatricesAsScalar (bool enable=true)
 This function enables or disables a global flag that forces single element matrices to be treated as scalars. This is enabled by default.
static bool TimeMatch (Matrix &A, const unsigned timeColumnA, Matrix &B, const unsigned timeColumnB, const unsigned precision, const double rolloverTime)
 This static function matches matrices in time with specified precision where time is a column of each matrix. This function also allows time to rollover at a specified interval.
static bool Interpolate (Matrix &A, const unsigned timeColumnA, Matrix &B, const unsigned timeColumnB, const double maxInterpolationInterval, const double rolloverTime)
 This static function interpolates Matrix B values by the times defined in the column in Matrix A. Time must be increasing but times can rollover with the specified rolloverTime.
static void StaticMatrixError (const char *error)
 A static function to handle the error message.
static void StaticMatrixError (const char *function, const char *error)
 A static function to handle the error message.

Protected Member Functions

bool IndexCheck (const unsigned row, const unsigned col)
 Check the specified indices. Throw an exception if they are invalid.
bool IndexCheck (const unsigned index)
 Check the specified index into the Matrix as a vector. Throw an exception if the index is invalid.

Protected Attributes

Element m_MatrixElement
 A single element from the matrix. This is used for write access with operator().
MTX m_Matrix
 The deep level matrix container.

Static Protected Attributes

static bool m_IsMTXInitialized = false
 This indicates if the mtx core engine been initialized.

Friends

Matrix operator++ (Matrix &mat, int)
 The postfix ++ operator overload. Add +1.0 to all elements and returns matrix values after the increment, e.g. Matrix B = A++. Use Inplace_Increment for a boolean return for safer operation.
Matrix operator-- (Matrix &mat, int)
 The postfix -- operator overload. Subtract 1.0 to all elements and returns matrix values after the increment, e.g. Matrix B = A--. Use Inplace_Decrement for a boolean return for safer operation.
Matrix operator * (const Matrix &mat1, const Matrix &mat2)
 Multiply two matrices and copy the result. Result = mat1 * mat2.
Matrix operator * (Matrix &mat1, Matrix &mat2)
 Multiply two matrices and copy the result. Result = mat1 * mat2.
Matrix operator+ (Matrix &mat1, Matrix &mat2)
 Add two matrices and copy the result. Result = mat1 + mat2.
Matrix operator+ (const Matrix &mat1, const Matrix &mat2)
 Add two matrices and copy the result. Result = mat1 + mat2.
Matrix operator- (Matrix &mat1, Matrix &mat2)
 Subtract two matrices and copy the result. Result = mat1 - mat2.
Matrix operator- (const Matrix &mat1, const Matrix &mat2)
 Subtract two matrices and copy the result. Result = mat1 - mat2.
Matrix operator^ (Matrix &mat, const int scalar)
 Raise all matrix elements to the power scalar.
Matrix