matrixbase::Transpose

Description

Transpose a matrix.

Syntax

BOOL Transpose( )

Parameters

Return

Returns TRUE on success or FALSE on failure.

Examples

EX1

// Transpose a matrix
void matrixbase_Transpose_ex1()
{
    BOOL rc;
    
    matrix<double> mat1 = {
        {1,  1,  1,  1},
        {2,  4,  6,  8},
        {3,  6,  9, 12}
    };
// Output of this sample code:
//   Transposed matrix is:
//      1    2     3
//      1    4     6
//      1    6     9
//      1    8    12
//
    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers(0);
    Matrix Mat1(MatLy1);
    Mat1 = mat1;
    printf("  Input matrix is %s.\n",Mat1.GetName());
    
    MatrixPage MatPg2;
    MatPg2.Create("Origin");
    MatrixLayer MatLy2 = MatPg2.Layers(0);
    Matrix Mat2(MatLy2);
    Mat2 = mat1;
    
    rc=Mat2.Transpose(); // Transpose a matrix
    if(!rc) 
        printf("  Error: Transpose failed.\n");
    else
        printf("  Transposed matrix is %s.\n",Mat2.GetName());
}

Remark

Transpose a matrix. Rows become columns and columns become rows.

See Also

matrixbase::FlipHorizontal, matrixbase::FlipVertical, matrixbase::Rotate

header to Include

origin.h