2.2.3.9.67 matrixbase::Shrink

Description

Shrink this matrix by averaging cell values together according to the column and row shrink factors. This is similar to the LabTalk mat.Shrink() method.

Syntax

BOOL Shrink( int nColShrinkFactor, int nRowShrinkFactor )

Parameters

nColShrinkFactor
[input] column shrink factor
nRowShrinkFactor
[input] row shrink factor

Return

Returns TRUE on successful exit or FALSE on failure.

Examples

EX1

// Shrink a matrix
void matrixbase_Shrink_ex1()
{
    BOOL rc;
    
    matrix<double> mat1 = {
        {0,  0,  0,  0},
        {0,  6,  0,  4},
        {0,  6,  0,  3}
    };

// Shrunk matrix by this sample program will be:
//      {1,  2}
//      {2,  3}

    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers(0);
    Matrix Mat1(MatLy1);
    Mat1 = mat1;
    printf("  Original matrix is %s, which size is %dx%d.\n",
      Mat1.GetName(),mat1.GetNumRows(),mat1.GetNumCols());
    
    MatrixPage MatPg2;
    MatPg2.Create("Origin");
    MatrixLayer MatLy2 = MatPg2.Layers(0);
    Matrix Mat2(MatLy2);
    Mat2 = mat1;
    
    rc=Mat2.Shrink(3,2); // Shrink a matrix
    printf("  Shrink Factors for Row=2, Col=3.\n");
    if(!rc) 
        printf("  Error: Shrink failed.\n");
    else
        printf("  Shrunk matrix is %s, which size is %dx%d.\n",
          Mat2.GetName(),Mat2.GetNumRows(),Mat2.GetNumCols());
}

Remark

See Also

Header to Include

origin.h