2.2.3.9.71 matrixbase::Wrap

Description

Wrap around elements.

Syntax

BOOL Wrap( int nRowNum = 0, int nColNum = 0 )

Parameters

nRowNum
[input] when the value is 0, no wrap, when value less than zero, do up_wrap, other wise do down_wrap.
nColNum
[input] when the value is 0, no wrap, when value less than zero, do left_wrap, other wise do right_wrap.

Return

Returns TRUE on successful or FALSE on failure.

Examples

EX1

void matrixbase_Wrap_ex1()
{
    BOOL rc;
 
    matrix mat1 = {
        {1, 1, 2, 2, 2}, 
        {1, 1, 3, 3, 3}, 
        {1, 1, 4, 4, 4}, 
        {10, 20, 30, 40, 50}
    };
 
    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.Wrap(-1, 2); // up-wrap one row and right-wrap two columns
    // Change nRowNum, nColNum to <0, =0, >0 to see different result
    // Result matrix:
    //	  {30, 40, 50, 10, 20} 
    //    {2, 2, 2, 1, 1}
    //    {3, 3, 3, 1, 1}
    //    {4, 4, 4, 1, 1}
    
    if(!rc) printf("Error: Wrap failed.\n");
    else
    {
        MatrixPage MatPg2;
        MatPg2.Create("Origin");
        MatrixLayer MatLy2 = MatPg2.Layers(0);
        Matrix Mat2(MatLy2);
        Mat2 = mat2;
        printf("  %s is a matrix wrapped upward once, and rightward twice.\n",
          Mat2.GetName());
    }
}

Remark

See Also

Header to Include

origin.h