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 CMatrix
Set 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 double
Get the row number:
mat.getRowNum(); // return int
Get the column number:
mat.getColNum(); // return int
Get the F-norm:
mat.norm(); // return double
Get a transposed cpoy:
CMatrix transposedMat = mat.trans(); // return CMatrix
Unitize 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 commutative
Division:
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.