When changing internal data type, original data is lost, so one has to backup and restore the data, as shown in the following Origin C program,
void setMatDouble()
{
MatrixLayer mat = Project.ActiveLayer();
if(mat == NULL)
{
out_str("no valid matrix a active window");
return;
}
if(mat.GetInternalData() == FSI_DOUBLE)
{
out_str("already double, no need to set again");
return;
}
Matrix<WORD> bb(mat); // assume you know the matrix data type
matrix temp; // both matrix and Matrix default is double
temp = bb; // store the Origin matrix into our temp double matrix
mat.SetInternalData(FSI_DOUBLE); // set matrix layer internal data type
Matrix aa(mat); // attach a double matrix object to the new matrix
aa = temp; // put original data back
}