Basic C++ code for multiplication of 2 matrix or vectors (C++ beginner)
- by Ice
I am a new C++ user and I am also doing a major in Maths so thought I would try implement a simple calculator. I got some code off the internet and now I just need help to multiply elements of 2 matrices or vectors.
Matrixf multiply(Matrixf const& left, Matrixf const& right) {
// error check
if (left.ncols() != right.nrows()) {
throw std::runtime_error("Unable to multiply: matrix dimensions not agree.");
}
/* I have all the other part of the code for matrix*/
/** Now I am not sure how to implement multiplication of vector or matrix.**/
Matrixf ret(1, 1);
return ret;
}