This is the basic C++ program of C++ armadillo library which shows how to get the value of cross product of the two given vectors of same particular size. It can be carried out by the help of inbuilt function cross in armadillo library. It takes two parametres i.e both the vectors which must be of same 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
vec A = randu<vec>(3); //random vector of size 3 (generared by this syntax)
vec B = randu<vec>(3);
vec C = cross(A,B); //cross product of two vectors
cout << "A::\n"<<endl;
cout<< A << endl;
cout << "B::" << endl; //displaying
cout<< B << endl;
cout << "C (A*B)::\n"<<endl;
cout << C << endl;
return 0;
}
---------------------------------------------------------------------------------------------------------------
Commands to run program on terminal::
$ g++ filename.cpp -o objectname -O2 -larmadillo
$ ./objectname
---------------------------------------------------------------------------------------------------------------
Output::
Comments