I have two header files: MyVector.h and MyMatrix.h. In both of them I define two multiplication function with the same name. Of course, the parameters are different:
for vector multiplication, and
They both work on either matrix or vector. Now I need to define a matrix-vector multiplication, ie.,
In this function prototype, I need to extract each row of matrix m1 to do a inner product with vector v2(the inner product define in MyVector.h). I already have a getRow function in MyMatrix.h. Now the problem is when I do this in my MatVetmult(...):
VC6++ doesn't recognize it needs to do a vector multiplication but complains that it is an illegal matrix multiplication.
It will be too tedious to modified the function names in all file. I recall something about overloading function but after check "C++ Primer", it looks like I can't overload it with this scope.
Any idea?
Thanks
Code:
template <class Type>
Vector<Type> mult(const Vector<Type>& v1, const Vector<Type>& v2);
Code:
template <class Type>
Matrix<Type> mult(const Matrix<Type>& m1,const Matrix<Type>& m2);
They both work on either matrix or vector. Now I need to define a matrix-vector multiplication, ie.,
Code:
template <class Type>
Type MatVetmult(const Matrix<Type>& m1, const Vector<Type> v2)
In this function prototype, I need to extract each row of matrix m1 to do a inner product with vector v2(the inner product define in MyVector.h). I already have a getRow function in MyMatrix.h. Now the problem is when I do this in my MatVetmult(...):
Code:
float temp = mult(m.getRow(1),v2);
VC6++ doesn't recognize it needs to do a vector multiplication but complains that it is an illegal matrix multiplication.
It will be too tedious to modified the function names in all file. I recall something about overloading function but after check "C++ Primer", it looks like I can't overload it with this scope.
Any idea?
Thanks