Multiply matrices (matmul)
By tholscla on Sat, 11/02/2013 - 10:41
In R this would be A%*%B. In Rcpp it is matmul(A,B).
### Calls function: dot
Rcpp::NumericMatrix matmul(Rcpp::NumericMatrix A,Rcpp::NumericMatrix B)
{ int a= A.nrow();
int b= B.ncol();
Rcpp::NumericMatrix C(a,b);
for (int i = 0; i < a; i++)
{ for (int j = 0; j < b; j++)
{ C(i,j)= dot(A(i,_),B(_,j));
}
}
return C;
}