A lightweight matrix lib in C++
Define a matrix instance with zeros:
CMatrix mat = CMatrix(rowNum, colNum); // demensions : rowNum*colNum
CMatrix mat = CMatrix(n); // demensions : n*n
CMatrix mat = anotherMat; // demensions : same as the right CMatrixSet the element at 2nd row and 3rd column to 1.5:
mat.set(2, 3, 1.5); Get the element at 2nd row and 3rd column:
mat.get(2, 3); // return doubleGet the row number:
mat.getRowNum(); // return intGet the column number:
mat.getColNum(); // return intGet the F-norm:
mat.norm(); // return doubleGet a transposed cpoy:
CMatrix transposedMat = mat.trans(); // return CMatrixUnitize diagnoal elements:
mat.diagUnitize(); Set all elements to zero:
mat.clear(); Addtion:
CMatrix mat = mat1 + mat2;Subtraction:
CMatrix mat = mat1 - mat2;Multiplication with CMatrix:
CMatrix mat = mat1 * mat2;Multiplication with single number:
CMatrix mat = mat1 * 1.5; // not commutativeDivision:
CMatrix mat = mat1 / 1.5;Exponentiation:
CMatrix mat = mat1 ^ 1.5;Some test methods have been declared in CTest.h and defined in CTest.cpp. These methods print test information on console.