I am implementing a class for matrices (the mathematical object), and I am unsure how the definition for the multiplication operator should look. My class is defined as:
The following code should well illustrate what I would like to do, even though it cannot compile:Code:template <class T, int rows, int columns> class matrix { // Members, operators, etc. };
As you might recall from the linear algebra, the product of two matrices has dimensions as follows: [m x n][n x p] = [m x p]. Note the dimensions of the (thought) returned matrix above. If you know linear algebra, you will understand the problemCode:template <class T, int rows, int columns> class matrix { // Members, operators, etc. matrix<T, rows, cols> operator*(const matrix<T, columns, int cols> &m); }![]()



LinkBack URL
About LinkBacks



