Threshold replace for a matrix.
BOOL Replace( double dThresholdVal, double dReplaceVal = 0, uint wBitwiseOptions = 0, double dAbsError = 0.01 )
Returns TRUE on successful exit or FALSE on failure.
EX1
// Replace data in a matrix void matrixbase_Replace_ex1() { BOOL rc; matrix<double> mat1 = { {0, 0, 0, 0, 0}, {0, -2, 4, -2, 0}, {0, 5, 10, 5, 0}, {0, -2, 4, -2, 0}, {0, 0, 0, 0, 0} }; // Result matrix: ( |x|>0 ==> <sign>*1; Otherwise ==> NANUM) // {--, --, --, --, --} // {--, -1, 1, -1, --} // {--, 1, 1, 1, --} // {--, -1, 1, -1, --} // {--, --, --, --, --} MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix Mat1(MatLy1); Mat1 = mat1; printf(" The original matrix is %s.\n",Mat1.GetName()); matrix mat2(mat1); // Create mat2, and copy mat1 to mat2 rc = mat2.Replace( 0, 1, MATREPL_TEST_GREATER | MATREPL_USE_ABSOLUTE_VALUE_IN_TEST | MATREPL_KEEP_ORIGINAL_SIGN_WHEN_TEST_RESULT_IS_TRUE | MATREPL_SET_TO_MISSING_VALUE_WHEN_TEST_RESULT_IS_FALSE ); if(!rc) printf("Error: Replace failed.\n"); else { MatrixPage MatPg2; MatPg2.Create("Origin"); MatrixLayer MatLy2 = MatPg2.Layers(0); Matrix Mat2(MatLy2); Mat2 = mat2; printf(" The Replaced matrix is %s.\n",Mat2.GetName()); } }
origin.h