Matrix::Matrix

Description

Default constructor for Matrix class.


Constructor for Matrix class that attaches to an internal Origin matrix by name.


Constructor for Matrix class that attaches to an internal Origin matrix by a MatrixLayer object.

Syntax

Matrix( )

Matrix( LPCSTR lpcszMatrixName )

Matrix( MatrixLayer & mlMatLayer, int nMatObj = -1 )

Parameters

lpcszMatrixName
[input] name of matrix in Origin to attach to

mlMatLayer
[input] MatrixLayer object
nMatObj
[input] MatrixObject index, -1 to get the Active MatrixObject

Return

Examples

EX1

void Matrix_Matrix_ex1()
{
    // Assumes Matrix1 exists in Origin
    double dMean;
    Matrix matA;             // Declare OC Matrix object
    matA.Attach("MBook1");   // Attach OC object to internal Origin matrix
    dMean = matA.GetMean();  // Use matrixbase::GetMean function
    printf("Mean of Matrix1: %g\n", dMean ); // Print out mean
}


EX2

int Matrix_Matrix_ex2()
{
    // Assumes Matrix1 exists in Origin
    double dMean;
    Matrix matA("MBook1");   // Declare OC Matrix object and attach it to Matrix1
    dMean = matA.GetMean();  // Use matrixbase::GetMean function
    printf("Mean of Matrix1: %g\n", dMean ); // Print out mean
    return 0;
}


EX3

int Matrix_Matrix_ex3()
{
    // Assumes Matrix1 is active window in Origin
    double dMean;
    MatrixLayer ml;                           // Declare OC MatrixLayer object
    ml = (MatrixLayer) Project.ActiveLayer(); // Get active MatrixLayer from OC Project object 
    Matrix matA(ml);                          // Declare OC Matrix object and attach it to Matrix1
    dMean = matA.GetMean();                   // Use matrixbase::GetMean function
    printf("Mean of Matrix1: %g\n", dMean );  // Print out mean
    return 0;
}

EX4

void Matrix_Matrix_ex4()
{
    matrix<complex> mComplex = { 1+2i, 3+4i };
    MatrixLayer MatLy1;
    MatLy1.Create();
    MatLy1.SetInternalData(FSI_COMPLEX);     // Set the internal data type (see OC_const.h) of the matrix layer to complex.
    Matrix<complex> Mat1(MatLy1);            // Set the internal data type of the matrix to complex
    Mat1 = mComplex;       // Assignment of a complex matrix
}

Remark

Constructor for Matrix class that attaches to an internal Origin matrix by a MatrixLayer object.

The default internal data type of a matrix is double, and to manipulate a matrix of other data type, it needs to be set to that type beforehand. (See the second example.)

See Also

Matrix::Attach,Matrix::Detach,Matrix::IsValid

header to Include

origin.h