Do you know why I cannot store in a double the result from a vector multiplication ?
double A = rowvec({1,3,4})*vec({5,6,7});
It gives "no suitable conversion function from "const arma::Glue"... to "const double" exists.
Still that matrix vector multiplication gives a double. How can I get around ?
Thank you!
The result of the product is an expression template called arma::Glue
which can be converted to a 1x1 matrix. To do this inline and assign it to a double evaluate it explicitly using .eval()
and take the only element which is (0,0).
#include <armadillo>
int main() {
using arma::rowvec;
using arma::vec;
double A = (rowvec({1,3,4})*vec({5,6,7})).eval()(0,0);
};
N.B.: Did you mean dot(a,b)
?
#include <armadillo>
int main() {
using arma::rowvec;
using arma::vec;
using arma::dot;
double A = dot(rowvec({1,3,4}), vec({5,6,7}));
};