This is the basic C++ program of C++ armadillo library which shows how to generate copy of matrix with columns and rows reversed of input matrix some particular size. It can be carried out by the help of inbuilt functions "fliplr" and "flipud" in armadillo library. It takes one parameter i.e input matrix name.
fliplr(): generate a copy of matrix X, with the order of the columns reversed
flipud(): generate a copy of matrix X, with the order of the rows reversed
mat A = randu<mat>(5,5);//random matrix of size 5 x 5 (generared by this syntax)
mat B = fliplr(A); //columns reversed
mat C = flipud(A); //rows reversed
cout << "Matrix A::\n"<<endl;
cout<< A << endl;
cout << "Matrix B(columns reversed)::\n"<<endl;
cout << B << endl;
cout << "Matrix C(rows reversed)::\n"<<endl;
Comments