My Project
Classes | Public Member Functions | Public Attributes | List of all members
MatrixVector::mat Class Reference

Classes

class  Loader
 Inspired from Eigen Lib. More...
 

Public Member Functions

 mat (const mat &m)
 
 mat (const int col, const int row)
 
 mat (vector< vector< float >> v2)
 
 mat (const int col, const int row, vector< float > v)
 
Loader operator<< (float x)
 
vec getVec (int n)
 
row getRow (int n)
 Get an index row from a matrix.
 
vec operator* (vec &v)
 
mat operator* (mat &m)
 
mat operator= (const mat &m)
 
bool operator== (const mat &m)
 
mat operator+ (mat m)
 
mat operator- (const mat &m)
 
mat operator/ (float f)
 
mat operator* (float f)
 
mat removeRow (int index)
 
mat removeVec (int index)
 Get an index Column or Vector from a matrix.
 
mat insertVecNext (int index, vec v)
 Add vector to the right of index, Should I change the name to insertVecRight()
 
mat insertVecPrevious (int index, vec v)
 
mat clone ()
 
mat concat (mat m)
 
mat rowMultiScala (int index, float f)
 
mat vecMultiScala (int index, float f)
 
mat swapRow (int inx1, int inx2)
 Add test cases.
 
void geneMat (int init)
 Generate matrix from init to ncol*nrow. More...
 
void geneMatRandom (int fst, int snd)
 Generate a random matrix in interval and [fst, snd) More...
 
void print ()
 print the matrix More...
 
string toStr ()
 
void print2 ()
 
void zero ()
 
void identity ()
 
bool isId ()
 
bool isZero ()
 
float det ()
 
mat id ()
 
mat subMatrix (int colIndex, int rowIndex)
 /Library/WebServer/Documents/zsurface/pdf/submatrix_get.pdf 1 2 3 subMatrix(1, 0) => 4 5 6 4 5 6 More...
 
mat transpose ()
 tranpose matrix More...
 
mat block (int colIndex, int clen, int rowIndex, int rlen)
 subblock of a matrix More...
 
mat take (int len)
 Take first n columns from a matrix. More...
 
mat drop (int len)
 Drop first n columns from a matrix. More...
 
mat init ()
 Drop the last column from a matrix

\[ \begin{bmatrix} a & b & c \\ c & d & e \\ f & g & h \end{bmatrix} \rightarrow \begin{bmatrix} a & b \\ c & d \\ f & g \end{bmatrix} \]

.

 
mat tail ()
 Drop the first column from a matrix.

\[ \begin{bmatrix} a & b & c \\ c & d & e \\ f & g & h \end{bmatrix} \rightarrow \begin{bmatrix} b & c \\ d & e \\ h & h \end{bmatrix} \]

.

 

Public Attributes

int ncol
 
int nrow
 
float ** arr
 

Member Function Documentation

◆ block()

mat MatrixVector::mat::block ( int  cIndex,
int  clen,
int  rIndex,
int  rlen 
)

subblock of a matrix

  • [..) + [..]
  • Idea is from substring(index, n = inde + 1)
    "abc".substring(0, 2) => "ab"
    "abc".substring(2, 3) => "c"

◆ drop()

mat MatrixVector::mat::drop ( int  len)

Drop first n columns from a matrix.

- mat m(nrow, nrow)
- drop(nrow) => m(ncol, 0)

◆ geneMat()

void MatrixVector::mat::geneMat ( int  init)

Generate matrix from init to ncol*nrow.

init = 1, ncol = 2, nrow = 3
1 2 3
3 4 5

◆ geneMatRandom()

void MatrixVector::mat::geneMatRandom ( int  fst,
int  snd 
)

Generate a random matrix in interval and [fst, snd)

init = 1, ncol = 2, nrow = 3
1 2 3
3 4 5
geneMatRandom(1, 10) => [1, 10)

◆ getVec()

vec MatrixVector::mat::getVec ( int  n)

get 0 <= n <= nrow vector or column from matrix

◆ print()

void MatrixVector::mat::print ( )

print the matrix

int ncol = 2;
int nrow = 3;
mat m(ncol, nrow);
m.geneMat(1);
for(int i=0; i< ncol; i++){
for(int j=0; j< nrow; j++){
int indent = 10;
printf("[%*f]", 10, m.arr[i][j]);
}
printf("\n");
}
m.print();

◆ subMatrix()

mat MatrixVector::mat::subMatrix ( int  colIndex,
int  rowIndex 
)

/Library/WebServer/Documents/zsurface/pdf/submatrix_get.pdf 1 2 3 subMatrix(1, 0) => 4 5 6 4 5 6

subblock matrix, submatrix 1 2 3 3 4 5 block(1, 1)=> 4 5 6 7 8 7 8

◆ take()

mat MatrixVector::mat::take ( int  len)

Take first n columns from a matrix.

mat m(nrow, nrow)
take(0) => m(ncol, 0)

◆ transpose()

mat MatrixVector::mat::transpose ( )

tranpose matrix

1 2 3 => 1 4 4 5 6 2 5 3 6

--------------------------------------------------------------------------------
1 2 3 1 4
4 5 6 => 2 5
3 6
--------------------------------------------------------------------------------

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