---------------------------------------------------------------------------------------------------------------
Description::
This is the basic C++ program of C++ armadillo library which shows how to get the value of determinant of given matrix of some particular size.
---------------------------------------------------------------------------------------------------------------
Program::
#include <iostream>
#include <armadillo>using namespace std;
using namespace arma;
int main()
{ //initialize the random generator
//Create a 4 x 4 random matrix and printing it
mat A(5,5,fill::randu); //random matrix of size 4x4 (generared by this syntax)
double Det = det(A); //getting determinant of matrix by inbuilt function
cout << "A::\n"<<endl;
cout<< A << endl;
cout << "Determinant::" << endl; //displaying
cout << Det << endl;
return 0;
}
---------------------------------------------------------------------------------------------------------------
Commands to run program on terminal::
$ g++ filename.cpp -o objectname -O2 -larmadillo
$ ./objectname
---------------------------------------------------------------------------------------------------------------
Output::
Matrix A::
0.7868 0.4049 0.2742 0.8571 0.2393
0.2505 0.2513 0.5610 0.4998 0.3201
0.7107 0.0227 0.1400 0.4194 0.9105
0.9467 0.5206 0.5439 0.7443 0.1648
0.0193 0.3447 0.5219 0.2492 0.2455
Determinant
-0.0267737
Comments