From: Gehua Yang <yangg2@rp...>  20050413 17:11:03

Riccardo Lattanzi wrote: >I tried to isolate the sources of error and here are the steps (error messages >pasted at the end of the email): > >1. If I use everything as downloaded from Vxl website, then vnl build >perfectly. > >2. Adding the explicit instantiation files vnl_matrix+mp_real.cxx and >vnl_matrix+mp_complex.cxx I get the errors I posted in the previous email plus >those referred to not templated functions used by member functions of >vnl_matrix.(normalize_rows,normalize_columns, etc... are templated on types >but inside their code they call functions like vnl_math_squared_magnitude, >vcl_sqrt, etc... which are missing the specialization for mp_complex and >mp_real) >WHAT DOES "VCL_DEFINE_SPECIALIZATION" BEFORE EACH TEMPLATE SPECIALIZATION MEAN? >DO I NEED TO ADD THAT? > > > Macro VCL_DEFINE_SPECIALIZATION is used to deal with broken compiler which has problems with template specialization. For most compilers, it will expand to template <>. Let's not worry about this. >3. If I comment out the functions in vnl_matrix that give errors I still have >the other error messages I pasted in the previous email. >So, I think I need to focus on them: > >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(32) : warning C4003: not enough >actual parameters for macro 'min' >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : warning C4003: not enough >actual parameters for macro 'max' >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(32) : error C2589: '(' : >illegal token on right side of '::' > C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : >while compiling classtemplate member function 'double __thiscall >vnl_unary_function<double,class vnl_vector<double> >::get_range_min(void) >const' >...etc..... > >vnl_unary_function is an abstract map between two types. >vnl_unary_function has only 2 specializations in the Templates folder >(vnl_unary_function+double.vnl_vector+double.cxx and >vnl_unary_function+int.int.cxx) >WHY ONLY THESE TWO? >The class vnl_unary_function uses the templated class vcl_numeric_limits >defined >in vcl_limits. > > > What I don't see is why these errors are raised while it is not related to mp_real or mp_complex. The order of included files are: vnl_unary_function+double.vnl_vector+double.cxx vnl_vector.h vnl_unary_function.txx vcl_limits.h I guess none of these files are touched, as you only add vnl_matrix instantiation file. I don't see why the introduction of mp_real and mp_complex breaks this. There is no mp_complex involved in these files. >4. I tried to add the specialization for mp_complex and mp_real in vcl_limits, >just copying that for long double (subs mp_real or mp_complex in place >of long double but it didn't make any difference). > > > > One example you could look at is vnl_matrix+vnl_rational.cxx, which include vnl_rational_traits.h. vnl_rational is also a nonstandard class. But by defining the vnl_math_squared_magnitude & vnl_math_abs functions in vnl_rational_traits.{h,cxx}, it is able to instantiate vnl_matrix<vnl_rational>. Second, vnl_rational didn't define any numeric limits. My intuition is you don't need that either. Hence, your case is only a bit more difficult than this example: vcl_sqrt . The solution will be change all occurance of vcl_sqrt to vnl_math_sqrt. By the way, VC6 is a broken compiler and its error messages usually do not make any sense. Is it convenient for you to get another compiler, such as Visual Studio .Net or GCC 3.x? I am not sure how much momentum you have at this point. If you are still committed, I will be willing to make the change vcl_sqrt > vnl_math_sqrt. By the way, if anyone has objections about this change, please speak. Regards, Gehua 