vendredi 28 juillet 2017

Operating on slices of Cube in armadillo

I am trying to get used to armadillo linear algebra library for c++ and I cannot figure out hot to operate on slices(matrices) of a cube. Whenever I try to operate on a slice, the program compiles but does not give any output, not even the outputs of statement before the slice operation. Here's the code:

#include <armadillo>
#include <iostream>
using namespace arma;
using namespace std;

int main()
{

Cube<double> A(3  , 5 ,1, fill::randu);

Cube<double>B(5,3,1,fill::randu);
Mat<double>x  =A.slice(0);
Mat<double>y = B.slice(0);
cout << x << "\n" << y << endl;
cout << x*y << endl; //code works fine if this line is removed
}

the problem is that the code works fine if the last line is removed. Why does this happen? Is there a better way to operate on matrices inside a cube ?

Aucun commentaire:

Enregistrer un commentaire