Zenautics::Matrix Class Reference

#include <Matrix.h>


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 operator^ (Matrix &mat, const float scalar)
 Raise all matrix elements to the power scalar.
Matrix operator^ (Matrix &mat, const double scalar)
 Raise all matrix elements to the power scalar.
Matrix operator+ (const double scalar, Matrix &mat)
 Add to a matrix by a scalar variable: ie. A = 2.0 + B and B + 2.0 (adds to 2.0 to all elements).
Matrix operator- (Matrix &mat, const double scalar)
 Subtract from a matrix by a scalar variable: ie. A = B - 2.0.
Matrix operator- (const double scalar, Matrix &mat)
 Subtract a matrix from a scalar variable: ie. A = 2.0 - B == -B + 2.0.
Matrix operator * (const double scalar, Matrix &mat)
 Multiply matrix by a scalar variable: A = 2.0 * B and A = B * 2.0.
Matrix operator/ (Matrix &mat, const double scalar)
 Divide matrix by a scalar variable: A = B / 2.0.
Matrix operator/ (const double scalar, Matrix &mat)
 Divide matrix into a scalar variable: A = 2.0 / B. e.g. A = [2.0 2.0; 2.0 2.0] / B, B is 2x2.

Data Structures

class  Element
 This is a nested class that is an element of the matrix. i.e. Matrix M; M(i,j) is the element. It is used for operator(,) access by the Matrix. More...
class  RealOnlyAccess
 A nested class for access only to the real part of the matrix. It is used for operator[] access by the Matrix. More...

Constructor & Destructor Documentation

Zenautics::Matrix::Matrix (  ) 

The default constructor (no data allocated yet).

Definition at line 148 of file Matrix.cpp.

Zenautics::Matrix::Matrix ( const unsigned  nrows  ) 

A vector style constructor.

Matrix A(nrows); creates an nrowsx1 real 'vector'. A complex vector must be created using Matrix A(nrows,ncols,false);

Definition at line 192 of file Matrix.cpp.

Zenautics::Matrix::Matrix ( const unsigned  nrows,
const unsigned  ncols,
const bool  isReal = true 
)

A matrix style constructor.

Matrix A(nrows,ncols); creates an nrowsxncols real 'matrix'. A real matrix is assumed. Matrix A(nrows,ncols,false); creates an nrowsxncols complex 'matrix'. A real matrix is assumed.

Definition at line 223 of file Matrix.cpp.

Zenautics::Matrix::Matrix ( const Matrix mat  ) 

The copy constructor.

Definition at line 286 of file Matrix.cpp.

Zenautics::Matrix::Matrix ( const char *  path,
bool &  itWorked 
)

A constructor reading data from a file.

Definition at line 261 of file Matrix.cpp.

Zenautics::Matrix::Matrix ( const double  mat[],
const unsigned  nrows,
const unsigned  ncols = 1 
)

The constructor as a copy from a static matrix.

Definition at line 297 of file Matrix.cpp.

Zenautics::Matrix::~Matrix (  )  [virtual]

The destructor.

Definition at line 169 of file Matrix.cpp.


Member Function Documentation

static void Zenautics::Matrix::Treat1x1MatricesAsScalar ( bool  enable = true  )  [static]

This function enables or disables a global flag that forces single element matrices to be treated as scalars. This is enabled by default.

Matrix & Zenautics::Matrix::operator= ( const Matrix mat  ) 

The assignment operator from another matrix.

e.g. Matrix B; Matrix A; B = "[1 2 3; 4 5 6]"; A = B; // A == [1 2 3; 4 5 6], A is (2x3)

Definition at line 313 of file Matrix.cpp.

Matrix & Zenautics::Matrix::operator= ( const double  value  ) 

The assignment operator from a scalar double value.

e.g. Matrix A; A = 2.0; // A is (1x1).

Definition at line 328 of file Matrix.cpp.

Matrix & Zenautics::Matrix::operator= ( const std::complex< double >  value  ) 

The assignment operator from a std::complex<double> value.

e.g. Matrix A; A = 2.0; // A is (1x1).

Definition at line 343 of file Matrix.cpp.

Matrix & Zenautics::Matrix::operator= ( const char *  strMatrix  ) 

The assignement operator from a string matrix.

There are two general possible interpretations of the string input.

(1) Square bracket delimited matrix. e.g.

    Matrix A;
    A = "[1 2 3; 4 5 6]"; // or 
    A = "[1, 2, 3; 4, 5, 6]";

In this case '[' donates the start of a matrix and ']' denotes the end.
Row vectors [1 2 3] and [4 5 6] are separated by ';'.
Commas can delimit row vector data but are not needed.
Complex input: e.g.

    Matrix A;
    A = "[1+1i 2+3j 1-2i; 4 5 6]"; // or
    A = "[1+1i, 2+3j, 1-2i; 4, 5, 6]";

(2) Free form delimited matrix. e.g.

    Matrix A; 
    A = "1 2 3 \\n 4 5 6 \\n";

In this case, the newline delimits different rows of the matrix. (\r\n also works).
Row vectors can still be delimited by ';' as well.

    B = "1 2 3; 4 5 6; \\n 7 8 9";

will set a 3x3 matrix == [1 2 3; 4 5 6; 7 8 9].

Commas can delimit row vector data but are not needed.
Complex input: e.g.

    Matrix A;
    A = "[1+1i 2+3j 1-2i\\n 4 5 6]";   // or
    A = "1+1i, 2+3j, 1-2i\\n 4, 5, 6"; // or
    A = "1+1i 2+3j 1-2i; 4, 5, 6";   

All result in A = [1+1i 2+3i 1-2i; 4 5 6];

Definition at line 358 of file Matrix.cpp.

bool Zenautics::Matrix::Clear (  ) 

Clear the matrix memory. Set the matrix to size 0x0.

    Matrix A(10,10); // A 10 x 10 matrix
    if( !A.Clear() )
      return false;
    // A is now 0x0 

Returns:
true if successul, false if error.

Definition at line 367 of file Matrix.cpp.

bool Zenautics::Matrix::isEmpty (  )  const

Is this matrix empty?

Definition at line 430 of file Matrix.cpp.

bool Zenautics::Matrix::isConformal ( const Matrix mat  )  const

Is the matrix mat conformal for multiplication (*this * mat)?

Definition at line 438 of file Matrix.cpp.

bool Zenautics::Matrix::isSameSize ( const Matrix mat  )  const

Is this matrix the same size as mat?

Definition at line 446 of file Matrix.cpp.

bool Zenautics::Matrix::isSquare (  )  const

Is this a square matrix?

Definition at line 454 of file Matrix.cpp.

bool Zenautics::Matrix::isStoredAsComplex (  ) 

Check if this matrix is stored as a complex matrix.

Definition at line 610 of file Matrix.cpp.

bool Zenautics::Matrix::isReal (  ) 

Check if this a real matrix.

Is this a real matrix for accessing by (row,col) operator? e.g. double d = A(0,4).

Definition at line 619 of file Matrix.cpp.

bool Zenautics::Matrix::isComplex (  ) 

Check if this a complex matrix.

Is this a complex matrix for accessing by [row][col] operators? e.g. stComplex d = A[0][4].

Definition at line 633 of file Matrix.cpp.

bool Zenautics::Matrix::isVector (  ) 

Check if this is a vector. Is the matrix either nx1 or 1xn.

Definition at line 638 of file Matrix.cpp.

unsigned Zenautics::Matrix::GetNrCols (  )  const

return no. of cols

Definition at line 462 of file Matrix.cpp.

unsigned Zenautics::Matrix::ncols (  )  const

return no. of cols

Definition at line 467 of file Matrix.cpp.

unsigned Zenautics::Matrix::GetNrElems (  )  const

return total no. of elements

Definition at line 472 of file Matrix.cpp.

unsigned Zenautics::Matrix::nelems (  )  const

return total no. of elements

Definition at line 477 of file Matrix.cpp.

unsigned Zenautics::Matrix::GetNrRows (  )  const

return no. of rows

Definition at line 482 of file Matrix.cpp.

unsigned Zenautics::Matrix::nrows (  )  const

return no. of rows

Definition at line 487 of file Matrix.cpp.

unsigned Zenautics::Matrix::GetLength (  )  const

return the maximum dimension either nrows or ncols whichever is greater.

Definition at line 492 of file Matrix.cpp.

double Zenautics::Matrix::real ( const unsigned  row,
const unsigned  col 
)

Return the real part of the matrix at this row and column.

    Matrix A = "2+4i";
    double a = A.real(0,0); // a is 2.0

Definition at line 500 of file Matrix.cpp.

double Zenautics::Matrix::real ( const unsigned  index  ) 

Return the real part of the matrix at this vector index.

    Matrix A = "[2+4i, 10-1i]";
    double a = A.real(1); // a is 10.0

Definition at line 519 of file Matrix.cpp.

double Zenautics::Matrix::imag ( const unsigned  row,
const unsigned  col 
)

Return the imaginary part of the matrix at this row and column.

    Matrix B = "2+4i";
    double b = B.imag(0); // b is 4.0

Definition at line 555 of file Matrix.cpp.

double Zenautics::Matrix::imag ( const unsigned  index  ) 

Return the imaginary part of the matrix at this vector index.

    Matrix B = "[2+4i, 1-10i]";
    double b = B.imag(1); // b is -10.0

Definition at line 574 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    Matrix B;
    Matrix C;
    bool result;

    result = A.ReadFromFile("data.txt"); // Read an ASCII numeric data file.
    result = B.ReadFromFile("data.csv"); // Read a comma delimited numeric data file. e.g. saved from EXCEL.
    result = C.ReadFromFile("data.mtx"); // Read a compressed binary matrix (MTX format).

Returns:
true if successful, false otherwise

Definition at line 649 of file Matrix.cpp.

bool Zenautics::Matrix::ReadFromFile ( std::string  path  ) 

Read the matrix from a file given the file path as a standard string.

    Matrix A;
    std::string str = "data.txt";
    if( !A.ReadFromFile(str) )
      return false;

Returns:
true if successful, false otherwise.

Definition at line 658 of file Matrix.cpp.

bool Zenautics::Matrix::Copy ( Matrix src  ) 

A safe function for performing a copy of another matrix.

    Matrix A(2,2);
    A[0][0] = 1.0;
    A[0][1] = 2.0;
    A[1][0] = 3.0;
    A[1][1] = 4.0;
    Matrix B;
    if( !B.Copy(A) )
      return false;

Returns:
true if successful, false otherwise

Definition at line 664 of file Matrix.cpp.

bool Zenautics::Matrix::Copy ( const double &  value  ) 

A safe function for setting the matrix from a double.

    double d = 10.0;
    Matrix A;
    if( !A.Copy(d) )
      return false;

Returns:
true if successful, false otherwise

Definition at line 672 of file Matrix.cpp.

bool Zenautics::Matrix::Copy ( const std::complex< double > &  cplx  ) 

A safe function for setting the matrix from a std::complex<double>.

    std::complex<double> cplx(1.0,2.0);
    Matrix A;
    if( !A.Copy(cplx) )
      return false;

Returns:
true if successful, false otherwise

Definition at line 683 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1,2,3; 4,5,6; 7,8,9]";
    if( !A.Save("data.mtx" ) )
      return false;

Returns:
true if successful, false otherwise

Definition at line 694 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    std::string str = "data.mtx";
    A = "[1,2,3; 4,5,6; 7,8,9]";
    if( !A.Save(str) )
      return false;

Returns:
true if successful, false otherwise

Definition at line 702 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    A = "[1,2,3; 4,5,6; 7,8,9]";
    if( !A.Print( "data.txt", 14 ) ) // Print the matrix to data.txt
      return false;

Returns:
true if successful, false otherwise

Definition at line 707 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    A = "[1,2,3; 4,5,6; 7,8,9]";
    std::string str = "data.txt";
    if( !A.Print( str, 14 ) ) // Print the matrix to data.txt
      return false;

Returns:
true if successful, false otherwise

Definition at line 715 of file Matrix.cpp.

bool Zenautics::Matrix::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'".

    Matrix A;
    A = "[1.123 0 2.123 -1; 3.123 0 4.123 -1]";  // Set A using string notation.
    bool result = A.PrintStdout(6); // Print to stdout with automatic width determination.
    // results in:
    // 0123456789012345678901234567890
    //  1.123  0  2.123 -1
    //  3.123  0  4.123 -1

Returns:
true if successful, false otherwise

Definition at line 720 of file Matrix.cpp.

bool Zenautics::Matrix::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'".

    Matrix A;
    A = "[1.123 0 2.123 -1; 3.123 0 4.123 -1]";  // Set A using string notation.
    char buffer[256]; 
    bool result = A.PrintToBuffer( buffer, 256, 6); // Print to a buffer with automatic width determination.
    cout << buffer << endl;
    // results in:
    // 0123456789012345678901234567890
    //  1.123  0  2.123 -1
    //  3.123  0  4.123 -1

Returns:
true if successful, false otherwise

Definition at line 728 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1.123 0 2.123 -1; 3.123 0 4.123 -1]";  // Set A using string notation.
    if( !A.PrintFixedWidth( "data.txt", 6, 3 ) )
      return false;
    // results in: data.txt with
    // 0123456789012345678901234567890
    //  1.123     0 2.123    -1
    //  3.123     0 4.123    -1

Returns:
true if successful, false otherwise

Definition at line 736 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1.123 0 2.123 -1; 3.123 0 4.123 -1]";  // Set A using string notation.
    std::string str = "data.txt";
    if( !A.PrintFixedWidth( str, 6, 3 ) )
      return false;
    // results in: data.txt with
    // 0123456789012345678901234567890
    //  1.123     0 2.123    -1
    //  3.123     0 4.123    -1

Returns:
true if successful, false otherwise

Definition at line 744 of file Matrix.cpp.

bool Zenautics::Matrix::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'".

    Matrix A;
    A = "[1.123 2.123 -1; 3.123 4.123 -1]";  // Set A using string notation.
    char buffer[256]; 
    bool result = A.PrintFixedWidthToBuffer( buffer, 256, 10, 6 ); // Print to a buffer with fixed width.
    cout << buffer << endl;
    // results in:
    // 0123456789012345678901234567890    
    //  1.123     2.123    -1
    //  3.123     4.123    -1

Returns:
true if successful, false otherwise

Definition at line 749 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1.123 2.123 -1; 3.123 4.123 -1]";  // Set A using string notation.
    if( !A.PrintDelimited( "data.csv", 5, ',' ) )
      return false;
    // results in: data.csv with
    // 0123456789012345678901234567890    
    // 1.123,2.123,-1
    // 3.123,4.123,-1

Returns:
true if successful, false otherwise

Definition at line 757 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1.123 2.123 -1; 3.123 4.123 -1]";  // Set A using string notation.
    std::string str = "data.csv";
    if( !A.PrintDelimited( str, 5, ',' ) )
      return false;
    // results in: data.csv with
    // 0123456789012345678901234567890    
    // 1.123,2.123,-1
    // 3.123,4.123,-1

Returns:
true if successful, false otherwise

Definition at line 765 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[1.123 2.123; 3.123 4.123]";  // Set A using string notation.
    char buffer[256]; 
    if( !A.PrintDelimitedToBuffer( buffer, 256, 6, ',' ) ) // Print to a buffer using comma delimiters.
      return false;
    cout << buffer << endl;
    // results in:
    // 1.123,2.123
    // 3.123,4.123

Returns:
true if successful, false otherwise

Definition at line 771 of file Matrix.cpp.

bool Zenautics::Matrix::PrintRowToString ( const unsigned  row,
char *  buffer,
const unsigned  maxlength,
const int  width,
const int  precision 
)

Print a row to a 'c' style string buffer.

    Matrix A;
    A = "[1.123 2.123; 3.123 4.123]";  // Set A using string notation.
    char buffer[256]; 
    if( !A.PrintRowToString( 1, buffer, 256, 4, 6 ) ) // Print the second row to the char buffer.
      return false;
    cout << buffer << endl;
    // results in:
    // 3.123   4.123

Returns:
true if successful, false otherwise

Definition at line 779 of file Matrix.cpp.

bool Zenautics::Matrix::RemoveColumn ( const unsigned  col  ) 

Remove a single column from the matrix.

    Matrix A;
    A = "[1.123 0 2.123; 3.123 0 4.123]";  // Set A using string notation.
    if( !A.RemoveColumn(1) ) // Remove the column with the zeros
      return false;
    // results in 
    // A
    // 1.123 2.123
    // 3.123 4.123

Returns:
true if successful, false otherwise.

Definition at line 788 of file Matrix.cpp.

bool Zenautics::Matrix::RemoveColumnsAfterIndex ( const unsigned  col  ) 

Remove all the columns 'after' the column index given.

    Matrix A;
    A = "[1.123 0 2.123; 3.123 0 4.123]";  // Set A using string notation.
    if( !A.RemoveColumnsAfterIndex(0) ) // Remove the 2nd and 3rd columns, i.e. after the 0th column.
      return false;
    // results in 
    // A
    // 1.123
    // 3.123

Returns:
true if successful, false otherwise.

Definition at line 796 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A(4,4);
    unsigned rows[2];
    unsigned cols[2];
    rows[0] = 0; // remove row 0
    rows[1] = 2; // remove row 2
    cols[0] = 0; // remove column 0
    cols[1] = 2; // romve column 2
    A.RemoveRowsAndColumns( 2, (unsigned int *)rows, 2, (unsigned int *)cols );
    // A is now a 2x2 matrix

Returns:
true if successful, false otherwise.

Definition at line 804 of file Matrix.cpp.

bool Zenautics::Matrix::InsertColumn ( const Matrix src,
const unsigned  dst_col,
const unsigned  src_col 
)

Insert a column matrix into the matrix.

    Matrix A;
    Matrix B(2,2);
    A = "[1.123 2.123; 3.123 4.123]";  // Set A using string notation.
    if( !A.InsertColumn( B, 1, 1 ) ) // Insert second column of B into the second column a A.
      return false;
    // results in:
    // A (2x3)
    // 1.123  0   2.123
    // 3.123  0   4.123

Returns:
true if successful, false otherwise.

Definition at line 812 of file Matrix.cpp.

bool Zenautics::Matrix::AddColumn ( const Matrix src,
const unsigned  src_col 
)

Add a column to the end of the matrix.

    Matrix A;
    atrix B(2,2);
    A = "[1.123 2.123; 3.123 4.123]";  // Set A using string notation.
    if( !A.AddColumn( B, 1 ) ) // Add second column of B to A.
      return false;
    // results in:
    // A (2x3)
    // 1.123  2.123 0
    // 3.123  4.123 0

Returns:
true if successful, false otherwise.

Definition at line 820 of file Matrix.cpp.

bool Zenautics::Matrix::Concatonate ( const Matrix src  ) 

Combine two matrices with the same nrows, A becomes A|B.

    Matrix A;
    atrix B(2,2);
    A = "[1.123 2.123; 3.123 4.123]";  // Set A using string notation.
    if( !A.Concatonate( B ) ) // make A = A | B
      return false;
    // results in:
    // A (2x4)
    // 1.123  2.123 0 0
    // 3.123  4.123 0 0

Returns:
true if successful, false otherwise.

Definition at line 828 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A(4,4);       // A is 4x4
    A[0][0] = 1;
    A[1][1] = -1;
    if( !A.Redim(2,2) )  // A is 2x2 but data values are retained.
      return false;
    // results in:
    // A (2x2)
    // 1  0
    // 0 -1

    Matrix B(10);     // B is a vector with length 10.
    B[0] = -1;
    B[1] = 1;
    if( !B.Redim(2) ) // B is a vector with length 2 but data values are retained
      return false;
    // results in:
    // B 
    // -1
    // 1

Returns:
true if successful, false otherwise.

Definition at line 836 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A(4,4);       // A is 4x4
    A[0][0] = 1;
    A[1][1] = -1;
    if( !A.Resize(2,2) )  // A is 2x2 and zero.
      return false;
    // results in:
    // A (2x2)
    // 0 0
    // 0 0

    Matrix B(10);     // B is a vector with length 10.
    B[0] = -1;
    B[1] = 1;
    if( !B.Resize(2) ) // B is a vector with length 2 and is zero.
      return false;
    // results in:
    // B 
    // 0
    // 0

Returns:
true if successful, false otherwise.

Definition at line 844 of file Matrix.cpp.

bool Zenautics::Matrix::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].

    Matrix A;
    double data[4] = {1.0,2.0,3.0,4.0};
    if( !A.SetFromStaticMatrix( data, 1, 4 ) )
      return false;
    \\ results in 
    \\ A
    \\ 1.0 2.0 3.0 4.0
    if( !A.SetFromStaticMatrix( data, 2, 2 ) )
      return false;    
    \\ results in 
    \\ A
    \\ 1.0 2.0 
    \\ 3.0 4.0    

Returns:
true if successful, false otherwise.

Definition at line 853 of file Matrix.cpp.

bool Zenautics::Matrix::SetFromMatrixString ( const char *  strMatrix  ) 

Setting the matrix values from a string matrix.

There are two general possible interpretations of the string input.

(1) Square bracket delimited matrix. e.g.

    Matrix A;
    A.SetFromMatrixString( "[1 2 3; 4 5 6]" ); // or 
    A.SetFromMatrixString( "[1, 2, 3; 4, 5, 6]" );

In this case '[' donates the start of a matrix and ']' denotes the end.
Row vectors [1 2 3] and [4 5 6] are separated by ';'.
Commas can delimit row vector data but are not needed.
Complex input: e.g.

    Matrix A;
    A.SetFromMatrixString( "[1+1i 2+3j 1-2i; 4 5 6]" ); // or
    A.SetFromMatrixString( "[1+1i, 2+3j, 1-2i; 4, 5, 6]" );

(2) Free form delimited matrix. e.g.

    Matrix A; 
    A.SetFromMatrixString( "1 2 3 \\n 4 5 6 \\n" );

In this case, the newline delimits different rows of the matrix. (\r\n also works).
Row vectors can still be delimited by ';' as well.

    A.SetFromMatrixString( "1 2 3; 4 5 6; \\n 7 8 9" );

will set a 3x3 matrix == [1 2 3; 4 5 6; 7 8 9].

Commas can delimit row vector data but are not needed.
Complex input: e.g.

    Matrix A;
    A.SetFromMatrixString( "[1+1i 2+3j 1-2i\\n 4 5 6]" );   // or
    A.SetFromMatrixString( "1+1i, 2+3j, 1-2i\\n 4, 5, 6" ); // or
    A.SetFromMatrixString( "1+1i 2+3j 1-2i; 4, 5, 6" );   

All result in A = [1+1i 2+3i 1-2i; 4 5 6];

Returns:
true if successful, false otherwise.

Definition at line 861 of file Matrix.cpp.

bool Zenautics::Matrix::CopyColumn ( const unsigned  src_col,
Matrix dst 
)

Copy the src data in column col to dst matrix, resize dst if possible and necessary.

    Matrix A;
    A = "[1 -1; 2 -2; 3 -3]".
    Matrix B;
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.CopyColumn(0,B); // Copy the first column of A into B.
    result = B.PrintStdout();   // Print Matrix B. B = [1;2;3];

Returns:
true if successful, false otherwise.

Definition at line 869 of file Matrix.cpp.

bool Zenautics::Matrix::InsertSubMatrix ( const Matrix src,
const unsigned  dst_row,
const unsigned  dst_col 
)

Insert a submatrix (src) into dst, starting at indices dst(row,col).

    Matrix A(4,4); // A 4x4 matrix of zeros.
    Matrix B(2,2); // A 2x2 matrix that we will fill with sevens.
    B.Fill(7.0);
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    result = A.InsertSubMatrix(B,1,1);  // Put B in the middle of A.
    result = A.PrintStdout();           // Print Matrix A. A = [0 0 0 0; 0 7 7 0; 0 7 7 0; 0 0 0 0].

Returns:
true if successful, false otherwise.

Definition at line 877 of file Matrix.cpp.

bool Zenautics::Matrix::Zero (  ) 

Zero the entire matrix.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.Zero();          // Set A back to zeros.
    result = A.PrintStdout();   // Print Matrix A. A = [0 0 0; 0 0 0; 0 0 0].

Returns:
true if successful, false otherwise.

Definition at line 885 of file Matrix.cpp.

bool Zenautics::Matrix::ZeroColumn ( const unsigned  col  ) 

Zero all elements in a specified column.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.ZeroColumn(1);   // Set the second column of A back to zeros.
    result = A.PrintStdout();   // Print Matrix A. A = [1 0 3; 4 0 6; 7 0 9].

Returns:
true if successful, false otherwise.

Definition at line 893 of file Matrix.cpp.

bool Zenautics::Matrix::ZeroRow ( const unsigned  row  ) 

Zero all elements in a specified row.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.ZeroRow(1);      // Set the second row of A back to zeros.
    result = A.PrintStdout();   // Print Matrix A. A = [1 2 3; 0 0 0; 7 8 9].

Returns:
true if successful, false otherwise.

Definition at line 901 of file Matrix.cpp.

bool Zenautics::Matrix::Fill ( const double  value  ) 

Fill the matrix with the given value.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.Fill(7);         // Fill the matrix with 7.0.
    result = A.PrintStdout();   // Print Matrix A. A = [7 7 7; 7 7 7; 7 7 7].

Returns:
true if successful, false otherwise.

Definition at line 909 of file Matrix.cpp.

bool Zenautics::Matrix::FillColumn ( const unsigned  col,
const double  value 
)

Fill the matrix column with the given value.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.FillColumn(1,7); // Fill the second column with 7.0.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 7 3; 4 7 6; 7 7 9].

Returns:
true if successful, false otherwise.

Definition at line 917 of file Matrix.cpp.

bool Zenautics::Matrix::FillRow ( const unsigned  row,
const double  value 
)

Fills the matrix row with the given value.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.FillRow(1,7);    // Fill the second row with 7.0.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 2 3; 7 7 7; 7 8 9].

Returns:
true if successful, false otherwise.

Definition at line 925 of file Matrix.cpp.

bool Zenautics::Matrix::FlipColumn ( const unsigned  col  ) 

Reverse the order of elements of a column.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.FlipColumn(1);   // Flip the second column.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 8 3; 4 5 6; 7 2 9].

Returns:
true if successful, false otherwise.

Definition at line 933 of file Matrix.cpp.

bool Zenautics::Matrix::FlipRow ( const unsigned  row  ) 

Reverse the order of elements of a row.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.FlipRow(1);      // Flip the second row.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 2 3; 6 5 4; 7 8 9].

Returns:
true if successful, false otherwise.

Definition at line 941 of file Matrix.cpp.

bool Zenautics::Matrix::Identity (  ) 

Set the matrix to identity using the current dimensions.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();   // Print Matrix A.
    result = A.Identity();      // Set A to identity.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 0 0; 0 1 0; 0 0 1].

Returns:
true if successful, false otherwise.

Definition at line 949 of file Matrix.cpp.

bool Zenautics::Matrix::Identity ( const unsigned  dimension  ) 

Set the matrix to identity using the specified dimension (nxn).

    Matrix A;
    bool result;
    result = A.Identity(3);     // Set A to identity, 3x3.
    cout << endl;
    result = A.PrintStdout();   // Print Matrix A. A = [1 0 0; 0 1 0; 0 0 1].

Returns:
true if successful, false otherwise.

Definition at line 957 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Transpose (  ) 

Transpose the matrix as an inplace operation.

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();         // Print Matrix A.
    result = A.Inplace_Transpose();   // Make A = transpose(A).
    cout << endl;
    result = A.PrintStdout();         // Print Matrix A. A = [1 4 7; 2 5 8; 3 6 9].

Returns:
true if successful, false otherwise.

Definition at line 972 of file Matrix.cpp.

bool Zenautics::Matrix::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
.

    Matrix A;
    A = "[1.09 2.08 3.07; 4.06 5.05 6.04; 7.03 8.02 9.01]";
    bool result;
    result = A.PrintStdout();     // Print Matrix A.
    result = A.Inplace_Round(1);  // Make A = round(A) to the 1st decimal place.
    cout << endl;
    result = A.PrintStdout();     // Print Matrix A. A = "[1.1 2.1 3.1; 4.1 5.1 6.0; 7.0 8.0 9.0]";

Returns:
true if successful, false otherwise.

Definition at line 980 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Floor (  ) 

Round the matrix elements to the nearest integers towards minus infinity.

    Matrix A;
    A = "[1.9 2.8 3.7; -4.6 -5.5 -6.4; 7.3 8.2 9.1]";
    bool result;
    result = A.PrintStdout();     // Print Matrix A.
    result = A.Inplace_Floor();   // Make A = floor(A).
    cout << endl;
    result = A.PrintStdout();     // Print Matrix A. A = "[1 2 3; -5 -6 -7; 7 8 9]";

Returns:
true if successful, false otherwise.

Definition at line 988 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Ceil (  ) 

Round the matrix elements to the nearest integers towards infinity.

    Matrix A;
    A = "[1.9 2.8 3.7; -4.6 -5.5 -6.4; 7.3 8.2 9.1]";
    bool result;
    result = A.PrintStdout();     // Print Matrix A.
    result = A.Inplace_Ceil();    // Make A = ceil(A).
    cout << endl;
    result = A.PrintStdout();     // Print Matrix A. A = "[2 3 4; -4 -5 -6; 8 9 10]";

Returns:
true if successful, false otherwise.

Definition at line 996 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Fix (  ) 

Rounds the matrix elements of X to the nearest integers towards zero.

    Matrix A;
    A = "[1.9 2.8 3.7; -4.6 -5.5 -6.4; 7.3 8.2 9.1]";
    bool result;
    result = A.PrintStdout();     // Print Matrix A.
    result = A.Inplace_Fix();     // Make A = fix(A).
    cout << endl;
    result = A.PrintStdout();     // Print Matrix A. A = "[1 2 3; -4 -5 -6; 7 8 9]";

Returns:
true if successful, false otherwise.

Definition at line 1004 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_AddScalar ( const double  scalar  ) 

Add a scaler double (ie: M += 5).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();        // Print Matrix A.
    result = A.Inplace_AddScalar(1); // A += 1.
    cout << endl;
    result = A.PrintStdout();        // Print Matrix A. A = "[2 3 4; 5 6 7; 8 9 10]";

Returns:
true if successful, false otherwise.

Definition at line 1012 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SubtractScalar ( const double  scalar  ) 

Subtract a scaler double (ie: M -= 5).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();             // Print Matrix A.
    result = A.Inplace_SubtractScalar(1); // A -= 1.
    cout << endl;
    result = A.PrintStdout();             // Print Matrix A. A = "[0 1 2; 3 4 5; 6 7 8]";

Returns:
true if successful, false otherwise.

Definition at line 1020 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_MultiplyScalar ( const double  scalar  ) 

Multiply by scaler double (ie: M *= 5).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();              // Print Matrix A.
    result = A.Inplace_MultiplyScalar(5);  // A *= 5.
    cout << endl;
    result = A.PrintStdout();              // Print Matrix A. A = "[5 10 15; 20 25 30; 35 40 45]";

Returns:
true if successful, false otherwise.

Definition at line 1028 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_DivideScalar ( const double  scalar  ) 

Divide by scaler double (ie: M /= 5).

    Matrix A;
    A = "[5 10 15; 20 25 30; 35 40 45]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    result = A.Inplace_DivideScalar(5); // A /= 5.
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[1 2 3; 4 5 6; 7 8 9]";

Returns:
true if successful, false otherwise.

Definition at line 1036 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_PowerScalar ( const double  scalar  ) 

Raise the matrix to a power scaler double (ie: M ^= 5).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    result = A.Inplace_PowerScalar(2);  // A = A.^2. Not A*A! Each element is raised.
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[1 4 9; 16 25 36; 49 64 81]";

Returns:
true if successful, false otherwise.

Definition at line 1044 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_AddScalarComplex ( const std::complex< double >  cplx  ) 

Add a scaler double (ie: M += (4+2i)).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    std::complex<double> cplx(4.0,2.0);
    result = A.Inplace_AddScalarComplex(cplx);  // A += (4+2i).
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[5+2i 6+2i 7+2i; 8+2i 9+2i 10+2i; 11+2i 12+2i 13+2i]";
    cout << "A(0,0) = " << A(0,0).real() << "+" << A(0,0).imag() << "i " << endl;

Returns:
true if successful, false otherwise.

Definition at line 1052 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SubtractScalarComplex ( const std::complex< double >  cplx  ) 

Subtract a scaler double (ie: M -= (5+2i)).

    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    std::complex<double> cplx(5.0,2.0);
    result = A.Inplace_SubtractScalarComplex(cplx);  // A -= (5+2i).
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[-4-2i -3-2i -2-2i; -1-2i 0-2i 1-2i; 2-2i 3-2i 4-2i]";
    cout << "A(0,0) = " << A(0,0).real() << "+" << A(0,0).imag() << "i " << endl;

Returns:
true if successful, false otherwise.

Definition at line 1060 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_MultiplyScalarComplex ( const std::complex< double >  cplx  ) 

Multiply by scaler double (ie: M *= (5+2i)).

    Matrix M;
    M = "[10 20]";
    std::complex<double> cplx(5,2);
    if( !M.Inplace_MultiplyScalarComplex(cplx) )
      return false;
    // M
    // 50+20i  100+40i

Returns:
true if successful, false otherwise.

Definition at line 1068 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_DivideScalarComplex ( const std::complex< double >  cplx  ) 

Divide by scaler double (ie: M /= (5+1i)).

    Matrix M;
    M = "[10+2i 20+4i]";
    std::complex<double> cplx(5,1);
    if( !M.Inplace_DivideScalarComplex(cplx) )
      return false;
    // M
    // 2  4

Returns:
true if successful, false otherwise.

Definition at line 1076 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_PowerScalarComplex ( const std::complex< double >  cplx  ) 

Raise the matrix to a power scaler double (ie: M ^= (5+2i)).

    Matrix M;
    M = "[2 3]";
    std::complex<double> cplx(5,2);
    if( !M.Inplace_PowerScalarComplex(cplx) )
      return false;
    // M
    // 5.87062319178566+31.4568876931598i    -142.459949032798+196.860770397691i

Returns:
true if successful, false otherwise.

Definition at line 1084 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Abs (  ) 

Compute the absolute value of each element in the matrix.

    Matrix A;
    A = "[-1 -2; -3 -4]";
    if( !A.Inplace_Abs() )
      return false;
    // A
    // 1 2
    // 3 4

Returns:
true if successful, false otherwise.

Definition at line 1092 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Sqr (  ) 

Compute the value^2 of each element in the matrix.

    Matrix A;
    A = "[1 2; -3 -4]";
    if( !A.Inplace_Sqr() )
      return false;
    // A
    // 1 4
    // 9 16

Returns:
true if successful, false otherwise.

Definition at line 1201 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Sqrt (  ) 

Computes the sqrt(value) of each element in the matrix.

    Matrix A;
    A = "[1 4; 9 16]";
    if( !A.Inplace_Sqrt() )
      return false;
    // A
    // 1 2
    // 3 4

Returns:
true if successful, false otherwise.

Definition at line 1209 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Exp (  ) 

Computes the exp(value) of each element in the matrix.

    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Exp() )
      return false;
    // A ~
    //  2.71828  7.38905
    // 20.08553 54.59815

Returns:
true if successful, false otherwise.

Definition at line 1217 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Ln (  ) 

Computes the natural logarithm, ln(value) of each element in the matrix.

    Matrix A;
    A = "[2.71828  7.38905; 20.08553 54.59815]";    
    if( !A.Inplace_Ln() )
      return false;
    // A ~
    // 1 2
    // 3 4

Returns:
true if successful, false otherwise.

Definition at line 1225 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Increment (  ) 

Add +1.0 to all elements, e.g. M++.

    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Increment() )
      return false;
    // A 
    // 2 3
    // 4 5

Returns:
true if successful, false otherwise.

Definition at line 1233 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Decrement (  ) 

Subtract 1.0 from all elements, e.g. M--.

    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Decrement() )
      return false;
    // A 
    // 0 1
    // 2 3

Returns:
true if successful, false otherwise.

Definition at line 1241 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Add ( const Matrix B  ) 

Add matrix B to this matrix inplace. A += B, inplace.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 3 4]";
    if( !A.Inplace_Add(B) )
      return false;
    // A 
    // 2 4
    // 6 8

Returns:
true if successful, false otherwise.

Definition at line 1249 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Subtract ( const Matrix B  ) 

Subtract matrix B from this matrix inplace. A -= B, inplace.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 3 4]";
    if( !A.Inplace_Subtract(B) )
      return false;
    // A 
    // 0 0
    // 0 0

Returns:
true if successful, false otherwise.

Definition at line 1257 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_PreMultiply ( const Matrix B  ) 

Pre-Multiply this matrix by B. A = B*A, inplace.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_PreMultiply(B) )
      return false;
    // A 
    // 7 10
    // 5 8

Returns:
true if successful, false otherwise.

Definition at line 1265 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_PostMultiply ( const Matrix B  ) 

Post-Multiply this matrix by B. A = A*B, inplace.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_PostMultiply(B) )
      return false;
    // A 
    // 5 4
    // 11 10

Returns:
true if successful, false otherwise.

Definition at line 1273 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_DotMultiply ( const Matrix B  ) 

Dot multiply A .*= B, inplace. A and B must have the same dimensions.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_DotMultiply(B) )
      return false;
    // A 
    // 1 4
    // 6 4

Returns:
true if successful, false otherwise.

Definition at line 1281 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_DotDivide ( const Matrix B  ) 

Dot divide A ./= B, inplace. A and B must have the same dimensions.

    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_DotDivide(B) )
      return false;
    // A 
    // 1   1
    // 1.5 4

Returns:
true if successful, false otherwise.

Definition at line 1289 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SortAscending (  ) 

Sorts each column of the matrix in ascending order. If complex, sorts based on magnitude.

    Matrix A;
    A = "[1;3;2;4;6;5;7]";
    if( !A.Inplace_SortAscending() )
      return false;
    // A
    // [1;2;3;4;5;6;7]

Returns:
true if successful, false otherwise.

Definition at line 1297 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SortDescending (  ) 

Sorts each column of M in descending order. If complex, sorts based on magnitude.

    Matrix A;
    A = "[1;3;2;4;6;5;7]";
    if( !A.Inplace_SortDescending() )
      return false;
    // A
    // [7;6;5;4;3;2;1]

Returns:
true if successful, false otherwise.

Definition at line 1305 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SortColumnAscending ( const unsigned  col  ) 

Sorts a specific column in ascending order. If complex, sorts based on magnitude.

    Matrix A;
    A = "[0 1;0 3;0 2;0 4;0 6;0 5;0 7]";
    if( !A.Inplace_SortColumnAscending(1) )
      return false;
    // A
    // A = "[0 1;0 2;0 3;0 4;0 5;0 6;0 7]";

Returns:
true if successful, false otherwise.

Definition at line 1313 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SortColumnDescending ( const unsigned  col  ) 

Sorts a specific column in descending order. If complex, sorts based on magnitude.

    Matrix A;
    A = "[0 1;0 3;0 2;0 4;0 6;0 5;0 7]";
    if( !A.Inplace_SortColumnDescending(1) )
      return false;
    // A
    // A = "[0 7;0 6;0 5;0 4;0 3;0 2;0 1]";

Returns:
true if successful, false otherwise.

Definition at line 1321 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    Matrix I;
    A = "[0 1;0 3;0 2;0 4;0 6;0 5;0 7]";
    if( !A.Inplace_SortColumnIndexed(1, I) )
      return false;
    // A = "[0 1;0 2;0 3;0 4;0 5;0 6;0 7]";
    // I = "[0;2;1;3;5;4;6]"

Returns:
true if successful, false otherwise.

Definition at line 1329 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_SortByColumn ( const unsigned  col  ) 

Sorts the entire matrix by a specific column. If complex, sorts based on magnitude.

    Matrix A;
    Matrix I;
    A = "[0 1;2 3;1 2;3 4;5 6;4 5;6 7]";
    if( !A.Inplace_SortByColumn(0) )
      return false;
    // A = "[0 1;1 2;2 3;3 4;4 5;5 6;6 7]";

Returns:
true if successful, false otherwise.

Definition at line 1337 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_Invert (  ) 

Computes the inplace inverse of the matrix.

Uses fast closed form solutions for: 1x1, 2x2, 3x3

Otherwise, the matrix is first tested to determine if it is a symmetric positive-definite matrix. If so, Cholesky decomposition is used to facilitate the inversion of a lower triangular matrix. If the matrix is not symmetric and positive-definite robust inversion using gaussing elimination is attempted.

If the matrix is singular, the original matrix is unchanged.

    Matrix A;
    A = "[10 14; 14 20]";
    if( !A.Inplace_Invert() )
      return false;
    // A
    //     5  -3.5
    //  -3.5   2.5

Returns:
true if successful, false if empty, singular or not square.

Definition at line 1345 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_InvertRobust (  ) 

Perfroms an inplace inverse using Gaussian Elimination methods.

    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_InvertRobust() )
      return false;
    // A
    //   -2     1
    //  1.5  -0.5

Returns:
true if successful, false if empty, singular or not square.

Definition at line 1353 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_LowerTriangularInverse (  ) 

Compute the inplace inverse of a unit lower triangular matrix.

    Matrix A;
    // A
    //    1    0    0
    //   -2    2    0
    //    4   -3   -3    
    A = "[1 0 0; -2 2 0; 4 -3 -3]";
    if( !A.Inplace_LowerTriangularInverse() )
      return false;
    // A
    //    1    0    0
    //    1  1/2    0
    // -1/3  1/2  1/3

Returns:
true if successful, false if empty, singular or not square.

Definition at line 1361 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_FFT (  ) 

Compute the inplace Fourier Transform of each column of the matrix.

    Matrix A;
    A = "[0; 0; 0; 0; 1; 1; 1; 1;]"; 
    if( !A.Inplace_FFT() )
     return false;
    // A
    //  4                         
    // -1+2.41421356237309i
    //  0                         
    // -1+0.414213562373095i
    //  0                         
    // -1-0.414213562373095i
    //  0                         
    // -1-2.41421356237309i

endcode

Returns:
true if successful, false if unable to perform the FFT.

Definition at line 1369 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_IFFT (  ) 

Compute the inplace inverse Fourier Transform of each column of the matrix.

    Matrix A;
    A = "[4; -1+2.41421356237309i; 0; -1+0.414213562373095i; 0; -1-0.414213562373095i; 0; -1-2.41421356237309i;]"; 
    if( !A.Inplace_IFFT() )
     return false;
    // A
    // 0                         
    // 0
    // 0                         
    // 0
    // 1                         
    // 1
    // 1                         
    // 1

Returns:
true if successful, false if unable to perform the FFT.

Definition at line 1377 of file Matrix.cpp.

bool Zenautics::Matrix::Add ( const Matrix B,
const Matrix C 
)

Add A = B+C. The result, A, is stored in this matrix.

    Matrix A;
    Matrix B;
    Matrix C;
    B = "[1 2; 3 4]";
    C = "[-1 2; -3 4]";
    if( !A.Add( B, C ) )
      return false;
    // A
    // 0 4
    // 0 8

Returns:
true if successful, false otherwise.

Definition at line 1386 of file Matrix.cpp.

bool Zenautics::Matrix::Subtract ( const Matrix B,
const Matrix C 
)

Subtract A = B-C. The result, A, is stored in this matrix.

    Matrix A;
    Matrix B;
    Matrix C;
    B = "[1 2; 3 4]";
    C = "[-1 2; -3 4]";
    if( !A.Subtract( B, C ) )
      return false;
    // A
    // 2 0
    // 6 0

Returns:
true if successful, false otherwise.

Definition at line 1395 of file Matrix.cpp.

bool Zenautics::Matrix::Multiply ( const Matrix B,
const Matrix C 
)

Multiply A = B*C. The result, A, is stored in this matrix.

    Matrix A;
    Matrix B;
    Matrix C;
    B = "[1 2; 3 4]";
    C = "[-1 2; -3 4]";
    if( !A.Multiply( B, C ) )
      return false;
    // A
    //  -7  10
    // -15  22

Returns:
true if successful, false otherwise.

Definition at line 1403 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_abs (  ) 

Compute the absolute value of each element of the matrix inplace.

    Matrix A;
    A = "[-1 2 3]";
    if( !A.Inplace_abs() )
      return false;
    // A 
    // [1 2 3]

Returns:
true if successful, false otherwise.

Definition at line 1412 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[0 0.5 1]";
    if( !A.Inplace_acos() )
      return false;
    // A 
    // [pi/2 pi/3 0]

Returns:
true if successful, false otherwise.

Definition at line 1100 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[0 0.5 1]";
    if( !A.Inplace_acosd() )
      return false;
    // A 
    // [90 60 0]

Returns:
true if successful, false otherwise.

Definition at line 1108 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_acosh (  ) 

Compute the inverse hyperbolic cosine of each element of the matrix inplace. Results in radians.

    Matrix A;
    A = "[0  1.0471975511966 1.5707963267949]";
    if( !A.Inplace_acosh() )
      return false;
    // A 
    // [0 pi/3 pi/2]

Returns:
true if successful, false otherwise.

Definition at line 1123 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_angle (  ) 

Compute the phase angle in radians of the elements of the matrix.

    Matrix A;
    A = "[1+1i  1-1i 3+2i]";
    if( !A.Inplace_acosh() )
      return false;
    // A 
    // [pi/4 -pi/4 0.588002603547568]

Returns:
true if successful, false otherwise.

Definition at line 1131 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[0  0.5 1.0]";
    if( !A.Inplace_asin() )
      return false;
    // A 
    // [0 pi/6 pi/2]

Returns:
true if successful, false otherwise.

Definition at line 1139 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    A = "[0  0.5 1.0]";
    if( !A.Inplace_asind() )
      return false;
    // A 
    // [0 30 90]

Returns:
true if successful, false otherwise.

Definition at line 1147 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_asinh (  ) 

Compute the inverse hyperbolic sine of each element of the matrix inplace. Results in radians.

    Matrix A;
    A = "[0  0.521095305493747  1.1752011936438]";
    if( !A.Inplace_asinh() )
      return false;
    // A 
    // [0 0.5 1]

Returns:
true if successful, false otherwise.

Definition at line 1162 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_atan (  ) 

Compute the arc-tangent of each element of the matrix inplace. Results in radians bounded [-pi/2, pi/2].

    Matrix A;
    A = "[0  1.73205080756888  1.63312393531954e+016]";
    if( !A.Inplace_atan() )
      return false;
    // A 
    // [0 pi/3 pi/2]

Returns:
true if successful, false otherwise.

Definition at line 1170 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_atand (  ) 

Compute the arc-tangent of each element of the matrix inplace. Results in degrees bounded [-90, 90].

    Matrix A;
    A = "[0  1.73205080756888  1.63312393531954e+016]";
    if( !A.Inplace_atand() )
      return false;
    // A 
    // [0 60 90]

Returns:
true if successful, false otherwise.

Definition at line 1178 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_atanh (  ) 

Compute the inverse hyperbolic tangent of each element of the matrix inplace.

    Matrix A;
    A = "[0  0.46211715726001  0.761594155955765]";
    if( !A.Inplace_atanh() )
      return false;
    // A 
    // [0 0.5 1]

Returns:
true if successful, false otherwise.

Definition at line 1193 of file Matrix.cpp.

bool Zenautics::Matrix::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.
.

    Matrix A;
    if( !A.Inplace_colon( 2, 2, 9 ) )
      return false;
    // A
    // [2; 4; 6; 8]
    if( !A.Inplace_colon( 2, -2, -9 ) )
      return false;
    // A
    // [2; 0; -2; -4; -6; -9;]    
    if( !A.Inplace_colon( -10, 0.01, 10 ) )
      return false;
    // A
    // [-10 -9.99 -9.98 ... 10]    

Returns:
true if successful, false otherwise.

Definition at line 1420 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_cos (  ) 

Compute the cosine of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  1.0471975511966  1.5707963267949]"; // [0 pi/3 pi/2]
    if( !A.Inplace_cos() )
      return false;
    // A
    // 1 0.5 0

Returns:
true if successful, false otherwise.

Definition at line 1436 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_cosh (  ) 

Compute the hyperbolic cosine of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  0.5 1]";
    if( !A.Inplace_cosh() )
      return false;
    // A
    // 1  1.12762596520638  1.54308063481524

Returns:
true if successful, false otherwise.

Definition at line 1444 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_cot (  ) 

Compute the cotangent of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  1.0471975511966  1.5707963267949]"; // [0  pi/3 pi/2]
    if( !A.Inplace_cot() )
      return false;
    // A
    // Inf  0.577350269189626  0

Returns:
true if successful, false otherwise.

Definition at line 1452 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_coth (  ) 

Compute the hyperbolic cotangent of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  0.5  1]";
    if( !A.Inplace_coth() )
      return false;
    // A
    // Inf   2.16395341373865 1.31303528549933

Returns:
true if successful, false otherwise.

Definition at line 1460 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_conj (  ) 

Complex conjugate. z = x+yi. conj(z) = x-yi.

    Matrix A;
    A = "[2-2i -3+2i]";
    if( !A.Inplace_conj() )
      return false;
    // A
    // 2+2i  -3-2i

Returns:
true if successful, false otherwise.

Definition at line 1428 of file Matrix.cpp.

bool Zenautics::Matrix::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)).

    Matrix A;
    A = "[1 2]";
    if( !A.Inplace_exp() )
      return false;
    // A
    //  2.71828182845905  7.38905609893065

Returns:
true if successful, false otherwise.

Definition at line 1476 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_eye ( const unsigned  nrows,
const unsigned  ncols 
)

Create an indentity matrix with nrows and ncols.

    Matrix A;
    if( !A.eye(3,3) )
      return false;
    // A
    // 1 0 0 
    // 0 1 0 
    // 0 0 1

Returns:
true if successful, false otherwise.

Definition at line 1484 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_imag (  ) 

Imaginary part of the complex matrix. z = x+yi. real(z) = y.

    Matrix A;
    A = "[2-2i -3+2i]";
    if( !A.Inplace_imag() )
      return false;
    // A
    // -2  2

Returns:
true if successful, false otherwise.

Definition at line 1468 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_log2 (  ) 

Compute the log base 2 of the elements of the matrix. Complex results if elements are negative.

    Matrix A;
    A = "[2 32]";
    if( !A.Inplace_log2() )
      return false;
    // A
    // 1 5

Returns:
true if successful, false otherwise.

Definition at line 1492 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_log10 (  ) 

Compute the log base 10 of the elements of the matrix. Complex results if elements are negative.

    Matrix A;
    A = "[10 1000]";
    if( !A.Inplace_log10() )
      return false;
    // A
    // 1 3

Returns:
true if successful, false otherwise.

Definition at line 1507 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_ones ( const unsigned  nrows,
const unsigned  ncols 
)

Create a matrix of nrows by ncols filled with 1.0.

    Matrix A;
    if( !A.Inplace_ones(2,3) )
      return false;
    // A
    // 1 1 1
    // 1 1 1

Returns:
true if successful, false otherwise.

Definition at line 1523 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_real (  ) 

Real part of the complex matrix. z = x+yi. real(z) = x.

    Matrix A;
    A = "[2-2i -3+2i]";
    if( !A.Inplace_real() )
      return false;
    // A
    // 2  3

Returns:
true if successful, false otherwise.

Definition at line 1540 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_sin (  ) 

Compute the sine of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0         0.523598775598299           1.5707963267949]"; //[0 pi/6 pi/2]
    if( !A.Inplace_sin() )
      return false;
    // A
    // 0 0.5 1

Returns:
true if successful, false otherwise.

Definition at line 1548 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_sinc (  ) 

Compute the sinc of each element*pi of the matrix inplace. i.e. y = sin(pi*x)./(pi*x).

    Matrix A;
    A = "[0  0.523598775598299  1.5707963267949]"; //[0 pi/6 pi/2]
    if( !A.Inplace_sinc() )
      return false;
    // A
    // 1  0.606257160324575  -0.19765087483668

Returns:
true if successful, false otherwise.

Definition at line 1556 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_sinh (  ) 

Compute the hyperbolic sine of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0 0.5 1]";
    if( !A.Inplace_sinh() )
      return false;
    // A
    // 0  0.521095305493747  1.1752011936438

Returns:
true if successful, false otherwise.

Definition at line 1564 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_sqrt (  ) 

Compute the sqrt of each element of the matrix inplace.

    Matrix A;
    A = "[0 9 121]";
    if( !A.Inplace_sqrt() )
      return false;
    // A
    // 0  3  11

Returns:
true if successful, false otherwise.

Definition at line 1572 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_tan (  ) 

Compute the tangent of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  0.785398163397448  1.5707963267949]"; // [0 pi/4 pi/2]
    if( !A.Inplace_tan() )
      return false;
    // A
    // 0  1  1.63312393531954e+016

Returns:
true if successful, false otherwise.

Definition at line 1580 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_tanh (  ) 

Compute the hyperbolic tangent of each element of the matrix inplace. This function assumes radian values in the matrix.

    Matrix A;
    A = "[0  0.785398163397448  1.5707963267949]"; // [0 pi/4 pi/2]
    if( !A.Inplace_tanh() )
      return false;
    // A
    // 0  0.655794202632672  0.917152335667274

Returns:
true if successful, false otherwise.

Definition at line 1588 of file Matrix.cpp.

bool Zenautics::Matrix::Inplace_zeros ( const unsigned  nrows,
const unsigned  ncols 
)

Create a matrix of nrows by ncols filled with 0.0.

    Matrix A;
    if( !A.Inplace_zeros(2,3) )
      return false;
    // A
    // 0 0 0
    // 0 0 0

Returns:
true if successful, false otherwise.

Definition at line 1596 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxAbs ( unsigned &  row,
unsigned &  col,
double &  value 
)

Computes the value of the largest absolute element and its index.

    Matrix A;
    unsigned row;
    unsigned col;
    double value;
    A = "[1 2 3 4 5]";
    if( !A.GetStats_MaxAbs( row, col, value ) )
      return false;
    // row   == 0
    // col   == 4
    // value == 5

Returns:
true if successful, false otherwise.

Definition at line 1614 of file Matrix.cpp.

bool Zenautics::Matrix::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.

    Matrix A;
    unsigned row;
    unsigned col;
    double re;
    double im;
    A = "[1 2 3 4 5-22i]";
    if( !A.GetStats_Max( row, col, re, im ) )
      return false;
    // row   == 0
    // col   == 4
    // re    == 5
    // im    == -22

Returns:
true if successful, false otherwise.

Definition at line 1622 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxVal ( double &  re,
double &  im 
)

Computes the value (re+im*j) of the maximum element. When complex the maximum absolute value is determined.

    Matrix A;
    double re;
    double im;
    A = "[1 2 3 4 5-22i]";
    if( !A.GetStats_MaxVal( re, im ) )
      return false;
    // re    == 5
    // im    == -22

Returns:
true if successful, false otherwise.

Definition at line 1630 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxAbsCol ( const unsigned  col,
double &  value,
unsigned &  row 
)

Computes the value of the largest absolute column element and its row index.

    Matrix A;
    unsigned row;
    double value;
    A = "[1 2 3; 4 -5 6]";
    if( !A.GetStats_MaxAbsCol( 1, value, row ) )
      return false;
    // value == 5
    // row   == 1

Returns:
true if successful, false otherwise.

Definition at line 1638 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1646 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxColVal ( const unsigned  col,
double &  re,
double &  im 
)

Computes the value (re+im*j) of the maximum column element.

Returns:
true if successful, false otherwise.

Definition at line 1654 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxAbsRow ( const unsigned  row,
double &  value,
unsigned &  col 
)

Computes the value of the largest absolute row element and its column index.

Returns:
true if successful, false otherwise.

Definition at line 1662 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1670 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MaxRowVal ( const unsigned  row,
double &  re,
double &  im 
)

Computes the value (re+im*j) of the maximum row element.

Returns:
true if successful, false otherwise.

Definition at line 1678 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinAbs ( unsigned &  row,
unsigned &  col,
double &  value 
)

Computes the value of the smallest absolute element and its index.

Returns:
true if successful, false otherwise.

Definition at line 1686 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_Min ( unsigned &  row,
unsigned &  col,
double &  re,
double &  im 
)

Computes the value (re+im*j) of the minimum element and its index.

Returns:
true if successful, false otherwise.

Definition at line 1694 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinVal ( double &  re,
double &  im 
)

Computes the value (re+im*j) of the minimum element.

Returns:
true if successful, false otherwise.

Definition at line 1702 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinAbsCol ( const unsigned  col,
double &  value,
unsigned &  row 
)

Computes the value of the smallest absolute column element and its row index.

Returns:
true if successful, false otherwise.

Definition at line 1710 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1718 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinColVal ( const unsigned  col,
double &  re,
double &  im 
)

Computes the value (re+im*j) of the minimum column element.

Returns:
true if successful, false otherwise.

Definition at line 1727 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinAbsRow ( const unsigned  row,
double &  value,
unsigned &  col 
)

Computes the value of the smallest absolute row element and its column index.

Returns:
true if successful, false otherwise.

Definition at line 1735 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1743 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_MinRowVal ( const unsigned  row,
double &  re,
double &  im 
)

Computes the value (re+im*j) of the minimum row element.

Returns:
true if successful, false otherwise.

Definition at line 1751 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1759 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1767 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1775 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1783 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1791 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1799 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1807 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1815 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1823 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_ColumnStdev ( const unsigned  col,
double &  value 
)

Computes the sample standard deviation for the specified column.

Returns:
true if successful, false otherwise.

Definition at line 1831 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_RowStdev ( const unsigned  row,
double &  value 
)

Computes the sample standard deviation for the specified row.

Returns:
true if successful, false otherwise.

Definition at line 1839 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_Stdev ( double &  value  ) 

Computes the sample standard deviation for the matrix.

Returns:
true if successful, false otherwise.

Definition at line 1847 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_ColumnVar ( const unsigned  col,
double &  value 
)

Computes the sample variance for the specified column.

Returns:
true if successful, false otherwise.

Definition at line 1855 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_RowVar ( const unsigned  row,
double &  value 
)

Computes the sample variance for the specified row.

Returns:
true if successful, false otherwise.

Definition at line 1863 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_Var ( double &  value  ) 

Computes the sample variance for the matrix.

Returns:
true if successful, false otherwise.

Definition at line 1871 of file Matrix.cpp.

bool Zenautics::Matrix::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) ) ).

Returns:
true if successful, false otherwise.

Definition at line 1879 of file Matrix.cpp.

bool Zenautics::Matrix::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) ) ).

Returns:
true if successful, false otherwise.

Definition at line 1887 of file Matrix.cpp.

bool Zenautics::Matrix::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) ) ).

Returns:
true if successful, false otherwise.

Definition at line 1895 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_ColumnRMS ( const unsigned  col,
double &  value 
)

Computes the sample RMS value for the specified column.

Returns:
true if successful, false otherwise.

Definition at line 1903 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_RowRMS ( const unsigned  row,
double &  value 
)

Computes the sample RMS value for the specified row.

Returns:
true if successful, false otherwise.

Definition at line 1911 of file Matrix.cpp.

bool Zenautics::Matrix::GetStats_RMS ( double &  value  ) 

Computes the sample RMS value for the matrix.

Returns:
true if successful, false otherwise.

Definition at line 1919 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1927 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1935 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.

Definition at line 1943 of file Matrix.cpp.

bool Zenautics::Matrix::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).

Returns:
true if successful, false otherwise.

Definition at line 1951 of file Matrix.cpp.

bool Zenautics::Matrix::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).

Returns:
true if successful, false otherwise.

Definition at line 1959 of file Matrix.cpp.

bool Zenautics::Matrix::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).

Returns:
true if successful, false otherwise.

Definition at line 1967 of file Matrix.cpp.

bool Zenautics::Matrix::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. /.

/

Returns:
true if successful, false otherwise.

Definition at line 1975 of file Matrix.cpp.

bool Zenautics::Matrix::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.

/

Definition at line 1983 of file Matrix.cpp.

bool Zenautics::Matrix::GetDiagonal ( Matrix DiagonalVector  ) 

Sets the diagonal elements of the matrix into DiagonalVector as a column vector. /.

/

Returns:
true if successful, false otherwise.

Definition at line 1991 of file Matrix.cpp.

bool Zenautics::Matrix::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. /.

/

Returns:
true if successful, false otherwise.

Definition at line 1999 of file Matrix.cpp.

bool Zenautics::Matrix::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. /.

/

Returns:
true if successful, false otherwise.

Definition at line 2007 of file Matrix.cpp.

bool Zenautics::Matrix::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 ); /.

/

Returns:
true if successful, false otherwise.

Definition at line 2015 of file Matrix.cpp.

bool Zenautics::Matrix::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 ); /.

/

Returns:
true if successful, false otherwise.

Definition at line 2023 of file Matrix.cpp.

bool Zenautics::Matrix::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. / /.

/

Returns:
true if successful, false otherwise.

Definition at line 2046 of file Matrix.cpp.

bool Zenautics::Matrix::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. / /.

/

Returns:
true if successful, false otherwise.

Definition at line 2098 of file Matrix.cpp.

std::string Zenautics::Matrix::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.

/ get the indices that are not this value / get the indices less than this value / get the indices less than this value

    bool result;
    Matrix A;
    result = A.ReadFromFile("file.txt");
    // A == [1.0 20.0 30.0]
    std::string comment = A.GetMatrixComment();
    // comment == "time(s)   x(m)   y(m)"

Returns:
The matrix comment string.

Definition at line 2150 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.
Parameters:
timeColumn  The column containing time.
startTime  The specified start time (inclusive).
duration  The duration to include.
rolloverTime  The potential time at which system time rolls over.

Definition at line 2160 of file Matrix.cpp.

bool Zenautics::Matrix::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.

Returns:
true if successful, false otherwise.
Parameters:
timeColumn  The column containing time
startTime  The specified start time (inclusive)
endTime  The duration to include

Definition at line 2178 of file Matrix.cpp.

bool Zenautics::Matrix::TimeMatch ( Matrix A,
const unsigned  timeColumnA,
Matrix B,
const unsigned  timeColumnB,
const unsigned  precision,
const double  rolloverTime 
) [static]

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.

precision 0 = match to whole number
precision 1 = match to nearest 0.1
precision 2 = match to nearest 0.01
etc.

rolloverTime examples
GPS time of week (s): rolloverTime= 604800.0
hours : rolloverTime = 24.0
minutes : rolloverTime = 60.0

The time data must be non-decreasing but the time may rollover by the specified amount. e.g. rolloverTime = 60.0
0,1,2,3,4,...59,60,1,2,5,10,60,1,2,3...

This function may be called by: bool result = Matrix::TimeMatch( ... );

Returns:
true if successful, false otherwise.
Parameters:
A  The matrix with interpolation times
timeColumnA  The zero based column index for matrix A
B  The matrix to be interpolated
timeColumnB  The zero based column index for matrix B
precision  The rounding precision used for time matching, 0 = whole, 1 = 0.1, 2 = 0.01, etc
rolloverTime  The rollover time, e.g. 60 s for minute based timing, 0.0 means rollovers not allowed

Definition at line 2194 of file Matrix.cpp.

bool Zenautics::Matrix::Interpolate ( Matrix A,
const unsigned  timeColumnA,
Matrix B,
const unsigned  timeColumnB,
const double  maxInterpolationInterval,
const double  rolloverTime 
) [static]

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.

This function returns A and B with the same number of rows and time aligned time columns.

This function may be called by: bool result = Matrix::Interpolate( ... );

Returns:
true if successful, false otherwise.
Parameters:
A  The matrix with interpolation times
timeColumnA  The zero based column index for matrix A
B  The matrix to be interpolated
timeColumnB  The zero based column index for matrix B
maxInterpolationInterval  The largest interpolation interval allowed
rolloverTime  The rollover time, e.g. 60 s for minute based timing, 0.0 means rollovers not allowed

Definition at line 2229 of file Matrix.cpp.

Matrix Zenautics::Matrix::Column ( const unsigned  col  ) 

Return the column matrix specified by the column index. Returns (nrows x 1).

Definition at line 2267 of file Matrix.cpp.

Matrix Zenautics::Matrix::Row ( const unsigned  row  ) 

Return the row matrix specified by the column index. Returns (ncols x 1).

Definition at line 2278 of file Matrix.cpp.

Matrix Zenautics::Matrix::Transpose (  ) 

Return the tranpose of the matrix.

Definition at line 2289 of file Matrix.cpp.

Matrix Zenautics::Matrix::T (  ) 

Return the tranpose of the matrix.

Definition at line 2300 of file Matrix.cpp.

Matrix Zenautics::Matrix::Diagonal (  ) 

Return the diagonal of the matrix as a vector.

Definition at line 2306 of file Matrix.cpp.

Matrix Zenautics::Matrix::Inverse (  ) 

Return the inverse of the matrix.

Definition at line 2317 of file Matrix.cpp.

Matrix Zenautics::Matrix::Inv (  ) 

Return the inverse of the matrix.

Definition at line 2332 of file Matrix.cpp.

Matrix Zenautics::Matrix::FFT (  ) 

Return the Fourier Transform of each column of the matrix. Power of two uses FFT, otherwise fast DFT.

Definition at line 2338 of file Matrix.cpp.

Matrix Zenautics::Matrix::IFFT (  ) 

Return the inverse Fourier Transform of each column of the matrix. Power of two uses IFFT, otherwise fast IDFT.

Definition at line 2349 of file Matrix.cpp.

Matrix::Element & Zenautics::Matrix::operator() ( unsigned  row,
unsigned  col 
)

Get a reference to an element in the matrix to set or get its value.

Get a reference to an element in the matrix to set its value.

Definition at line 2362 of file Matrix.cpp.

Matrix::Element & Zenautics::Matrix::operator() ( 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.

Get a reference to an element in the matrix as a column or row vector to set its value.

Definition at line 2380 of file Matrix.cpp.

bool Zenautics::Matrix::operator+= ( const int  scalar  )  [inline]

add a scaler int (shorthand notation: A += 5).

Definition at line 3208 of file Matrix.h.

bool Zenautics::Matrix::operator+= ( const float  scalar  )  [inline]

add a scaler float (shorthand notation: A += 5).

Definition at line 3209 of file Matrix.h.

bool Zenautics::Matrix::operator+= ( const double  scalar  ) 

add a scaler double (shorthand notation: A += 5).

Definition at line 3023 of file Matrix.cpp.

bool Zenautics::Matrix::operator+= ( const std::complex< double >  cplx  ) 

add a scaler complex (shorthand notation: A += (5+2i)).

Definition at line 3028 of file Matrix.cpp.

bool Zenautics::Matrix::operator-= ( const int  scalar  )  [inline]

subtract a scaler int (shorthand notation: A -= 5).

Definition at line 3213 of file Matrix.h.

bool Zenautics::Matrix::operator-= ( const float  scalar  )  [inline]

subtract a scaler float (shorthand notation: A -= 5).

Definition at line 3214 of file Matrix.h.

bool Zenautics::Matrix::operator-= ( const double  scalar  ) 

subtract a scaler double (shorthand notation: A -= 5).

Definition at line 3033 of file Matrix.cpp.

bool Zenautics::Matrix::operator-= ( const std::complex< double >  cplx  ) 

subtract a scaler complex (shorthand notation: A -= (5+2i)).

Definition at line 3038 of file Matrix.cpp.

bool Zenautics::Matrix::operator *= ( const int  scalar  )  [inline]

multiply a scalar int (shorthand notation: A *= 5).

Definition at line 3218 of file Matrix.h.

bool Zenautics::Matrix::operator *= ( const float  scalar  )  [inline]

multiply a scalar float (shorthand notation: A *= 5).

Definition at line 3219 of file Matrix.h.

bool Zenautics::Matrix::operator *= ( const double  scalar  ) 

multiply a scalar double (shorthand notation: A *= 5).

Definition at line 3043 of file Matrix.cpp.

bool Zenautics::Matrix::operator *= ( const std::complex< double >  cplx  ) 

multiply a scaler complex (shorthand notation: A *= (5+2i)).

Definition at line 3048 of file Matrix.cpp.

bool Zenautics::Matrix::operator/= ( const int  scalar  )  [inline]

divide a scalar int (shorthand notation: A /= 5).

Definition at line 3223 of file Matrix.h.

bool Zenautics::Matrix::operator/= ( const float  scalar  )  [inline]

divide a scalar float (shorthand notation: A /= 5).

Definition at line 3224 of file Matrix.h.

bool Zenautics::Matrix::operator/= ( const double  scalar  ) 

divide a scalar double (shorthand notation: A /= 5).

Definition at line 3053 of file Matrix.cpp.

bool Zenautics::Matrix::operator/= ( const std::complex< double >  cplx  ) 

divide a scaler complex (shorthand notation: A /= (5+2i)).

Definition at line 3058 of file Matrix.cpp.

bool Zenautics::Matrix::operator+= ( const Matrix mat  ) 

add a matrix (shorthand notation: A += B).

Definition at line 3063 of file Matrix.cpp.

bool Zenautics::Matrix::operator-= ( const Matrix mat  ) 

subtract a matrix (shorthand notation: A -= B).

Definition at line 3068 of file Matrix.cpp.

Matrix::RealOnlyAccess Zenautics::Matrix::operator[] ( const unsigned  row  ) 

Retrieve a copy of a RealOnlyAccess object which is then used for the second [] overload.

Definition at line 3427 of file Matrix.cpp.

void Zenautics::Matrix::MatrixError ( const char *  error  ) 

Clear the matrix from memory and handle the error message.

Definition at line 375 of file Matrix.cpp.

void Zenautics::Matrix::MatrixError ( const char *  function,
const char *  error 
)

Clear the matrix from memory and handle the error message.

Definition at line 381 of file Matrix.cpp.

void Zenautics::Matrix::StaticMatrixError ( const char *  error  )  [static]

A static function to handle the error message.

Definition at line 389 of file Matrix.cpp.

void Zenautics::Matrix::StaticMatrixError ( const char *  function,
const char *  error 
) [static]

A static function to handle the error message.

Definition at line 395 of file Matrix.cpp.

bool Zenautics::Matrix::IndexCheck ( const unsigned  row,
const unsigned  col 
) [protected]

Check the specified indices. Throw an exception if they are invalid.

Returns:
true if valid, false otherwise. return code should not be reached!

Definition at line 3321 of file Matrix.cpp.

bool Zenautics::Matrix::IndexCheck ( const unsigned  index  )  [protected]

Check the specified index into the Matrix as a vector. Throw an exception if the index is invalid.

Returns:
true if valid, false otherwise. return code should not be reached!

Definition at line 3337 of file Matrix.cpp.


Friends And Related Function Documentation

Matrix operator++ ( Matrix mat,
int   
) [friend]

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.

Definition at line 3074 of file Matrix.cpp.

Matrix operator-- ( Matrix mat,
int   
) [friend]

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.

Definition at line 3085 of file Matrix.cpp.

Matrix operator * ( const Matrix mat1,
const Matrix mat2 
) [friend]

Multiply two matrices and copy the result. Result = mat1 * mat2.

Definition at line 3109 of file Matrix.cpp.

Matrix operator * ( Matrix mat1,
Matrix mat2 
) [friend]

Multiply two matrices and copy the result. Result = mat1 * mat2.

Definition at line 3097 of file Matrix.cpp.

Matrix operator+ ( Matrix mat1,
Matrix mat2 
) [friend]

Add two matrices and copy the result. Result = mat1 + mat2.

Definition at line 3124 of file Matrix.cpp.

Matrix operator+ ( const Matrix mat1,
const Matrix mat2 
) [friend]

Add two matrices and copy the result. Result = mat1 + mat2.

Definition at line 3136 of file Matrix.cpp.

Matrix operator- ( Matrix mat1,
Matrix mat2 
) [friend]

Subtract two matrices and copy the result. Result = mat1 - mat2.

Definition at line 3151 of file Matrix.cpp.

Matrix operator- ( const Matrix mat1,
const Matrix mat2 
) [friend]

Subtract two matrices and copy the result. Result = mat1 - mat2.

Definition at line 3164 of file Matrix.cpp.

Matrix operator^ ( Matrix mat,
const int  scalar 
) [friend]

Raise all matrix elements to the power scalar.

Definition at line 3261 of file Matrix.h.

Matrix operator^ ( Matrix mat,
const float  scalar 
) [friend]

Raise all matrix elements to the power scalar.

Definition at line 3264 of file Matrix.h.

Matrix operator^ ( Matrix mat,
const double  scalar 
) [friend]

Raise all matrix elements to the power scalar.

Definition at line 3179 of file Matrix.cpp.

Matrix operator+ ( const double  scalar,
Matrix mat 
) [friend]

Add to a matrix by a scalar variable: ie. A = 2.0 + B and B + 2.0 (adds to 2.0 to all elements).

Definition at line 3192 of file Matrix.cpp.

Matrix operator- ( Matrix mat,
const double  scalar 
) [friend]

Subtract from a matrix by a scalar variable: ie. A = B - 2.0.

Definition at line 3278 of file Matrix.h.

Matrix operator- ( const double  scalar,
Matrix mat 
) [friend]

Subtract a matrix from a scalar variable: ie. A = 2.0 - B == -B + 2.0.

Definition at line 3211 of file Matrix.cpp.

Matrix operator * ( const double  scalar,
Matrix mat 
) [friend]

Multiply matrix by a scalar variable: A = 2.0 * B and A = B * 2.0.

Definition at line 3238 of file Matrix.cpp.

Matrix operator/ ( Matrix mat,
const double  scalar 
) [friend]

Divide matrix by a scalar variable: A = B / 2.0.

Definition at line 3257 of file Matrix.cpp.

Matrix operator/ ( const double  scalar,
Matrix mat 
) [friend]

Divide matrix into a scalar variable: A = 2.0 / B. e.g. A = [2.0 2.0; 2.0 2.0] / B, B is 2x2.

Definition at line 3276 of file Matrix.cpp.


Field Documentation

Element Zenautics::Matrix::m_MatrixElement [protected]

A single element from the matrix. This is used for write access with operator().

Definition at line 3411 of file Matrix.h.

MTX Zenautics::Matrix::m_Matrix [protected]

The deep level matrix container.

Definition at line 3414 of file Matrix.h.

bool Zenautics::Matrix::m_IsMTXInitialized = false [static, protected]

This indicates if the mtx core engine been initialized.

Definition at line 3417 of file Matrix.h.


The documentation for this class was generated from the following files: