Redistribution and use in source and binary forms, with or without modification, of the specified files is permitted provided the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Data Structures |
struct | _MTX_listItemCplx |
| struct specific for MTX_ReadFromFile and related functions (a simple linked list) More...
|
Defines |
#define | PI (3.1415926535897932384626433832795) |
| better value
|
#define | TWOPI (6.283185307179586476925286766559) |
| 2.0*PI
|
#define | HALFPI (1.5707963267948966192313216916398) |
| PI/2.0.
|
#define | MTX_ID_COMPRESSED_01 ("MTX01\n") |
| identifier used to indicate a file stored using SaveCompressed (version 1)
|
#define | MTX_ID_LEGACY_V01 ("Matrix\n") |
| legacy identifier used to indicate a file stored using Save with imprecise double RLE
|
#define | MTX_ID_LEGACY_V02 ("MTXV02\n") |
| legacy identifier used to indicate a file stored using Save with imprecise double RLE
|
#define | MTX_VERSION_NR_DEFAULT (101) |
| identifier used to indicate a file stored using basic Save
|
#define | MTX_VERSION_NR_COMPRESSED_01 (102) |
| identifier used to indicate a file stored using SaveCompressed (version 1)
|
#define | MTX_VERSION_NR_LEGACY_V01 (1) |
| legacy identifier used to indicate a file stored using Save with imprecise double RLE
|
#define | MTX_VERSION_NR_LEGACY_V02 (2) |
| legacy identifier used to indicate a file stored using Save with imprecise double RLE
|
#define | MTX_NK (8) |
| the number of byte columns used to represent a column of doubles when using MTX_ID_COMPRESSED_01
|
Functions |
BOOL | MTX_Initialize_MTXEngine () |
| This function must be called first by users of cmatrix!
|
BOOL | MTX_Enable1x1MatricesForTreatmentAsScalars (BOOL enable) |
| This function is used to set if matrices that are single elements (1x1) are treated as scalars for math operations or whether the regular matrix rules apply. THIS IS ENABLED BY DEFAULT.
|
BOOL | MTX_isNull (const MTX *M) |
| Is this a null matrix?
|
BOOL | MTX_isConformalForMultiplication (const MTX *A, const MTX *B) |
| Are matrices A & B conformal for multiplication, real * real.
|
BOOL | MTX_isConformalForAddition (const MTX *A, const MTX *B) |
| Are matrices A & B conformat for addition/subtraction, real + real.
|
BOOL | MTX_isSquare (const MTX *A) |
| Is this a square matrix?
|
BOOL | MTX_isSameSize (const MTX *A, const MTX *B) |
| are A and B the same size?
|
BOOL | MTX_Init (MTX *M) |
| Initialize a MTX matrix struct to appropriate zero values. This must always be called for proper operation!
|
BOOL | MTX_SetComment (MTX *M, const char *comment) |
| Set the matrix comment string.
|
BOOL | MTX_Free (MTX *M) |
| Clear the matrix data from memory if dynamically allocated. Zero the struct members.
|
BOOL | MTX_Malloc (MTX *M, const unsigned nrows, const unsigned ncols, const BOOL isReal) |
| Allocate matrix data (not set to zero).
|
BOOL | MTX_Calloc (MTX *M, const unsigned nrows, const unsigned ncols, const BOOL isReal) |
| Allocate matrix data (set to zero).
|
BOOL | MTX_SetValue (MTX *M, const unsigned row, const unsigned col, const double value) |
| Set a scalar value in the matrix.
|
BOOL | MTX_SetComplexValue (MTX *M, const unsigned row, const unsigned col, const double re, const double im) |
| Set a complex value in the matrix.
|
BOOL | MTX_Complex (MTX *M, const MTX *Re, const MTX *Im) |
| Matrix M = Re + Im*i, where Re and Im are real matrices.
|
BOOL | MTX_SetComplexColumn (MTX *M, const unsigned col, const MTX *Re, const MTX *Im) |
| Set the specified column in Matrix M to Re + Im*i, where Re and Im are real matrices. The dimensions of M must already be valid.
|
BOOL | MTX_ConvertRealToComplex (MTX *M) |
| Convert a real matrix to a complex matrix.
|
BOOL | MTX_ConvertComplexToReal (MTX *M) |
| Convert a complex marix to a real matrix using only the imaginary component A = real(B).
|
BOOL | MTX_ConvertComplexToImag (MTX *M) |
| Convert a complex marix to a real matrix using only the imaginary component A = imag(B).
|
BOOL | MTX_Real (const MTX *M, MTX *Re) |
| Extract the real component of matrix M.
|
BOOL | MTX_isReal (MTX *M, BOOL *isReal) |
| Check if the matrix contains only real values. Alter the matrix if it is stored as complex and only has real values.
|
BOOL | MTX_RealColumn (const MTX *M, const unsigned col, MTX *Re) |
| Extract the real component of column col of matrix M.
|
BOOL | MTX_Imag (const MTX *M, MTX *Im) |
| Extract the imaginary component of matrix M.
|
BOOL | MTX_ImagColumn (const MTX *M, const unsigned col, MTX *Im) |
| Extract the imaginary component of column col of matrix M.
|
BOOL | MTX_Magnitude (const MTX *M, MTX *Magnitude) |
| If M is a real matrix, Magnitude is a copy. If M is a complex matrix, Magnitude is a real matrix = sqrt( re*re + im*im ).
|
BOOL | MTX_Phase (const MTX *M, MTX *Phase) |
| If M is a real matrix, Phase is a zero matrix. If M is a complex matrix, Phase is a real matrix = atan2(im,re).
|
BOOL | MTX_Conjugate (MTX *M) |
| If M is a real matrix, nothing is done. If M is a complex matrix, the conjugate is set.
|
BOOL | MTX_RemoveColumn (MTX *M, const unsigned col) |
| Remove a single column from the matrix.
|
BOOL | MTX_RemoveColumnsAfterIndex (MTX *dst, const unsigned col) |
| remove all the columns 'after' the column index given.
|
BOOL | MTX_InsertColumn (MTX *dst, const MTX *src, const unsigned dst_col, const unsigned src_col) |
| insert a column into another matrix.
|
BOOL | MTX_AddColumn (MTX *dst, const MTX *src, const unsigned src_col) |
| Add a column to the Matrix.
|
BOOL | MTX_Concatonate (MTX *dst, const MTX *src) |
| Combine two matrices with the same nrows, A becomes A|B,.
|
BOOL | MTX_AddZeroValuedColumns (MTX *dst, const unsigned nr_new_cols) |
| A becomes A|0|0|0|.. etc.
|
BOOL | MTX_Redim (MTX *dst, const unsigned nrows, const unsigned ncols) |
| Redimension the matrix, original data is saved in place, new data is set to zero.
|
BOOL | MTX_Resize (MTX *dst, const unsigned nrows, const unsigned ncols, const BOOL isReal) |
| Resize the matrix, original data is lost, new data is set to zero, must specify if the matrix is real or complex.
|
BOOL | MTX_Copy (const MTX *src, MTX *dst) |
| Copy the src data to dst matrix, resize dst if possible & necessary.
|
BOOL | MTX_CopyIntoColumnWiseVector (const MTX *src, MTX *dst) |
| Copy the src matrix data [m cols x n rows] to dst vector [1 col x m*n rows], resize dst if possible & necessary.
|
BOOL | MTX_SetFromStaticMatrix (MTX *dst, const double mat[], const unsigned nrows, const unsigned ncols) |
| Set the dst matrix from the static 'c' style matrix indexed by mat[i*ncols + j].
|
BOOL | MTX_CopyColumn (const MTX *src, const unsigned col, MTX *dst) |
| Copy the src data in column col to dst matrix, resize dst if possible & necessary.
|
BOOL | MTX_CopyRow (const MTX *src, const unsigned row, MTX *dst) |
| Copy the src data in row, row, to dst matrix, resize dst if possible & necessary.
|
BOOL | MTX_CopyRowIntoAColumnMatrix (const MTX *src, const unsigned row, MTX *dst) |
| Copy the src data in row 'row' (1xn) to dst matrix (nx1), resize dst if possible & necessary. dst becomes (nx1).
|
BOOL | MTX_InsertSubMatrix (MTX *dst, const MTX *src, const unsigned dst_row, const unsigned dst_col) |
| Insert a submatrix (src) into dst, starting at indices dst(row,col).
|
BOOL | MTX_ExtractSubMatrix (const MTX *src, MTX *dst, const unsigned from_row, const unsigned from_col, const unsigned to_row, const unsigned to_col) |
| Extract a submatrix (dst) from this matrix from (inclusive) the rows and columns specified.
|
BOOL | MTX_Zero (MTX *dst) |
| Zero the entire matrix.
|
BOOL | MTX_ZeroColumn (MTX *dst, const unsigned col) |
| Zero all elements in a specified column.
|
BOOL | MTX_ZeroRow (MTX *dst, const unsigned row) |
| Zero all elements in a specified row.
|
BOOL | MTX_Fill (MTX *dst, const double value) |
| Fill the matrix with the given value.
|
BOOL | MTX_FillComplex (MTX *dst, const double re, const double im) |
| Fill the matrix with the given complex value.
|
BOOL | MTX_FillColumn (MTX *dst, const unsigned col, const double value) |
| Fill the matrix column with the given value.
|
BOOL | MTX_FillColumnComplex (MTX *dst, const unsigned col, const double re, const double im) |
| Fill the matrix column with the given complex value.
|
BOOL | MTX_FillRow (MTX *dst, const unsigned row, const double value) |
| Fill the matrix row with the given value.
|
BOOL | MTX_FillRowComplex (MTX *dst, const unsigned row, const double re, const double im) |
| Fill the matrix row with the given complex value.
|
BOOL | MTX_Identity (MTX *dst) |
| Set the matrix to an identity.
|
BOOL | MTX_ForceSymmetric (MTX *M) |
| Force this square matrix to be symmetric by M = (M + T.())/2 using minimal operations.
|
BOOL | MTX_Transpose (const MTX *src, MTX *dst) |
| Transpose the matrix src into the matris dst.
|
BOOL | MTX_TransposeInplace (MTX *M) |
| Transpose the matrix as an inplace operation.
|
BOOL | MTX_Round (MTX *M, const unsigned precision) |
| Round the matrix elements to the specified precision.
e.g. precision = 0 1.8 -> 2
e.g. precision = 1, 1.45 -> 1.5
e.g. precision = 2 1.456 -> 1.46
e.g. precision = 3, 1.4566 -> 1.457
precision has a maximum of 32. After which no rounding occurs.
|
BOOL | MTX_Floor (MTX *M) |
| Round the matrix elements to the nearest integers towards minus infinity.
|
BOOL | MTX_Ceil (MTX *M) |
| Round the matrix elements to the nearest integers towards infinity.
|
BOOL | MTX_Fix (MTX *M) |
| Round the matrix elements to the nearest integers towards zero. Sometimes known as trunc().
|
BOOL | MTX_OneMinus (const MTX *src, MTX *dst) |
| Set the destination matrix to be 1.0 minus the source matrix.
|
BOOL | MTX_DetermineFileDelimiter (const char *path, char *delimiter, BOOL *hasComment, char **comment) |
| Determine the matrix file delimiter and if a comment line is available.
|
BOOL | MTX_DetermineFileSize (const char *path, unsigned *size) |
| Determine the size of a file.
|
BOOL | MTX_DetermineNumberOfColumnsInDataString (const char *datastr, unsigned *ncols) |
| Determine the number of columns in the data string provided.
|
BOOL | MTX_DetermineNumberOfColumnsInDataStringCplx (const char *datastr, const char delimiter, unsigned *ncols) |
| Determine the number of columns in the complex data string provided. The delimiter is needed, 'w' indicates whitespace.
|
BOOL | MTX_ReadFromFileRealOnly (MTX *M, const char *path) |
| Read a real-only matrix from a file (ASCII formatted, any common delimiters). This function will also read in MTX BINARY formatted files.
|
BOOL | MTX_ReadFromFile (MTX *M, const char *path) |
| Read either a real or complex matrix from a file (ASCII formatted, any common delimiters). This function will also read in MTX BINARY formatted files.
|
BOOL | MTX_SetFromMatrixString (MTX *M, const char *strMatrix) |
| Set the matrix from a matrix string.
|
BOOL | MTX_ValueToString (const double value, const unsigned width, const unsigned precision, const BOOL isReal, const BOOL alignLeft, char *ValueBuffer, const unsigned ValueBufferSize) |
| Convert a value to a string with the specified width and precision. analogous to sprintf( ValueBuffer, "%'blank''-'width.precision'g'", value );.
|
BOOL | MTX_Print (const MTX *M, const char *path, const unsigned width, const unsigned precision, const BOOL append) |
| Print the matrix to a file with specifed width and precision. MTX_PrintAutoWidth is recommended over this function, "%'blank''-'width.precision'g'".
|
BOOL | MTX_Print_ToBuffer (const MTX *M, char *buffer, const unsigned maxlength, const unsigned width, const unsigned precision) |
| Print the matrix to a buffer of maxlength with specifed width and precision. MTX_PrintAutoWidth is recommended over this function, "%'blank''-'width.precision'g'".
|
BOOL | MTX_PrintAutoWidth (const MTX *M, const char *path, const unsigned precision, const BOOL append) |
| Print the matrix to a file with automatically determined column width. and the specified precision, uses "%'blank''-'autowidth.precision'g'".
|
BOOL | MTX_PrintStdoutAutoWidth (const MTX *M, const unsigned precision) |
| Print the matrix to stdout with automatically determined column width. and the specified precision, uses "%'blank''-'autowidth.precision'g'".
|
BOOL | MTX_PrintAutoWidth_ToBuffer (const MTX *M, char *buffer, const unsigned maxlength, const unsigned precision) |
| Print the matrix to a buffer of maxlenth with automatically determined column width. and the specified precision, uses "%'blank''-'autowidth.precision'g'".
|
BOOL | MTX_PrintDelimited (const MTX *M, const char *path, const unsigned precision, const char delimiter, const BOOL append) |
| Print the matrix to a file with specifed precision and delimiter. Use MTX_PrintAutoWidth if print using whitespace as a delimiter is required, uses "%.precision'g'".
|
BOOL | MTX_PrintDelimited_ToBuffer (const MTX *M, char *buffer, const unsigned maxlength, const unsigned precision, const char delimiter) |
| Print the matrix to a file with specifed precision and delimiter. Use MTX_PrintAutoWidth if print using whitespace as a delimiter is required, uses "%.precision'g'".
|
BOOL | MTX_PrintRowToString (const MTX *M, const unsigned row, char *buffer, const unsigned maxlength, const int width, const int precision) |
| Print a row to a string buffer.
|
BOOL | MTX_Add_Scalar (MTX *M, const double scalar) |
| Adds a scalar double to matrix M, ie: M += 5.
|
BOOL | MTX_Add_ScalarComplex (MTX *M, const double re, const double im) |
| Adds a scalar complex to matrix M, ie: M += (5 + 3i).
|
BOOL | MTX_Subtract_Scalar (MTX *M, const double scalar) |
| Subtracts a scalar double from matrix M, ie: M -= 5.
|
BOOL | MTX_Subtract_ScalarComplex (MTX *M, const double re, const double im) |
| Subtracts a scaler complex from matrix M, ie: M -= (5+3i).
|
BOOL | MTX_Multiply_Scalar (MTX *M, const double scalar) |
| Multiply M with a double scalar inplace, ie: M *= 5.
|
BOOL | MTX_Multiply_ScalarComplex (MTX *M, const double re, const double im) |
| Multiply M with a complex scalar inplace, ie: M *= (5+3i).
|
BOOL | MTX_Divide_Scalar (MTX *M, const double scalar) |
| Divide M by scaler double inplace, ie: M /= 5.
|
BOOL | MTX_Divide_ScalarComplex (MTX *M, const double re, const double im) |
| Divide M by scaler complex inplace, ie: M /= (5+3i).
|
BOOL | MTX_Negate (MTX *M) |
| Change the sign of all the data in the matrix. M *= -1.
|
BOOL | MTX_Abs (MTX *M) |
| Computes the absolute value of each element in the matrix.
|
BOOL | MTX_acos (MTX *M) |
| Compute the arc-cosine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1).
|
BOOL | MTX_angle (MTX *M) |
| Compute the phase angle in radians of the elements in the matrix. If all elements are real, the results are 0.
|
BOOL | MTX_asin (MTX *M) |
| Compute the arc-sine of each element of the matrix inplace. Complex results are obtained if elements are greater than abs(1).
|
BOOL | MTX_Sqr (MTX *M) |
| Computes the value^2 of each element in the matrix.
|
BOOL | MTX_Sqrt (MTX *M) |
| Computes the sqrt(value) of each element in the matrix. A real matrix is converted to complex if any elements are negative. e.g. sqrt(-1) = -i.
|
BOOL | MTX_Exp (MTX *M) |
| 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 | MTX_Eye (MTX *M, const unsigned nrows, const unsigned ncols) |
| Create an indentity matrix with nrows and ncols.
|
BOOL | MTX_Ln (MTX *M) |
| Computes the natural logarithm, ln(value) of each element in the matrix.
|
BOOL | MTX_Pow (const MTX *src, MTX *dst, const double power_re, const double power_im) |
| Raise all elements in src^(power_re + power_im*i) and store in dst. If power is just real, power_im = 0.0.
|
BOOL | MTX_PowInplace (MTX *src, const double power_re, const double power_im) |
| Raise all elements in src^(power_re + power_im*i). If power is just real, power_im = 0.0.
|
BOOL | MTX_atan (MTX *M) |
| Computes the arctan, atan(value) of each element in the matrix.
|
BOOL | MTX_Increment (MTX *M) |
| Add +1.0 to all elements, e.g. M++.
|
BOOL | MTX_Decrement (MTX *M) |
| Subtract 1.0 from all elements, e.g. M--.
|
BOOL | MTX_Add_Inplace (MTX *A, const MTX *B) |
| Add A += B, inplace.
|
BOOL | MTX_Subtract_Inplace (MTX *A, const MTX *B) |
| Subtract A -= B, inplace.
|
BOOL | MTX_PostMultiply_Inplace (MTX *A, const MTX *B) |
| Multiply A = A*B, inplace.
|
BOOL | MTX_PostMultiplyTranspose_Inplace (MTX *A, const MTX *B) |
| Multiply A = A*transpose(B), inplace.
|
BOOL | MTX_PreMultiply_Inplace (MTX *A, const MTX *B) |
| Multiply A = B*A, inplace.
|
BOOL | MTX_TransposePreMultiply_Inplace (MTX *A, const MTX *B) |
| Multiply A = tranpose(B)*A, inplace.
|
BOOL | MTX_DotMultiply_Inplace (MTX *A, const MTX *B) |
| Dot multiply A .*= B, inplace (A.data[col][row] = A.data[col][row]*B.data[col][row]).
|
BOOL | MTX_DotDivide_Inplace (MTX *A, const MTX *B) |
| Dot divide A ./= B, inplace (A.data[col][row] = A.data[col][row]/B.data[col][row]).
|
BOOL | MTX_Add (MTX *A, const MTX *B, const MTX *C) |
| Add A = B+C.
|
BOOL | MTX_Subtract (MTX *A, const MTX *B, const MTX *C) |
| Subtract A = B-C.
|
BOOL | MTX_Multiply (MTX *A, const MTX *B, const MTX *C) |
| Multiply A = B*C.
|
BOOL | MTX_TransposeMultiply (MTX *A, const MTX *B, const MTX *C) |
| Multiply A = transpose(B)*C.
|
BOOL | MTX_MultiplyTranspose (MTX *A, const MTX *B, const MTX *C) |
| Multiply A = B*transpose(C).
|
BOOL | MTX_IsEqual (const MTX *A, const MTX *B, const double tolerance, BOOL *isEqual) |
| Rest if A == B to within the specified tolerance.
|
BOOL | MTX_ColumnDiff (const MTX *M, MTX *Diff, const unsigned col) |
| Difference and approximte derivative for column col. The Diff is the column difference vector. diff = col[1:N-2] - col[0:N-1].
|
BOOL | MTX_Diff (const MTX *M, MTX *Diff) |
| Difference and approximate derivative. The Diff matrix is composed of the column difference vectors. for(i=0:M-1){ diff_i = col_i[1:N-2] - col_i[0:N-1] }.
|
BOOL | MTX_MaxColIndex (const MTX *M, const unsigned col, double *re, double *im, unsigned *row) |
| Computes the maximum element in the specified column and its index. 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. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxRowIndex (const MTX *M, const unsigned row, double *re, double *im, unsigned *col) |
| Computes the maximum element in the specified row and its index. 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. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MinColIndex (const MTX *M, const unsigned col, double *re, double *im, unsigned *row) |
| Computes the minimum element in the specified column and its index. 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. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_MinRowIndex (const MTX *M, const unsigned row, double *re, double *im, unsigned *col) |
| Computes the minimum element in the specified row and its index. 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. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxAbsColIndex (const MTX *M, const unsigned col, double *value, unsigned *row) |
| Computes the absolute maximum element in the specified column and its index. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxAbsRowIndex (const MTX *M, const unsigned row, double *value, unsigned *col) |
| Computes the absolue maximum element in the specified row and a its column index. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MinAbsColIndex (const MTX *M, const unsigned col, double *value, unsigned *row) |
| Computes the absolute minimum element in the specified column and its index. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_MinAbsRowIndex (const MTX *M, const unsigned row, double *value, unsigned *col) |
| Computes the absolute minimum element in the specified row and its index. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxColumn (const MTX *M, const unsigned col, double *re, double *im) |
| Computes the maximum element in 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 | MTX_MaxRow (const MTX *M, const unsigned row, double *re, double *im) |
| Computes the maximum element in 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 | MTX_MinColumn (const MTX *M, const unsigned col, double *re, double *im) |
| Computes the minimum element in 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 | MTX_MinRow (const MTX *M, const unsigned row, double *re, double *im) |
| Computes the minimum element in 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 | MTX_MaxAbsColumn (const MTX *M, const unsigned col, double *value) |
| Computes the absolute maximum element in the specified column.
|
BOOL | MTX_MaxAbsRow (const MTX *M, const unsigned row, double *value) |
| Computes the absolute maximum element in the specified row.
|
BOOL | MTX_MinAbsColumn (const MTX *M, const unsigned col, double *value) |
| Computes the absolute minimum element in the specified column.
|
BOOL | MTX_MinAbsRow (const MTX *M, const unsigned row, double *value) |
| Computes the absolute minimum element in the specified row.
|
BOOL | MTX_MaxAbsIndex (const MTX *M, double *value, unsigned *row, unsigned *col) |
| Computes the absolute maximum element for the entire matrix and its row and column index. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxIndex (const MTX *M, double *re, double *im, unsigned *row, unsigned *col) |
| Computes the maximum element for the entire matrix and its row and column index. If there are several equal maximum elements, the first index from the beginning is returned.
|
BOOL | MTX_MaxAbs (const MTX *M, double *value) |
| Computes the absolute maximum element for the entire matrix.
|
BOOL | MTX_Max (const MTX *M, double *re, double *im) |
| Computes the maximum element for the entire matrix.
|
BOOL | MTX_MinAbsIndex (const MTX *M, double *value, unsigned *row, unsigned *col) |
| Computes the absolute minimum element for the entire matrix and its row and column index. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_MinAbs (const MTX *M, double *value) |
| Computes the absolute minimum element for the entire matrix.
|
BOOL | MTX_MinIndex (const MTX *M, double *re, double *im, unsigned *row, unsigned *col) |
| Computes the minimum element for the entire matrix and its row and column index. If there are several equal minimum elements, the first index from the beginning is returned.
|
BOOL | MTX_Min (const MTX *M, double *re, double *im) |
| Computes the minimum element for the entire matrix.
|
BOOL | MTX_ColumnRange (const MTX *M, 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 | MTX_RowRange (const MTX *M, 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 | MTX_Range (const MTX *M, 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 | MTX_ColumnSum (const MTX *M, 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 | MTX_ColumnSumAbs (const MTX *M, const unsigned col, double *value) |
| Computes the sum of the absolute values for the specified column.
|
BOOL | MTX_RowSum (const MTX *M, 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 | MTX_Sum (const MTX *M, double *re, double *im) |
| Computes the sum of the data in 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 | MTX_ColumnMean (const MTX *M, 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 | MTX_RowMean (const MTX *M, 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 | MTX_Mean (const MTX *M, 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 | MTX_ColumnStdev (const MTX *M, const unsigned col, double *value) |
| Computes the sample standard deviation for the specified column.
|
BOOL | MTX_RowStdev (const MTX *M, const unsigned row, double *value) |
| Computes the sample standard deviation for the specified row.
|
BOOL | MTX_Stdev (const MTX *M, double *value) |
| Computes the sample standard deviation for the matrix.
|
BOOL | MTX_ColumnVar (const MTX *M, const unsigned col, double *value) |
| Computes the sample variance for the specified column.
|
BOOL | MTX_RowVar (const MTX *M, const unsigned row, double *value) |
| Computes the sample variance for the specified row.
|
BOOL | MTX_Var (const MTX *M, double *value) |
| Computes the sample variance for the matrix.
|
BOOL | MTX_ColumnNorm (const MTX *M, 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 | MTX_RowNorm (const MTX *M, 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 | MTX_Norm (const MTX *M, double *value) |
| Computes the norm of the matrix. If real, norm = sqrt( sum( val*val ) ). If complex, norm = sqrt( sum( val*conjugate(val) ) ).
|
BOOL | MTX_ColumnRMS (const MTX *M, const unsigned col, double *value) |
| Computes the sample RMS value for the specified column.
|
BOOL | MTX_RowRMS (const MTX *M, const unsigned row, double *value) |
| Computes the sample RMS value for the specified row.
|
BOOL | MTX_RMS (const MTX *M, double *value) |
| Computes the sample RMS value for the matrix.
|
BOOL | MTX_ColumnSkewness (const MTX *M, 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 | MTX_RowSkewness (const MTX *M, 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 | MTX_Skewness (const MTX *M, 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 | MTX_ColumnKurtosis (const MTX *M, 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 | MTX_RowKurtosis (const MTX *M, 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 | MTX_Kurtosis (const MTX *M, 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 | MTX_Trace (const MTX *M, 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 | MTX_Diagonal (const MTX *M, MTX *D) |
| Sets the diagonal elements of M into D as a column vector.
|
BOOL | MTX_FlipColumn (MTX *M, const unsigned col) |
| Reverse the order of elements of a column.
|
BOOL | MTX_FlipRow (MTX *M, const unsigned row) |
| Reverse the order of elements of a row.
|
BOOL | MTX_SortAscending (MTX *M) |
| Sorts each column of M in ascending order. If complex, sorts based on magnitude.
|
BOOL | MTX_SortDescending (MTX *M) |
| Sorts each column of M in descending order. If complex, sorts based on magnitude.
|
BOOL | MTX_SortColumnAscending (MTX *M, const unsigned col) |
| Sorts a specific column in ascending order. If complex, sorts based on magnitude.
|
BOOL | MTX_SortColumnDescending (MTX *M, const unsigned col) |
| Sorts a specific column in descending order. If complex, sorts based on magnitude.
|
BOOL | MTX_SortColumnIndexed (MTX *M, const unsigned col, MTX *index) |
| Sorts a specific column in ascending order and fills a MTX column vector with the sorted index. The index vector will be resized if index->nrows != M->nrows If complex, sorts based on magnitude.
|
BOOL | MTX_SortByColumn (MTX *M, const unsigned col) |
| Sorts the entire matrix by a specific column. If complex, sorts based on magnitude.
|
BOOL | MTX_SaveCompressed (const MTX *M, const char *path) |
| Saves a matrix to the specified file path using a proprietary compressed format. ADVANCED EDITION ONLY!
|
BOOL | MTX_GetCompressedFileAttributes (const char *path, unsigned *nrows, unsigned *ncols, BOOL *isReal) |
| Get attributes of the compressed file.
|
BOOL | MTX_ReadCompressed (MTX *M, const char *path) |
| Loads a binary compressed matrix that was saved using the MTX_SaveCompressed function.
|
BOOL | MTX_LoadAndSave (const char *infilepath, const char *outfilepath) |
| Read an ASCII matrix data file and save it using MTX_SaveCompressed. ADVANCED EDITION ONLY!
|
BOOL | MTX_LoadAndSaveQuick (const char *infilepath) |
| Read an ASCII matrix data file and save it using MTX_SaveCompressed. This version saves the data to the same base filename and uses the .mtx extension. ADVANCED EDITION ONLY!
|
BOOL | MTX_TimeWindow (MTX *M, const unsigned timeColumn, const double startTime, const double duration, const double rolloverTime) |
| Alter the matrix, M, 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 | MTX_TimeLimit (MTX *M, const unsigned timeColumn, const double startTime, const double endTime) |
| Alter the matrix, M, 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.
|
BOOL | MTX_TimeMatch (MTX *A, const unsigned timeColumnA, MTX *B, const unsigned timeColumnB, const unsigned precision, const double rolloverTime) |
| This 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.
|
BOOL | MTX_Interpolate (MTX *A, const unsigned timeColumnA, MTX *B, const unsigned timeColumnB, const double maxInterpolationInterval, const double rolloverTime) |
| This 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.
|
BOOL | MTX_InvertInPlaceClosedForm (MTX *M) |
| Compute the inplace inverse of the matrix. Uses fast closed form solutions for: Only for: 1x1, 2x2, 3x3.
|
BOOL | MTX_InvertClosedForm (const MTX *src, MTX *dst) |
| Compute the inplace inverse of the matrix. Uses fast closed form solutions for: Only for: 1x1, 2x2, 3x3.
|
BOOL | MTX_InvertInPlace (MTX *M) |
| Compute the inplace inverse of a matrix.
|
BOOL | MTX_Invert (const MTX *src, MTX *dst) |
| Compute the inverse of a matrix.
|
BOOL | MTX_InvertInPlaceRobust (MTX *M) |
| Perfroms an inplace matrix inverse using Gaussian Elimination methods.
|
BOOL | MTX_ColumnMovAvg (const MTX *src, const unsigned col, const unsigned nlead, const unsigned nlag, MTX *dst) |
| Computes a moving average using N lead samples and M lagging samples for the specified column and stores it in dst.
|
BOOL | MTX_MovAvg (const MTX *src, const unsigned nlead, const unsigned nlag, MTX *dst) |
| Computes a moving average using N lead samples and M lagging samples for the matrix and stores it in dst.
|
BOOL | MTX_ATAInverse (const MTX *A, MTX *InvATA) |
| Computes: InvATA = inverse( transpose(A) * A ).
|
BOOL | MTX_LowerTriangularInverseInplace (MTX *src) |
| Compute the inplace inverse of a unit lower triangular matrix. An example unit lower triangular matrix is:
A = [ 1 0 0;
-2 2 0;
4 -3 3 ]; with
inv(A) = [ 1 0 0;
1 1/2 0;
-1/3 1/2 1/3 ];
.
|
BOOL | MTX_Det (const MTX *M, 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 | MTX_LUFactorization (const MTX *src, BOOL *IsFullRank, MTX *P, MTX *L, MTX *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.
|
BOOL | MTX_IndexedValues (const MTX *src, const MTX *row_index, const MTX *col_index, MTX *dst) |
| Retrieve the elements of the matrix specified by the index vectors. The index vectors must be nx1 real vectors.
|
BOOL | MTX_SetIndexedValues (MTX *dst, const MTX *row_index, const MTX *col_index, const MTX *src) |
| Set the elements of the matrix specified by the index vectors. The index vectors must be nx1 real vectors.
|
BOOL | MTX_FFT2 (const MTX *src, MTX *dst) |
| Compute the Two-Dimensional Fast Fourier Transform of the src matrix and store it in the dst matrix.
|
BOOL | MTX_FFT2_Inplace (MTX *src) |
| Compute the inplace two dimensional Fast Fourier Transform of the matrix.
|
BOOL | MTX_IFFT2 (const MTX *src, MTX *dst) |
| Compute the Two-Dimensional Inverse Fast Fourier Transform of the src matrix and store it in the dst matrix.
|
BOOL | MTX_IFFT2_Inplace (MTX *src) |
| Compute the inplace two dimensional inverse Fast Fourier Transform of the matrix.
|
BOOL | MTX_FFT (const MTX *src, MTX *dst) |
| Compute the Fast Fourier Transform of each columns in the src matrix and store it in the dst matrix.
|
BOOL | MTX_IFFT (const MTX *src, MTX *dst) |
| Compute the inverse Fast Fourier Transform of each columns in the src matrix and store it in the dst matrix.
|
BOOL | MTX_FFT_Inplace (MTX *src) |
| Compute the inplace Fast Fourier Transform of each column of the matrix.
|
BOOL | MTX_IFFT_Inplace (MTX *src) |
| Compute the inplace inverse Fast Fourier Transform of each column of the matrix.
|
BOOL | MTX_sin (MTX *src) |
| Compute the sine of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_sinc (MTX *src) |
| Compute the sin(pi*x)/(pi*) of each element in the matrix.
|
BOOL | MTX_sinh (MTX *src) |
| Compute the hyperbolic sine of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_asinh (MTX *src) |
| Compute the inverse hyperbolic sine of each element in the matrix. Results in radians.
|
BOOL | MTX_cos (MTX *src) |
| Compute the cosine of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_cosh (MTX *src) |
| Compute the hyperbolic cosine of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_acosh (MTX *src) |
| Compute the inverse hyperbolic cosine of each element in the matrix. Results in radians.
|
BOOL | MTX_tan (MTX *src) |
| Compute the tangent of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_tanh (MTX *src) |
| Compute the hyperbolic tangent of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_atanh (MTX *src) |
| Compute the inverse hyperbolic tangent of each element in the matrix. Results in radians.
|
BOOL | MTX_cot (MTX *src) |
| Compute the cotangent of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_coth (MTX *src) |
| Compute the hyperbolic cotangent of each element in the matrix. Assumes elements are radians.
|
BOOL | MTX_Inv (MTX *src) |
| Compute the inverse, 1.0/x, inplace for each element of the matrix.
|
BOOL | MTX_Colon (MTX *dst, const double start, const double increment, const 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.
e.g. a = 2:2:9 = [2; 4; 6; 8;]
e.g. b = 2:-2:-9 = [2; 0; -2; -4; -6; -9;]
.
|
BOOL | MTX_RemoveRowsAndColumns (MTX *src, const unsigned nrows, const unsigned rows[], const unsigned ncols, const unsigned cols[]) |
| A very efficient method to remove rows and columns from the matrix.
|
BOOL | MTX_IsNAN (double value) |
| Test if a double value is NaN.
|
BOOL | MTX_IsPostiveINF (double value) |
| Test if a double value is +INF.
|
BOOL | MTX_IsNegativeINF (double value) |
| Test if a double value is -INF.
|
BOOL | MTX_randn (MTX *M, const unsigned nrows, const unsigned ncols, const unsigned seed) |
| Produce a matrix that is composed of pseudo-random numbers. Values are elements are standard normal distribution with mean zero, variance of one and standard of deviation one. N(0,1).
|
BOOL | MTX_rand (MTX *M, const unsigned nrows, const unsigned ncols, const unsigned seed) |
| Produce a matrix that is composed of pseudo-random numbers. Values are elements are uniform distribution [0,1].
|
BOOL | MTX_PlotQuick (MTX *M, const char *bmpfilename, const unsigned x_col, const unsigned y_col) |
| A quick plot, to a RLE compressed windows bitmap file, x_column vs y_column of the matrix M.
|
BOOL | MTX_Plot (const char *bmpfilename, const char *title, const unsigned plot_height_cm, const unsigned plot_width_cm, const BOOL includeStats, const BOOL isXGridOn, const BOOL isYGridOn, const char *xlabel, const char *ylabel, const MTX_structAxisOptions opt_x, const MTX_structAxisOptions opt_y, const MTX_PLOT_structSeries *series, const unsigned nrSeries) |
| Plot up to 12 series on one figure directly to an RLE compressed BITMAP file.
|
BOOL | MTX_AddIdentity (const MTX *src, MTX *dst) |
| Add this matrix and an identity matrix. Adds 1.0 to the diagonal even if not square.
|
BOOL | MTX_AddIdentity_Inplace (MTX *src) |
| Add this matrix and an identity matrix. Adds 1.0 to the diagonal even if not square.
|
BOOL | MTX_MinusIdentity (const MTX *src, MTX *dst) |
| Subtract an identity matrix from this matrix. Subtracts 1.0 from the diagonal even if not square.
|
BOOL | MTX_MinusIdentity_Inplace (MTX *src) |
| Subtract an identity matrix from this matrix. Subtracts 1.0 from the diagonal even if not square.
|
BOOL | MTX_IdentityMinus (const MTX *src, MTX *dst) |
| Subtract this matrix from an identity matrix. Subtracts the diagonal from 1.0 even if not square.
|
BOOL | MTX_IdentityMinus_Inplace (MTX *src) |
| Subtract this matrix from an identity matrix. Subtracts the diagonal from 1.0 even if not square.
|
BOOL | MTX_Hilbert (MTX *src, const unsigned N) |
| Sets the matrix as the NxN hilbert matrix. H_ij = 1.0 / (i+j-1.0) for i=1:N, j=1:N.
|
BOOL | MTX_Swap (MTX *A, MTX *B) |
| Swap the contents of matrix A with matrix B.
|
BOOL | MTX_LDLt (MTX *src, MTX *L, MTX *d, BOOL checkSymmetric) |
| Compute the LDLt decomposition of a square matrix. This method avoids using square roots and can be used for any square, full rank, symmetrical matrix.
|
BOOL | MTX_UDUt (MTX *src, MTX *U, MTX *d, BOOL checkSymmetric) |
| Compute the UDUt decomposition of a square matrix. This method avoids using square roots and can be used for any square, full rank, symmetrical matrix.
|
BOOL | MTX_erf_Inplace (MTX *src) |
| Compute the error function (erf) for all values in the matrix inplace.
erf(x) = 2/sqrt(pi) * [integral from 0 to x of]( e^(-t^2) )dt.
|
BOOL | MTX_erfinv_Inplace (MTX *src) |
| Compute the inverse error function (erfinv) for all values in the matrix inplace.
y = erf(x), compute x given y, i.e. x = erfinv(y).
|
BOOL | MTX_erfc_Inplace (MTX *src) |
| Compute the complementary error function (erfc) for all values in the matrix inplace. erfc(x) = 1 - erf(x) = 2/sqrt(pi) * [integral from x to inf of]( e^(-t^2) )dt.
|
BOOL | MTX_erfcinv_Inplace (MTX *src) |
| Compute the inverse complementary error function (erfcinv) for all values in the matrix inplace.
|
BOOL | MTX_find_column_values_equalto (const MTX *src, const unsigned col, MTX *indexVector, const double re, const double im, const double tolerance) |
| Set the index vector so that it contains are the indices of values that are equal to the value specified with the given tolerance from the column of the src matrix.
|
BOOL | MTX_find_column_values_not_equalto (const MTX *src, const unsigned col, MTX *indexVector, const double re, const double im, const double tolerance) |
| Set the index vector so that it contains are the indices of values that are not equal to the value specified with the given tolerance from the column of the src matrix.
|
BOOL | MTX_find_column_values_less_than (const MTX *src, const unsigned col, MTX *indexVector, const double value) |
| Set the index vector so that it contains are the indices of values that are less then to the value specified with the given tolerance from the column of the src matrix. Complex matrix values are compared to the value by magnitude (i.e. sqrt(re*re+im*im)).
|
BOOL | MTX_find_column_values_more_than (const MTX *src, const unsigned col, MTX *indexVector, const double value) |
| Set the index vector so that it contains are the indices of values that are more then to the value specified with the given tolerance from the column of the src matrix. Complex matrix values are compared to the value by magnitude (i.e. sqrt(re*re+im*im)).
|
Variables |
BOOL | MTX_static_global_treat_1x1_as_scalar = TRUE |
| This static global variable indicates whether matrix operations for single elements are treated as scalar operations. e.g. A = B*C, B is 1x1 C is 10x10. If this was disabled, this operation would return FALSE as an error. When enabled, A, is treated as a scalar and is multiplied into every element of C.
|