matrixbase::CastToDouble

Description

An explicit class memeber function to copy this matrix and casting the underlying base type to double for each element. You can also just use assignment to do the same thing.

Syntax

int CastToDouble( matrix & mDouble )


Parameters

mDouble
[output] The result matrix having an underlying base type of double

Return

Returns 0 on success and a non-zero error code on failure.

Examples

EX1

void matrixbase_CastToDouble_ex1()
{
// create two double matrix, as default Origin.otm is a double
MatrixPage MatPg1;
MatPg1.Create("Origin");
MatrixPage MatPg2;
MatPg2.Create("Origin");
MatrixLayer ml1 = MatPg1.Layers(0);
MatrixLayer ml2 = MatPg2.Layers(0);

MatrixObject Mat1, Mat2;
Mat1 = ml1.MatrixObjects(0);
Mat2 = ml2.MatrixObjects(0);

matrix& mat1 = Mat1.GetDataObject();
matrix& mat2 = Mat2.GetDataObject();

matrix<int> mm = {
{1,2,3},
{4,5,6},
{7,8,9}
};

// cast directly
mat1=mm;

// cast by this method, there is really no difference. This method was added to make it clear
mm.CastToDouble(mat2);
}


Remark

Copy this matrix and cast the underlying base type to double.