Skip to content

lbbc1117/Nacho

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nacho

A lightweight matrix lib in C++

Get start

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;

Test

Some test methods have been declared in CTest.h and defined in CTest.cpp. These methods print test information on console.

About

A lightweight matrix lib in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages