Reputation: 89
#include<iostream>
#include<armadillo>
using namespace std;
using namespace arma;
int main()
{
vec x = (1.0/5) * ones<vec>(N); //x is N sized uniformly distributed vector
vec xold(5);
mat v = randu<mat>(3,3);
mat b =randu<mat>(3,3);
mat c = v .* b; //element-wise matrix multiplication
xold = x .* x; // element-wise vector multiplication
}
//----------------------------this is the error message --------------------------------
/*
In function ‘int main()’:
SimilarityMatrix.cpp:182:17: error: ‘b’ cannot be used as a member pointer, since it is of type ‘arma::mat {aka arma::Mat<double>}’
mat c = (v.*b);
^
SimilarityMatrix.cpp:183:14: error: ‘x’ cannot be used as a member pointer, since it is of type ‘arma::vec {aka arma::Col}’ xold = x .* x; ^ */ //I would appreciate any immediate response.
Upvotes: 3
Views: 12522
Reputation: 3620
It's explained in the Armadillo documentation.
See the section on operators, which states that %
is used for element-wise multiplication:
mat c = v % b;
Upvotes: 12