rearrange the matrix in column-wise according to the given indices
BOOL ReorderColWise( const vector<UINT> & vnIndices, int nR1 = 0, int nC2 = -1 )
Returns TRUE on successful exit or FALSE on failure.
EX1
void ReorderColWise_ex() { BOOL rc; matrix mat1 = { {1, 2, 6, 9}, {2, 5, 4, 11}, {3, 7, 2, 12}, {4, 0, 4, 8}, {5, 2, 3, 10}, {6, 1, 0, 7} }; vector<UINT> vOrders = {3, 0, 1, 2}; MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix Mat1(MatLy1); Mat1 = mat1; printf(" Original matrix is %s.\n",Mat1.GetName()); MatrixPage MatPg2; MatPg2.Create("Origin"); MatrixLayer MatLy2 = MatPg2.Layers(0); Matrix Mat2(MatLy2); Mat2 = mat1; rc=Mat2.ReorderColWise(vOrders, 0, 1); //Reordering columns based on the vOrders vector, only reorder the first 2 rows if(!rc) printf(" Error: fail.\n"); else printf(" Reordered matrix is %s.\n",Mat2.GetName()); }
origin.h