James wrote:

I can't find a solution to this one, any suggestions would be welcome.

Say you have a matrix class specialized with storage type and

dimensions:

template<class T, unsigned ROWS, unsigned COLS>

class Matrix() {

...

};

You can overload an operation for multiplication of similar specialized

types:

Matrix<T,ROWS,COLS> operator*(const Matrix<T,ROWS,COLS>& right) const;

but can you think of a way to specialize a global function for

dissimilar types? ie:

Matrix<float, 3, 1> m1, m3;

Matrix<float, 3, 3> m2;

//Initialize operands...

m3 = m2 * m1;

TIA for any suggestions!

Here is a test program that I think does what you are trying to do:

-Alan

#include <iostream>

template <typename T, unsigned ROWS, unsigned COLS>

class Matrix

{

} ;

template <typename T, unsigned A, unsigned B, unsigned C>

Matrix<T, A, C> operator *(

const Matrix<T, A, B> & m1,

const Matrix<T, B, C> & m2)

{

std::cout << "Multiplying " << A << 'x' << B << " Matrix by "

<< B << 'x' << C << " Matrix." << std::endl ;

return Matrix<T, A, C>() ;

}

int main()

{

Matrix<int, 2, 3> a ;

Matrix<int, 3, 4> b ;

Matrix<int, 2, 4> c ;

c = a * b ;

return 0 ;

}