This is the basic C++ program of C++ armadillo library which shows how to get the absolute value of the two given matrix of some particular size. It can be carried out by the help of inbuilt function "abs" in armadillo library. It takes just the one parameter i.e the matrix name.
---------------------------------------------------------------------------------------------------------------
Program::
#include <iostream>
#include <armadillo>using namespace std;
using namespace arma;
int main()
{
// without initializing the random generator
//Creating a 3 x 2 random matrix and printing it
mat A;
A << 1 << -2 << 4 << endr
<< 45 << -6 << -8 << endr;
mat B = abs(A); //Getting absolute value of matrix
cout << "Matrix A::\n"<<endl;
cout<< A << endl;
cout << "Matrix B(Absolute value)::" << endl; //displaying
cout<< B << endl;
return 0;
}
---------------------------------------------------------------------------------------------------------------
Commands to run program on terminal::
$ g++ filename.cpp -o objectname -O2 -larmadillo
$ ./objectname
---------------------------------------------------------------------------------------------------------------
Output::
Comments