From: Ian S. <ian...@st...> - 2002-10-15 14:47:26
|
// This appears to be a bug in MSVC 6 // For example the following code compiles with no errors. It // isn't instantiating the * function. #include <vnl/vnl_vector_fixed.h> #include <vnl/vnl_matrix_fixed.h> template <class T, unsigned M, unsigned N> inline vnl_vector_fixed<T, M> operator*(const vnl_matrix_fixed<T, M, N>& a, const vnl_vector_fixed<T, N>& b) { deliberate error } void wibble() { vnl_vector_fixed<double,2> vwib1(0.0); vnl_matrix_fixed<double,3,2> mwib1(1.0); vnl_vector_fixed<double,3> vwib2 = operator*(mwib1,vwib1); } // ******************* // Changing the name of the operator to my_mult has no effect. template <class T, unsigned M, unsigned N> inline vnl_vector_fixed<T, M> my_mult(const vnl_matrix_fixed<T, M, N>& a, const vnl_vector_fixed<T, N>& b) { deliberate error } void wibble() { vnl_vector_fixed<double,2> vwib1(0.0); vnl_matrix_fixed<double,3,2> mwib1(1.0); vnl_vector_fixed<double,3> vwib2 = my_mult(mwib1,vwib1); } // again compiles with no errors. // ************************ // Specifying the template parameters forces the obvious // compiler error. template <class T, unsigned M, unsigned N> inline vnl_vector_fixed<T, M> my_mult(const vnl_matrix_fixed<T, M, N>& a, const vnl_vector_fixed<T, N>& b) { deliberate error } void wibble() { vnl_vector_fixed<double,2> vwib1(0.0); vnl_matrix_fixed<double,3,2> mwib1(1.0); vnl_vector_fixed<double,3> vwib2 = my_mult<double, 3, 2>(mwib1,vwib1); } // gives error // C:\workspace\seng\vxlsrc\vxl\vnl\tests\test_arithmetic.cxx // (19) : error C2065: 'deliberate' : undeclared identifier // ***************** // Note that you can't give explicit template arguments to // operator*(..) - the compiler complains "unexpected 'double'" // ***************** // This does not appear to be a problem with confusion // with other operator*, matrx or vector definitions. // The following code also compiles correctly despite // the obvious error. template <class T, unsigned num_rows> class my_vec { }; template <class T, unsigned int num_rows, unsigned int num_cols> class my_mat { }; template <class T, unsigned M, unsigned N> inline my_vec<T, M> my_mult(const my_mat<T, M, N>& a, const my_vec<T, N>& b) { deliberate error } void wibble() { my_vec<double,2> v; my_mat<double,3,2> m; my_vec<double,3> res = my_mult(m,v); } // ************************8 // My proposed solution is ugly, but should work. // For MSVC6 (and v7 if it displays the same error) // Modification to vnl_matrix_fixed.h #ifdef VCL_VC60 # define macro( T, M, N ) inline \ vnl_vector_fixed<T, M> operator*(const vnl_matrix_fixed<T, M, N>& a, const vnl_vector_fixed<T, N>& b) { \ vnl_vector_fixed<T, M> out; \ for (unsigned i = 0; i < M; ++i) { \ T accum = a(i,0) * b(0); \ for (unsigned k = 1; k < N; ++k) \ accum += a(i,k) * b(k); \ out(i) = accum; \ } return out; } macro(double, 2 , 2 ); macro(double, 2 , 3 ); macro(double, 3 , 2 ); // .. # undef macro #else // The original templated operator* definition // .. #endif This has all sorts of restrictions, but at least it works. I'll check in this mod, and you can do what you like with it. Ian. > -----Original Message----- > From: Ian Scott [mailto:ian...@st...] > Sent: Tuesday, October 15, 2002 2:15 PM > To: 'Amitha Perera' > Subject: RE: Broken Continuous build for VXL > ian.isbe.man.ac.uk/WinNT-vxl-mul > > > I've fixed the easy errors, however the > > C:\workspace\seng\vxlsrc\vxl\vnl\tests\test_arithmetic_body.h( > 227) : error C2676: binary '*' : 'class > vnl_matrix_fixed<double,3,2>' does not define this operator > or a conversion to a type acceptable to the predefined operator > test_bignum.cxx > > Is problematic. > It appears that the compiler is getting confused between the > various templated operator*s > > For example > template <class T, unsigned M, unsigned N> > inline > vnl_vector_fixed<T, M> my_multiply(const vnl_matrix_fixed<T, > M, N>& a, const vnl_vector_fixed<T, N>& b) > { > // .. identical to operator* apart from name > } > > void wibble() > { > vnl_vector_fixed<double,2u> vwib1(0.0); > vnl_matrix_fixed<double,3u,2u> mwib1(1.0); > vnl_vector_fixed<double,3u> vwib2 = my_multiply(mwib1,vwib1); > } > > There is no problem. > > renaming the function back to operator* gives the same old error. > I am trying to track down exactly which one is interfering > with the definition we need. > More details later. > > Ian. > > > -----Original Message----- > > From: Amitha Perera [mailto:pe...@cs...] > > Sent: Tuesday, October 15, 2002 1:25 AM > > To: Ian Scott > > Subject: Re: Broken Continuous build for VXL > > ian.isbe.man.ac.uk/WinNT-vxl-mul > > > > > > Hi Ian > > > > I'm not sure that the the errors listed here are valid. > > > > Ignoring the internal compiler error, the two casts seem to work in > > vnl_matrix.txx; I'm not sure why it doesn't work for matrix > > fixed. Perhaps a C-style cast (T)scale would work? For the last, I > > don't know why it can't find the overload. All the overloads are > > available in either vnl_matrix.h or vnl_matrix_fixed.h. > > > > Could you have a look when you get a chance? > > > > Thanks, > > Amitha. > > > > > A Continuous build has been broken for VXL and you have > > been identified > > > as one of the authors who have checked in changes that are > > part of this build. > > > > > > Errors for this build are here: > > http://www.cs.rpi.edu/research/vision/vxl/Testing/Sites/ian.is > be.man.ac.uk/WinNT-vxl-mul/20021014-2302-Continuous/BuildError.html > > > > The changes for this build are here: > http://www.cs.rpi.edu/research/vision/vxl/Testing/Sites/ian.is be.man.ac.uk/WinNT-vxl-mul/20021014-2302-Continuous/Update.html > > The dashboard for the day is here: http://www.cs.rpi.edu/research/vision/vxl/Testing/Dashboard/20021014-0300-Ni ghtly/Dashboard.html > > If you have any questions about this email, please contact the VXL > monitors for this build: |