matrixbase::Replace
  Replace 
  
  Description
  Threshold replace for a matrix. 
  Syntax
  
BOOL Replace( double dThresholdVal, double dReplaceVal = 0, uint wBitwiseOptions = 0, double dAbsError = 0.01 )
 
  Parameters
  
    - dThresholdVal
 
    - [input] Threshold value to compare to cells in matrix
 
    - dReplaceVal
 
    - [input] Replacement value to use when decision passes
 
    - wBitwiseOptions
 
    - [input] Combination of the following bits:
 
    - MATREPL_TEST_LESSTHAN, Use Less Than in condition TEST
 
    - MATREPL_TEST_EQUAL, Use Equal in condition TEST
 
    - MATREPL_TEST_GREATER, Use Greater Than in condition TEST
 
    - MATREPL_USE_ABSOLUTE_VALUE_IN_TEST Use Absolute values, in condition TEST
 
    - MATREPL_KEEP_ORIGINAL_SIGN_WHEN_TEST_RESULT_IS_TRUE, Keep original sign if condition TRUE ACTION
 
    - MATREPL_SET_TO_MISSING_VALUE_WHEN_TEST_RESULT_IS_FALSE Set to missing, value if condition FALSE ACTION
 
    - dAbsError
 
    - [input] Absolute error
 
   
  Return
  Returns TRUE on successful exit or FALSE on failure. 
  Examples
  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());
    }            
}
  Remark
  See Also
  header to Include
  origin.h 
             |