CMatrix::CMatrix

There are four ways to construct a two-dimensional matrix:

CMatrix(int nType=DATA_DOUBLE );
CMatrix(CMatrix *s);
CMatrix(int nRow, int nCol, double nValue=0);
CMatrix(CString strData,int nType=DATA_DOUBLE);

Parameters

nType

The data type of the matrix. You can create different types of data in a matrix. If a matrix is created by using "CMatrix(DATA_FLOAT)", both numbers of rows and columns are zero. This means that it is an empty matrix.

s

A existing matrix will be used to construct a new matrix with the same dimensions and value.

nRow

Number of rows in the matrix.

nCol

Number of columns  in the matrix.

nValue

The initial value will be set in the all elements in the matrix. Its default is 0.

strData

A matrix will be created by using the data string, such as "{1,2,3; 4,5,6}".

 

Remarks

Constructs a CMatrix object.

Example

// example for CMatrixr::CMatrix

    CMatrix a(); // an empty matrix will be constructed, and the number of rows and columns are zero.

    CMatrix b("1,2,3; 4,5 6"); // The first row is " 1   2  3" and the second row is "4  5  6".

    CMatrix c(&b) ;    // Matrix c is the same as Matrix b

CMatrix OverviewClass Members

Also see