2.2.3.9.52 matrixbase::ReorderReorder
Description
Re-order a matrix from Column order to Row order or from Row order to Column order.
Syntax
BOOL Reorder( BOOL bRowOrder = TRUE )
Parameters
- bRowOrder
- [input] If TRUE re-order to Row order and if FALSE re-order to Column order
Return
Returns TRUE on success or FALSE on failure.
Examples
EX1
// Reorder a matrix
void matrixbase_Reorder_ex1()
{
matrix<double> mat1 = {
{1, 1, 1, 1},
{2, 4, 6, 8},
{3, 6, 9, 12}
};
// Output of this sample code:
// Reordered matrix in Row order is:
// 1 2 3 1
// 4 6 1 6
// 9 1 8 12
// Reordered matrix in Column order is:
// 1 1 6 6
// 1 2 8 9
// 1 4 3 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;
int rc=Mat2.Reorder(); // Reorder matrix from Column order to Row order (default)
if(!rc)
printf(" Error1: Reorder failed.\n");
printf(" Reordered matrix (in Row order) is %s.\n",Mat2.GetName());
MatrixPage MatPg3;
MatPg3.Create("Origin");
MatrixLayer MatLy3 = MatPg3.Layers(0);
Matrix Mat3(MatLy3);
Mat3 = mat1;
rc=Mat3.Reorder(FALSE); // Reorder matrix from Row order to Column order
if(!rc)
printf(" Error2: Reorder failed.\n");
printf(" Reordered matrix (in Column order) is %s.\n",Mat3.GetName());
}
Remark
Re-order a matrix from Column order to Row order or from Row order to Column order.
See Also
matrixbase::FlipHorizontal, matrixbase::FlipVertical, matrixbase::Rotate, matrixbase::Transpose
Header to Include
origin.h
|