   I need help solving this problem
  This is the problematic function :template<int N>VectorN<N> SquareMatrix::solve(const VectorN<N>& v)const{VectorN<N> res;switch(m_row){case 2  : res =  _solve2By2(v); break;case 3  : res =  _solve3By3(v); break;case 4  : res =  _solve4By4(v); break;default : res =  _solveNByN(v); break;}return res;}These are the prototypes for _solve*By* :VectorN<2> SquareMatrix::_solve2By2(const VectorN<2>& v2)constVectorN<3> SquareMatrix::_solve3By3(const VectorN<3>& v2)constVectorN<4> SquareMatrix::_solve4By4(const VectorN<4>& v2)const So say solve was called with N equal to 3. The problem is that _solve2By2(v)gets instantiated as well as _solve3By3, and _solve4By4. And that meansthere is going to be a compile error because VectorN<3> is not convertibleto VectorN<2> or VectorN<4>. Any help with this.   
VectorN<N> res;return VectorN<N>::solve(v);Or however solve() is declared.   ;Quote:Original post by AntheusVectorN<N> res;return VectorN<N>::solve(v);Or however solve() is declared.I'm not sure what you mean? The thing is, I have a different method to solvethe 2x2... 4x4 matrices, specifically, using its determinants if possible.I do not want to resort to Gaussian elimination or LU factorization just yet.   ;  Can you use template specialization instead of `switch'?   ;  You know, instead of dealing with this compile time stuff, I decided to justuse std::vectors. Since this class is essentially works during runtime. So thanksfor the responses.   ;  These are for matrices for graphics calculations?Just make three classes.Honestly.They don't have as much in common with each other as you'd expect them to, and you already know you're not going to need other sizes.   ;Quote:Original post by ZahlmanThese are for matrices for graphics calculations?Just make three classes.Honestly.They don't have as much in common with each other as you'd expect them to, and you already know you're not going to need other sizes.The three sizes 2x2, 3x3, and 4x4 ?This was not gonna be used for graphics calculations. As you suggested, I probablywould have created a 4x4 matrix class for that. This was mean to find a polynomial, given a sequence of digits. For examplegive the data points {1,2,3}. The function that finds the nth term, is f(n) = n.In order to find that polynomial, I found myself solving linear equations, soI decided to make such a system.;  OK, so then you're using them primarily for the things that all square matrices do have in common - namely, operations like matrix inversion.Well - why can't you write the matrix inversion in a general way? Each matrix size is not some kind of special case. You either do row-reduction or some kind of cofactor/adjoint/determinant thingy - either way, the solution can be expressed recursively, and the recursion converted to iteration.   ;Quote:Original post by ZahlmanOK, so then you're using them primarily for the things that all square matrices do have in common - namely, operations like matrix inversion.Well - why can't you write the matrix inversion in a general way? Each matrix size is not some kind of special case. You either do row-reduction or some kind of cofactor/adjoint/determinant thingy - either way, the solution can be expressed recursively, and the recursion converted to iteration.Yes I will first use gaussian elimination, then later on see if its fast enough,for what I need. If not, then I will move onto LU factorization, which willgreatly reduce the number of FLOPS. And the problem I am trying tosolve has always the property that it will always be a nxn square matrix.Thanks for the replies.   ;  If you are really concerned about performance, you should probably look up other polynomial interpolation methods, like Lagrange polynomials, or the Newton series.