Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050110 22:24:32

Hi, A friend of mine has just introduced me to VNL, but I'm not sure if I'll be able to use it asis for my purposes. I need to invert a matrix of complex numbers whose rows are almost linearly dependent. I hope somebody can help me with the following questions: 1 Can I create a matrix of complex elements? 2 Is there a way to use arbitrary precision for the complex data type (kind of what can be done with mathematica)? Thanks a lot. Sincerely, Riccardo  
From: Ian Scott <ian.m.scott@st...>  20050111 13:21:35

Riccardo Lattanzi wrote: > Hi, > > A friend of mine has just introduced me to VNL, but I'm not sure > if I'll be able to use it asis for my purposes. > > I need to invert a matrix of complex numbers whose rows are almost > linearly dependent. I hope somebody can help me with the following > questions: I take it using an SVD based inverse with double precision is not sufficient? > > 1 Can I create a matrix of complex elements? > Yes vnl_matrix<vcl_complex<double> > M(m,n); > 2 Is there a way to use arbitrary precision for the complex > data type (kind of what can be done with mathematica)? Unfortunately we don't have an infinite precision real number class. That said it would not be difficult to create one. Create a new class vnl_arbitrary_precision, that looks the same as vnl_rational, and change the type of the numerator and denominator to vnl_bignum. There would no doubt be a several other changes to the class's API to get this to work smoothly. vnl should then allow you to create a matrix with a complex version of this new type: vnl_matrix<vcl_complex<vnl_arbitrary_precision> > The biggest problem however is that most (and probably all) of the matrix decomposition and inversion classes in vnl_algo are actually just thin wrappers around the netlib library. This Fortran library can only cope with matrices of float, double, complex<float> and complex<double> types. Writing a basic LU decomposition based class would be possible. Ian. 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050111 17:02:15

Thanks for your answer, I've search the web a little and I came out with an idea to solve the problem (see below). I'd really appreciate if you could give me your opinion on that. > I take it using an SVD based inverse with double precision is not > sufficient? > Unfortunately it's not sufficient. I have to deal with 750 by 750 matrices of complex elements, which are badly conditioned. I've implemented using Mathematica with 50 digits precision, but I need the performance of C++ for my purposes. > ......... > > vnl should then allow you to create a matrix with a complex version of > this new type: > > vnl_matrix<vcl_complex<vnl_arbitrary_precision> > > > The biggest problem however is that most (and probably all) of the > matrix decomposition and inversion classes in vnl_algo are actually just > thin wrappers around the netlib library. This Fortran library can only > cope with matrices of float, double, complex<float> and complex<double> > types. Writing a basic LU decomposition based class would be possible. > > Ian. > I found a package that allows to create a type with arbitrary precision ( ARPREC, http://crd.lbl.gov/~dhbailey/mpdist/ ). The library also includes the redefinition of the basic arithmetic operators to smartly handle the new type. I could write my own "matrixinverter" code using this package, but I'm not sure I would end up with something as efficient as the VNL matrix inversion. Do you think it's feasible to create a new type with ARPREC, use it inside VNL and edit the VNL source codes for matrix inversion and matrix multiplication forcing the program to use the typespecific operators instead of the standard +  * / ? Or do you suggest to write my own LU decomposition using the ARPREC library? Thank for your help. Riccardo 
From: Ian Scott <ian.m.scott@st...>  20050112 09:16:26

Riccardo Lattanzi wrote: > Thanks for your answer, I've search the web a little and I came out with > an idea to solve the problem (see below). I'd really appreciate if you > could give me your opinion on that. > > >>I take it using an SVD based inverse with double precision is not >>sufficient? >> > > > Unfortunately it's not sufficient. I have to deal with 750 by 750 > matrices of complex elements, which are badly conditioned. > I've implemented using Mathematica with 50 digits precision, but I need > the performance of C++ for my purposes. > > >>......... >> >>vnl should then allow you to create a matrix with a complex version of >>this new type: >> >>vnl_matrix<vcl_complex<vnl_arbitrary_precision> > >> >>The biggest problem however is that most (and probably all) of the >>matrix decomposition and inversion classes in vnl_algo are actually just >>thin wrappers around the netlib library. This Fortran library can only >>cope with matrices of float, double, complex<float> and complex<double> >>types. Writing a basic LU decomposition based class would be possible. >> >>Ian. >> > > > I found a package that allows to create a type with arbitrary precision > ( ARPREC, http://crd.lbl.gov/~dhbailey/mpdist/ ). The library also > includes the redefinition of the basic arithmetic operators to smartly > handle the new type. > I could write my own "matrixinverter" code using this package, but I'm > not sure I would end up with something as efficient as the VNL matrix > inversion. > > Do you think it's feasible to create a new type with ARPREC, use it inside > VNL and edit the VNL source codes for matrix inversion and matrix > multiplication forcing the program to use the typespecific operators > instead of the standard +  * / ? > > Or do you suggest to write my own LU decomposition using the ARPREC > library? Having had a quick look at ARPREC, it appears to provide the standard operator+, operator*, etc for the main numeric classes mpreal and mpcomplex. So vnl would should be able to create matrices of mpcomplex fairly easily. You might need to add some simple definitions of vnl_numeric_traits<mpreal>, vnl_complex_traits<mpcomplex>, etc. The basic matrix operations  addition, multiplication  should work fine on vnl_matrix<mpcomplex>. You would still need to write a decomposition class in order to invert your matrix (as I mentioned above, vnl_algo's decomposition and inversion classes only work on a strictly limited set of types) but I guess Numerical Recipes would help there. If you have to use mpcomplex to do the numbers, and write your own decomposition, then it is hard to say if the advantage of using vnl's matrix handling, is worth your effort in setting up vnl. On the plus side, VXL is pretty easy to setup, especially if you switch off everything but the numerics in the build options. On the plus side for us, we would be interested in your experience of using ARPREC+vnl, and we would be happy to put your decomposition code in the library. If you do want to write a LU decomposition class for vnl_matrix<mpcomplex> I suggest you write it for vnl_matrix<vcl_complex<double> > first and then turn it into a templated class. Ian. 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050317 22:30:56

Hi, I had to stop working on this for a while, but now I'm back on it. As you suggested I first wrote my own routine for matrix inversion (based on LU decomposition) for vnl_matrix<vcl_complex<double> >. It works correctly, but I haven't wrote it as a class (I wrote the functions and I call them from my main application which read MATLAB matrices, perform the inversion and wrote the inverted matrix on a MATLAB file). On the otherside I build the Multiprecision Library ARPREC and I test it on some sample applications. Now I need to integrate the two and I'm not sure to know how to do it. What I would do is: 1 write the decomposition as a class; 2 turn such class in a templated class so it would work for both vnl_matrix<vcl_complex<double> > and vnl_matrix<vcl_complex<mpreal> > ARPREC provide the standard operators for mpreal. What should I do to make everything work? Do I need to edit the Vnl files? (edit vnl_matrix and define new operators overloading for the new case?) Could you please help me on this? Could you point to some code in Vnl I could get some ideas? Thanks a lot. Riccardo > > Having had a quick look at ARPREC, it appears to provide the standard > operator+, operator*, etc for the main numeric classes mpreal and > mpcomplex. So vnl would should be able to create matrices of mpcomplex > fairly easily. You might need to add some simple definitions of > vnl_numeric_traits<mpreal>, vnl_complex_traits<mpcomplex>, etc. > > The basic matrix operations  addition, multiplication  should work > fine on vnl_matrix<mpcomplex>. You would still need to write a > decomposition class in order to invert your matrix (as I mentioned > above, vnl_algo's decomposition and inversion classes only work on a > strictly limited set of types) but I guess Numerical Recipes would help > there. > > If you have to use mpcomplex to do the numbers, and write your own > decomposition, then it is hard to say if the advantage of using vnl's > matrix handling, is worth your effort in setting up vnl. On the plus > side, VXL is pretty easy to setup, especially if you switch off > everything but the numerics in the build options. On the plus side for > us, we would be interested in your experience of using ARPREC+vnl, and > we would be happy to put your decomposition code in the library. > > If you do want to write a LU decomposition class for > vnl_matrix<mpcomplex> I suggest you write it for > vnl_matrix<vcl_complex<double> > first and then turn it into a templated > class. > > Ian. > > > >  Riccardo Lattanzi HarvardMIT Division of Health Science and Technology Laboratory for Biomedical Imaging Research Beth Israel Deaconess Medical Center Tel: (+1) 617 667 0281 Fax: (+1) 617 667 7917 
From: Ian Scott <ian.m.scott@st...>  20050405 13:02:19

Riccardo Lattanzi wrote: > Hi, > > sorry for my last email...I should have slept over the problem. > Now everything is working fine (there were a lot of typos in the code!). > I build it and I was able to invert a matrix correctly. > Still I need your help for the integration with the multiprecision > library because I've never done anything similar to what you suggested. > That is: > > >>As far as I understand what you are doing, you should not need to add >>any code to vnl_matrix. The only thing you will need to do is add your >>own template instantiation file. >> >>// example tempalte instantion file for ARPREC. >>#include <vnl/vnl_complex.h> >>#include <vnl/vnl_matrix.txx> >>#include <arprec/mpcomplex.h> >>VNL_MATRIX_INSTANTIATE(mpcomplex); >> >>The instantiation will link against the operatots provided by ARPREC. >>You might have to add one for vnl_vector as well. >> > > > What do you mean by "adding my own instantion file for ARPREC" ? > I don't understand what "VNL_MATRIX_INSTANTIATE(mpcomplex);" does. > Is it a function? Template instantiation is the creation of code from a c++ template for a specific instace of the templates parameters, e.g. for vcl_pair<A,B>, you can implicitly instantiate vcl_pair<int,double> by using vcl_pair<int,double>, in which case all the necessary code is put into the current translation unit. (Well actually, it is all likely to be inlined away  but that is another issue.) Alternatively you can do explicit instantiation by declaring template <> vcl_pair<int, double>; which will include all the code associated vcl_pair, specialised for <int,double> into the current translation unit. Some compilers can do smart things, but we are restricted because our code has to work with a wide range of compilers, many of which do no smart stuff to help us handle template instantiation. So VXL uses implicit instantiation for all parts of the STL (or VCL as we call it.) However, our own templates in VXL are much larger than those in the STL, and having a copy in every translation unit that uses it would be very expensive in both compiled space, and compilation time. All of the code in VXL's *.txx files are explicitly instantiated once for each specialisation. This occurs in the template instantion files, which are kept in Template subdirs of the relevent library. The .txx file provides a macro, e.g. VNL_MATRIX_INSTANTIATE(A). For every template specialisation that we need e.g. vnl_matrix<double>, we have template instatiation file e.g. vnl/Templates/vnl_matrix+double.cxx, that invokes the macro appropriately, e.g. #include <vnl/vnl_matrix.txx> VNL_MATRIX_INSTANTIATE(double); Some of the code in vnl_matrix is available in vnl_matrix.h in the hope that the compiler will inline it, but if you want to link against anything in vnl_matrix.txx you will need to provide a template instantiation file, like the example above. More details can be found in the VXL book at http://paine.wiau.man.ac.uk/pub/doc_vxl/books/core/book_3.html#SEC28 and http://paine.wiau.man.ac.uk/pub/doc_vxl/books/core/book_15.html#SEC152 Ian. 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050408 20:15:52

Quoting Ian Scott <ian.m.scott@...>: > All of the code in VXL's *.txx files are explicitly instantiated once > for each specialisation. This occurs in the template instantion files, > which are kept in Template subdirs of the relevent library. The .txx > file provides a macro, e.g. VNL_MATRIX_INSTANTIATE(A). For every > template specialisation that we need e.g. vnl_matrix<double>, we have > template instatiation file e.g. vnl/Templates/vnl_matrix+double.cxx, > that invokes the macro appropriately, e.g. > #include <vnl/vnl_matrix.txx> > VNL_MATRIX_INSTANTIATE(double); > Hi, thanks for your help on template instantion. I followed your suggestion but I still get an error, even if everything looks fine to me. Summarizing: I have vnl and a multiprecision library that define a class (mp_complex) which is a complex number with arbitrary precision (I can choose how many digits). I need to create a vnl_matrix<mp_complex> matrix to do inversion of badly conditioned matrices. In order to integrate the two libraries I've created a file "vnl_matrix+mp_complex.cxx" in the folder "/.../vnl/Templates". Such files contains the template explicit instantiation: #include <mp/mpcomplex.h> #include <vnl/vnl_matrix.txx> VNL_MATRIX_INSTANTIATE(mp_complex); besides that I didn't do anything else (I did NOT rebuild vnl, I did NOT add anything to vnl_matrix.txx,...should have done something else?). In the main file I successfully read matrices from file and convert each element in mp_complex. However I didn't succeeded in creating a vnl_matrix<mp_complex> matrix to contain such mp_complex elements. If for example I add the line: vnl_matrix<mp_complex> arprec_mat(1,1); I get the following error when I build: Linking... vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol "public: __thiscall vnl_matrix<class mp_complex>::~vnl_matrix<class mp_complex>(void)" (??1?$vnl_matrix@...@@@@QAE@...) vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol "public: __thiscall vnl_matrix<class mp_complex>::vnl_matrix<class mp_complex>(unsigned int,unsigned int)" (??0?$vnl_matrix@...@@@@QAE@...@Z) Release/05042005_arprec_test.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. Although if I add just vnl_matrix<mp_complex> arprec_mat() I don't get any error, actually it's not working. In fact nothing is created. To check that I simply added the line arprec_mat.size() and when I built I got the error: error C2228: left of '.size' must have class/struct/union type Could you please help me with this issue? Thanks a lot. Riccardo  Riccardo Lattanzi HarvardMIT Division of Health Science and Technology Laboratory for Biomedical Imaging Research Beth Israel Deaconess Medical Center Tel: (+1) 617 667 0281 Fax: (+1) 617 667 7917 
From: Gehua Yang <yangg2@rp...>  20050408 20:35:17

The linking errors you got are likely caused by missing instantiation. I am not sure if you have done it. But in case you don't, you will need to do the following. To "activate" the your instantiation file, you need to rerun CMake, which will added this instantiation file into workspace/Makefile. After recompiling vnl (no need to clean build), you should be able to get rid of these linking errors. Regards, Gehua >In order to integrate the two libraries I've created a >file "vnl_matrix+mp_complex.cxx" in the folder >"/.../vnl/Templates". Such files contains the template >explicit instantiation: > >#include <mp/mpcomplex.h> >#include <vnl/vnl_matrix.txx> >VNL_MATRIX_INSTANTIATE(mp_complex); > > > >besides that I didn't do anything else (I did NOT rebuild vnl, >I did NOT add anything to vnl_matrix.txx,...should have done something else?). > >In the main file I successfully read matrices from file and >convert each element in mp_complex. However I didn't succeeded >in creating a vnl_matrix<mp_complex> matrix to contain such mp_complex >elements. >If for example I add the line: vnl_matrix<mp_complex> arprec_mat(1,1); >I get the following error when I build: > >Linking... >vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol "public: >__thiscall vnl_matrix<class mp_complex>::~vnl_matrix<class mp_complex>(void)" >(??1?$vnl_matrix@...@@@@QAE@...) >vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol "public: >__thiscall vnl_matrix<class mp_complex>::vnl_matrix<class mp_complex>(unsigned >int,unsigned int)" (??0?$vnl_matrix@...@@@@QAE@...@Z) >Release/05042005_arprec_test.exe : fatal error LNK1120: 2 unresolved externals >Error executing link.exe. > >Although if I add just vnl_matrix<mp_complex> arprec_mat() I don't get any >error, actually it's not working. In fact nothing is created. >To check that I simply added the line arprec_mat.size() and when I built >I got the error: >error C2228: left of '.size' must have class/struct/union type > >Could you please help me with this issue? >Thanks a lot. > >Riccardo > > > 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050408 21:37:29

Thanks, I've done what you suggested, but when I attempted to rebuild just vnl from VisualC++6 I get this error both for vnl_matrix<mp_complex> and vnl_vector<mp_complex>:  vnl_vector+mp_complex.cxx D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : error C2440: 'type cast' : cannot convert from 'unsigned int' to 'class vnl_numeric_traits_not_a_valid_type' No constructor could take the source type, or constructor overload resolution was ambiguous D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::mean(const class mp_complex *,unsigned int)'  vnl_matrix+mp_complex.cxx D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : error C2440: 'type cast' : cannot convert from 'unsigned int' to 'class vnl_numeric_traits_not_a_valid_type' No constructor could take the source type, or constructor overload resolution was ambiguous D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::mean(const class mp_complex *,unsigned int)'  Does it mean that big changes are needed to make the 2 library together? Could you please help me to solve that? Thanks. Riccardo Quoting Gehua Yang <yangg2@...>: > The linking errors you got are likely caused by missing instantiation. I > am not sure if you have done it. But in case you don't, you will need to > do the following. > > To "activate" the your instantiation file, you need to rerun CMake, > which will added this instantiation file into workspace/Makefile. After > recompiling vnl (no need to clean build), you should be able to get rid > of these linking errors. > > Regards, > Gehua > > > >In order to integrate the two libraries I've created a > >file "vnl_matrix+mp_complex.cxx" in the folder > >"/.../vnl/Templates". Such files contains the template > >explicit instantiation: > > > >#include <mp/mpcomplex.h> > >#include <vnl/vnl_matrix.txx> > >VNL_MATRIX_INSTANTIATE(mp_complex); > > > > > > > >besides that I didn't do anything else (I did NOT rebuild vnl, > >I did NOT add anything to vnl_matrix.txx,...should have done something > else?). > > > >In the main file I successfully read matrices from file and > >convert each element in mp_complex. However I didn't succeeded > >in creating a vnl_matrix<mp_complex> matrix to contain such mp_complex > >elements. > >If for example I add the line: vnl_matrix<mp_complex> arprec_mat(1,1); > >I get the following error when I build: > > > >Linking... > >vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol > "public: > >__thiscall vnl_matrix<class mp_complex>::~vnl_matrix<class > mp_complex>(void)" > >(??1?$vnl_matrix@...@@@@QAE@...) > >vnl_arprec_inv_test.obj : error LNK2001: unresolved external symbol > "public: > >__thiscall vnl_matrix<class mp_complex>::vnl_matrix<class > mp_complex>(unsigned > >int,unsigned int)" (??0?$vnl_matrix@...@@@@QAE@...@Z) > >Release/05042005_arprec_test.exe : fatal error LNK1120: 2 unresolved > externals > >Error executing link.exe. > > > >Although if I add just vnl_matrix<mp_complex> arprec_mat() I don't get any > >error, actually it's not working. In fact nothing is created. > >To check that I simply added the line arprec_mat.size() and when I built > >I got the error: > >error C2228: left of '.size' must have class/struct/union type > > > >Could you please help me with this issue? > >Thanks a lot. > > > >Riccardo > > > > > > >  Riccardo Lattanzi HarvardMIT Division of Health Science and Technology Laboratory for Biomedical Imaging Research Beth Israel Deaconess Medical Center Tel: (+1) 617 667 0281 Fax: (+1) 617 667 7917 
From: Gehua Yang <yangg2@rp...>  20050408 22:02:44

The vnl_numeric_traits<mp_complex> specialization is missing. If you take a look into vnl_numeric_traits.h, you will find out it is only a dozen lines to add. Besides, you can copy from vnl_numeric_traits< complex<double> >. I believe it won't take more than 10 minutes. By the way, I notice your directory name is vxl1.1.0. CVS checkout of the current version is more recommended. Gehua Riccardo Lattanzi wrote: >Thanks, >I've done what you suggested, but when I attempted to rebuild just vnl >from VisualC++6 I get this error both for vnl_matrix<mp_complex> >and vnl_vector<mp_complex>: > > >vnl_vector+mp_complex.cxx >D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : error C2440: 'type cast' : >cannot convert from 'unsigned int' to 'class >vnl_numeric_traits_not_a_valid_type' > No constructor could take the source type, or constructor overload >resolution was ambiguous > D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling >classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class >mp_complex>::mean(const class mp_complex *,unsigned int)' > >vnl_matrix+mp_complex.cxx >D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : error C2440: 'type cast' : >cannot convert from 'unsigned int' to 'class >vnl_numeric_traits_not_a_valid_type' > No constructor could take the source type, or constructor overload >resolution was ambiguous > D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling >classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class >mp_complex>::mean(const class mp_complex *,unsigned int)' > > > >Does it mean that big changes are needed to make the 2 library together? >Could you please help me to solve that? > >Thanks. >Riccardo > > > > > > 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050411 22:09:44

Quoting Gehua Yang <yangg2@...>: > The vnl_numeric_traits<mp_complex> specialization is missing. If you > take a look into vnl_numeric_traits.h, you will find out it is only a > dozen lines to add. Besides, you can copy from vnl_numeric_traits< > complex<double> >. I believe it won't take more than 10 minutes. > Hi, Thanks for your suggestion. I added the specialization on vnl_numeric_traits but that caused new error to arise. I did the vnl_numeric_traits<mp_complex> and vnl_numeric_traits<mp_real> adding the following to vnl_numeric_traits.h (AND NOTHING TO vnl_numeric_traits.cxx): class vnl_numeric_traits< mp_complex > { public: //: Additive identity static const mp_complex zero; //: Multiplicative identity static const mp_complex one; // Maximum value which this type can assume; makes no sense for this type //static const vcl_complex<double> maxval; //: Return value of abs() typedef mp_real abs_t; //: Name of a type twice as long as this one for accumulators and products. typedef mp_complex double_t; //: Name of type which results from multiplying this type with a double typedef mp_complex real_t; }; class vnl_numeric_traits< mp_real > { public: //: Additive identity static const mp_real zero; //: Multiplicative identity static const mp_real one; //: Maximum value which this type can assume static const mp_real maxval; //: Return value of abs() typedef mp_real abs_t; //: Name of a type twice as long as this one for accumulators and products. typedef mp_real double_t; //: Name of type which results from multiplying this type with a double typedef mp_real real_t; }; That seemed to work per se but lead to many errors when I rebuilt vnl. There are some member functions in vnl_matrix.txx (i.e. normalize_rows, normalize_columns, operator_one,_norm,....) that use some functions which are not templated and expect vcl_complex<double> (i.e. vnl_math_squared_magnitude, vnl_math_abs, vnl_matlab_isfinite,...). I tried to work around that commenting out the member functions of vnl_matrix which were causing problems (not very elegant, but if I can build at least I could try to write examples with vnl_matrix<mp_complex>). Using such "cheating" I got rid of most of the errors. The remaining ones are related to the file vnl_unary_function_h which I think doesn't work because it searches for the limits of mp_complex and mp_real in vcl_numeric_limits. (at the end of the email I'm attaching the error message) Is something I did wrong when adding the specialization on vnl_numeric_traits.h ? I don't think I'm ready to solve that problem without the guide of some Vxl devoloper. Can you please help me with this? Thanks a lot, Riccardo Lattanzi Error Message: Configuration: vnl  Win32 Release Compiling... vnl_unary_function+double.vnl_vector+double.cxx 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' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(32) : error C2059: syntax error : '::' 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' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : 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_max(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : error C2059: syntax error : '::' 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_max(void) const' Error executing cl.exe. vnl.lib  4 error(s), 2 warning(s)  Riccardo Lattanzi HarvardMIT Division of Health Science and Technology Laboratory for Biomedical Imaging Research Beth Israel Deaconess Medical Center Tel: (+1) 617 667 0281 Fax: (+1) 617 667 7917 
From: Gehua Yang <yangg2@rp...>  20050412 18:36:05

In your class vnl_numeric_traits< mp_complex >, I believe you forgot to change the type of maxval. In vnl_numeric_traits.cxx, could you add: const mp_complex vnl_numeric_traits<mp_complex >::zero(0.0); const mp_complex vnl_numeric_traits<mp_complex >::one(1.0); const mp_complex vnl_numeric_traits<mp_complex >::maxval(1E+308); // let's not worry about this value for now const mp_real vnl_numeric_traits<mp_real >::zero(0.0); const mp_real vnl_numeric_traits<mp_real >::one(1.0); const mp_real vnl_numeric_traits<mp_real >::maxval(1E+308); // let's not worry about this value for now All these are just to make it complete. I do not know what construtors are available for mp_real and mp_complex. Please change them accordingly. At this point, you should be able to compile vnl_numeric_traits.cxx without errors. Looking at the errors you attached, they happened when compling vnl_unary_function+double.vnl_vector+double.cxx, which has nothing to do with mp_real or mp_complex. If you haven't had problems with this file before, then it is quite likely your changes to vnl_matrix or vnl_vector caused these errors. Let's focus on vnl_matrix.txx. member functions, such as normalize_rows, normalize_columns, and operator_one_norm, are all templated on types. As far as I can see, vnl_matrix+mp_complex.cxx instantiation is likely to compile without any modifications to vnl_matrix. The errors you encountered may cause by: 1. the vcl_complex<double> typo in class vnl_numeric_traits< mp_complex >. 2. Missing the definition of mp_real and/or mp_complex. In your vnl_matrix+mp_complex.cxx, please try the following: #include <mp_complex.h> #include <vnl/vnl_matrix.txx> VNL_MATRIX_INSTANTIATE(mp_complex); The order of header files does matter. Gehua Riccardo Lattanzi wrote: >Hi, > >Thanks for your suggestion. >I added the specialization on vnl_numeric_traits but that caused >new error to arise. >I did the vnl_numeric_traits<mp_complex> and vnl_numeric_traits<mp_real> >adding the following to vnl_numeric_traits.h (AND NOTHING TO >vnl_numeric_traits.cxx): > >class vnl_numeric_traits< mp_complex > >{ > public: > //: Additive identity > static const mp_complex zero; > //: Multiplicative identity > static const mp_complex one; > // Maximum value which this type can assume; makes no sense for this type > //static const vcl_complex<double> maxval; > > //: Return value of abs() > typedef mp_real abs_t; > //: Name of a type twice as long as this one for accumulators and products. > typedef mp_complex double_t; > //: Name of type which results from multiplying this type with a double > typedef mp_complex real_t; >}; > >class vnl_numeric_traits< mp_real > >{ > public: > //: Additive identity > static const mp_real zero; > //: Multiplicative identity > static const mp_real one; > //: Maximum value which this type can assume > static const mp_real maxval; > //: Return value of abs() > typedef mp_real abs_t; > //: Name of a type twice as long as this one for accumulators and products. > typedef mp_real double_t; > //: Name of type which results from multiplying this type with a double > typedef mp_real real_t; >}; > >That seemed to work per se but lead to many errors when I rebuilt vnl. >There are some member functions in vnl_matrix.txx (i.e. normalize_rows, >normalize_columns, operator_one,_norm,....) that use some functions which are >not templated and expect vcl_complex<double> (i.e. vnl_math_squared_magnitude, >vnl_math_abs, vnl_matlab_isfinite,...). >I tried to work around that commenting out the member functions of vnl_matrix >which were causing problems (not very elegant, but if I can build at least I >could try to write examples with vnl_matrix<mp_complex>). >Using such "cheating" I got rid of most of the errors. >The remaining ones are related to the file vnl_unary_function_h which I think >doesn't work because it searches for the limits of mp_complex and mp_real in >vcl_numeric_limits. (at the end of the email I'm attaching the error message) > >Is something I did wrong when adding the specialization on vnl_numeric_traits.h >? >I don't think I'm ready to solve that problem without the guide of some Vxl >devoloper. >Can you please help me with this? > >Thanks a lot, >Riccardo Lattanzi > > >Error Message: > >Configuration: vnl  Win32 Release >Compiling... >vnl_unary_function+double.vnl_vector+double.cxx >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' >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(32) : error C2059: syntax error >: '::' > 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' >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : 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_max(void) >const' >D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : error C2059: syntax error >: '::' > 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_max(void) >const' >Error executing cl.exe. > >vnl.lib  4 error(s), 2 warning(s) > > > 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050412 21:32:09

Hi, thanks again for your help. I'm sorry for being not enough specific in the previous email. I'll try to explain better stepbystep the error I find. Quoting Gehua Yang <yangg2@...>: > In your class vnl_numeric_traits< mp_complex >, I believe you forgot to > change the type of maxval. > Thanks, I fixed that, but it was a commented line so didn't make any better. vnl_numeric_traits.cxx compiles without errors and I checked for the files for explicit instantiation which are fine. The error is somewhere else and I think it has to do with the file vcl_limit.h in which the class vcl_numeric_limits is defined. 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? 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. 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). DOES ANYBODY KNOW WHAT I'M DOING WRONG? COULD BE A PROBLEM THE FACT THAT mp_real ID DECLARED IN mpreal.h AND NOT mp_real.h ? (I don't think so, but since it doesn't respect the vnl convention I'm not sure if any automatic building mechanisms are effected). Let me know if I missed any information useful for understanding the problem. Thanks a lot. Riccardo  Error message present in all steps (except 1) 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' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(32) : error C2059: syntax error : '::' 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' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : 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_max(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_unary_function.txx(39) : error C2059: syntax error : '::' 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_max(void) const'  Error message in addition to the previous one (only in step 2): vnl_matrix+mp_complex.cxx D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(864) : error C2665: 'vnl_math_squared_magnitude' : none of the 9 overloads can convert parameter 1 from type 'class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::normalize_rows(void)' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(867) : error C2665: 'vcl_sqrt' : none of the 3 overloads can convert parameter 1 from type 'class mp_real' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::normalize_rows(void)' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(885) : error C2665: 'vnl_math_squared_magnitude' : none of the 9 overloads can convert parameter 1 from type 'class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::normalize_columns(void)' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(888) : error C2665: 'vcl_sqrt' : none of the 3 overloads can convert parameter 1 from type 'class mp_real' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::normalize_columns(void)' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1372) : error C2665: 'vnl_math_abs' : none of the 13 overloads can convert parameter 1 from type 'class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_real __thiscall vnl_matrix<class mp_complex>::operator_one_norm(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1389) : error C2665: 'vnl_math_abs' : none of the 13 overloads can convert parameter 1 from type 'class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_real __thiscall vnl_matrix<class mp_complex>::operator_inf_norm(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1090) : error C2665: 'vnl_math_abs' : none of the 13 overloads can convert parameter 1 from type 'class mp_complex_temp' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'bool __thiscall vnl_matrix<class mp_complex>::is_identity(double) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1090) : error C2665: 'vnl_math_abs' : none of the 13 overloads can convert parameter 1 from type 'class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'bool __thiscall vnl_matrix<class mp_complex>::is_identity(double) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1115) : error C2665: 'vnl_math_abs' : none of the 13 overloads can convert parameter 1 from type 'const class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'bool __thiscall vnl_matrix<class mp_complex>::is_zero(double) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1139) : error C2665: 'vnl_math_isfinite' : none of the 12 overloads can convert parameter 1 from type 'const class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'bool __thiscall vnl_matrix<class mp_complex>::is_finite(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1127) : error C2665: 'vnl_math_isnan' : none of the 12 overloads can convert parameter 1 from type 'const class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'bool __thiscall vnl_matrix<class mp_complex>::has_nans(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1164) : error C2665: 'vnl_math_isfinite' : none of the 12 overloads can convert parameter 1 from type 'const class mp_complex' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::assert_finite_internal(void) const' D:\Vxl\vxl1.1.0\core\vnl/vnl_matrix.txx(1164) : fatal error C1903: unable to recover from previous error(s); stopping compilation C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __thiscall vnl_matrix<class mp_complex>::assert_finite_internal(void) const' vnl_matrix+mp_real.cxx (SAME AS FOR mp_complex) 
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 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050413 19:08:27

Quoting Gehua Yang <yangg2@...>: > > > 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. > Hi, thanks again. I tried to implement your suggestion bu it seems the error is still there. Here is what I've done: I subs vcl_sqrt with vnl_math_sqrt and I declared inline vnl_math_sqrt in vnl_math.h in a way that allows me to avoid errors (not a definitive declarartion: the function doesn't do anything). I added the files: vnl_mpreal_traits.h vnl_mpreal_traits.cxx vnl_mpcomplex_traits.h vnl_mpcomplex_traits.cxx vnl_matrix+mp_real.cxx vnl_matrix+mp_complex.cxx which are adaptation of vnl_rational_traits.h, vnl_rational_traits.h and vnl_matrix+vnl_rational.cxx to the cases of mp_complex and mp_real. However I still get the usual errors related to vnl_unary_function...maybe I need an adhoc specialization of vnl_unary_function. In fact know it gives the error right after vnl_unary_function+double.vnl_vector+double.cxx, which shouldn't be related to mp_complex and mp_real. WHAT DO YOU THINK? If anybody wants to try by himself, the multiprecision library can be downloaded at http://crd.lbl.gov/~dhbailey/mpdist/ and it's a very small package. > 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? > You're right and I'm planning to repeat everything on GCC as soon as I have sometime. Thanks a lot, Riccardo 
From: Gehua Yang <yangg2@rp...>  20050413 19:28:37

Riccardo Lattanzi wrote: >I added the files: >vnl_mpreal_traits.h >vnl_mpreal_traits.cxx >vnl_mpcomplex_traits.h >vnl_mpcomplex_traits.cxx >vnl_matrix+mp_real.cxx >vnl_matrix+mp_complex.cxx > > > Did you try to manually compile these files? If you are able to get these compiled, then we are very close to success. >However I still get the usual errors related to vnl_unary_function...maybe I >need an adhoc specialization of vnl_unary_function. >In fact know it gives the error right after >vnl_unary_function+double.vnl_vector+double.cxx, >which shouldn't be related to mp_complex and mp_real. WHAT DO YOU THINK? > > > Could you also try to generate a preprocessed file on vnl_unary_function+double.vnl_vector+double.cxx? Just rightclick the vnl project, choose Property, expand C/C++, click preprocessor, and turn on generate preprocessed file. (I only have VC7. It should be similar though) After you compile vnl_unary_function+double.vnl_vector+double.cxx file, vnl_unary_function+double.vnl_vector+double.o should be the output of preprocessor. I would like to take a look at it. >If anybody wants to try by himself, the multiprecision library can >be downloaded at http://crd.lbl.gov/~dhbailey/mpdist/ and it's a very small >package. > > > > 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050413 21:03:16

Good news! I was able to build vnl.lib. However, I used some tricks. I first compiled the files by themselves and to quickly get rid of the errors I commented out 4 functions on vnl_matrix.txx that were causing errors (those are functions I don't need directly for my purposes but some other routines may invoke them, so I'll need to check). Another thing I did was avoiding to use vcl_sqrt, so my vnl_mpcomplex_traits (same thing on vnl_mpreal_traits)is: #include "vnl_mpcomplex_traits.h" #include <mp/mpcomplex.h> #include <mp/mpreal.h> #include <vcl_cmath.h> const mp_complex vnl_numeric_traits<mp_complex>::zero = mp_complex(0.0,0.0); const mp_complex vnl_numeric_traits<mp_complex>::one = mp_complex(1.0,1.0); const mp_complex vnl_numeric_traits<mp_complex>::maxval = mp_complex(1E+308,1E+308); mp_real vnl_math_squared_magnitude(mp_complex const& x) { return x.real*x.real+x.imag*x.imag; } mp_real vnl_math_abs(mp_complex const& x) { //return mp_real(vcl_sqrt(double(x.real*x.real+x.imag*x.imag))); mp_real fake(1.0); return fake; } vcl_ostream& operator<<(vcl_ostream& os, mp_complex x) { return os << x.real << '+' << x.imag << 'j'; } You said you will write a vnl_math_sqrt: would it be an inline function with all the specialization that would go in vnl_math.h ?. I guess at that point I would need to download a more recent version of Vxl form CVS. I'll try to use the library and also to fix the errors given by the 4 member functions of vnl_matrix. Hopes that everything will work. Thanks. Riccardo 
From: Gehua Yang <yangg2@rp...>  20050413 22:08:02

Riccardo Lattanzi wrote: >Good news! I was able to build vnl.lib. > > Congratulations! This is a great news. >However, I used some tricks. >I first compiled the files by themselves and to quickly get rid of the errors I >commented out 4 functions on vnl_matrix.txx that were causing errors (those are >functions I don't need directly for my purposes but some other routines may >invoke them, so I'll need to check). >Another thing I did was avoiding to use vcl_sqrt, so my vnl_mpcomplex_traits >(same thing on vnl_mpreal_traits)is: > >#include "vnl_mpcomplex_traits.h" >#include <mp/mpcomplex.h> >#include <mp/mpreal.h> >#include <vcl_cmath.h> > >const mp_complex vnl_numeric_traits<mp_complex>::zero = mp_complex(0.0,0.0); >const mp_complex vnl_numeric_traits<mp_complex>::one = mp_complex(1.0,1.0); >const mp_complex vnl_numeric_traits<mp_complex>::maxval = >mp_complex(1E+308,1E+308); > >mp_real vnl_math_squared_magnitude(mp_complex const& x) >{ > return x.real*x.real+x.imag*x.imag; >} >mp_real vnl_math_abs(mp_complex const& x) >{ > //return mp_real(vcl_sqrt(double(x.real*x.real+x.imag*x.imag))); > mp_real fake(1.0); > return fake; > >} > >vcl_ostream& operator<<(vcl_ostream& os, mp_complex x) { > return os << x.real << '+' << x.imag << 'j'; >} > > >You said you will write a vnl_math_sqrt: would it be an inline >function with all the specialization that would go in vnl_math.h ?. > > It will likely be a template function with specializations for mp_real type. >I guess at that point I would need to download a more recent version of >Vxl form CVS. > > > Yes, Please download the CVS version. 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050413 22:35:19

> >Good news! I was able to build vnl.lib. > > > > > Congratulations! This is a great news. > I tried to build a testing example but I got a strange message. So I checked deeper and it seems that nothing with mpreal.h works anymore. I rebuilt arprec and everything worked. When I tried to build the simpliest application: #include <mp/mpreal.h> int main () { return 0; } The error is: error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@@QAE@...) I don't what that error means in this case. Could the building of vnl.lib have caused that? Best Regards, Riccardo 
From: Gehua Yang <yangg2@rp...>  20050414 15:54:40

>I tried to build a testing example but I got a strange message. >So I checked deeper and it seems that nothing with mpreal.h works anymore. > >I rebuilt arprec and everything worked. >When I tried to build the simpliest application: >#include <mp/mpreal.h> >int main () >{ >return 0; >} > >The error is: >error LNK2001: unresolved external symbol "__declspec(dllimport) public: >__thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@@QAE@...) > >I don't what that error means in this case. >Could the building of vnl.lib have caused that? > >Best Regards, >Riccardo > > > > Besides including the header files, you also need to link against mpreal library. Change the line in core/vnl/CMakeLists.txt from TARGET_LINK_LIBRARIES( vnl vcl ) to TARGET_LINK_LIBRARIES( vnl vcl mpreal) I don't know what's the real name of the library. Here I use "mpreal" as an example. Please correct it for the real name. Also, make sure the library is in the search path. One easy way to experiment is to copy the "mpreal.lib" into your vxlbin/lib directory. Gehua 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050415 16:41:50

> Besides including the header files, you also need to link against mpreal > library. > > Change the line in core/vnl/CMakeLists.txt from > TARGET_LINK_LIBRARIES( vnl vcl ) > to > TARGET_LINK_LIBRARIES( vnl vcl mpreal) > I did that, adding arprec.lib to the appropriate folder. I add a new project to vxl workspace, I wrote a sample application using only arprec and everything worked. However, if I add to the code just the line vnl_matrix<double> test_mat I get 7 errors (pasted below). If I add instead vnl_matrix<mp_real> test_mat I get 26 errors...I guess the 2 libraries don't like to work together. But my main problem now is that ARPREC DOESN'T WORK ANYWHERE RATHER THAN IN A PROJECT INSIDE VXL...HOW CAN I FIX THAT WITHOUT REINSTALLING EVERYTHING? The error (if using arprec outside vxl workspace) is: error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@@QAE@...) Could you please help me with this? Thanks a lot, Riccardo **************************************************************************** ERROR AFTER ADDING vnl_matrix<double> test_mat TO A SAMPLE APPLICATION USING ARPREC **************************************************************************** sample code: #include <vnl/vnl_matrix.h> #include <mp/mpreal.h> int main() { mp::mp_init(300); mp_real a, b(2.0); vnl_matrix<double> test; a = sqrt(b); cout << "sqrt(2) = " << a << endl; mp::mp_finalize(); return 0; } Configuration: vnl_test_arprec  Win32 Release Compiling... vnl_test_arprec.cpp Linking... msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::ios_base::Init::Init(void)" (??0Init@...@std@@QAE@...) already defined in libcp.lib(iostream.obj) msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::ios_base::Init::~Init(void)" (??1Init@...@std@@QAE@...) already defined in libcp.lib(iostream.obj) msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::_Winit::_Winit(void)" (??0_Winit@...@@QAE@...) already defined in libcp.lib(wiostrea.obj) msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::_Winit::~_Winit(void)" (??1_Winit@...@@QAE@...) already defined in libcp.lib(wiostrea.obj) msvcprt.lib(MSVCP60.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??6std@@YAAAV?$basic_ostream@...?$char_ traits@...@std@@@0@...@PBD@...) already defined in vnl_test_arprec.obj MSVCRT.lib(MSVCRT.dll) : error LNK2005: _abort already defined in LIBC.lib(abort.obj) LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library Release/vnl_test_arprec.exe : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe. 
From: Gehua Yang <yangg2@rp...>  20050415 17:06:19

As you add a project into VXL workspace, have you ensured they are using the same sets of libraries? Please refer to this email archive for details: http://sourceforge.net/mailarchive/message.php?msg_id=6473201 Gehua Riccardo Lattanzi wrote: >>Besides including the header files, you also need to link against mpreal >>library. >> >>Change the line in core/vnl/CMakeLists.txt from >> TARGET_LINK_LIBRARIES( vnl vcl ) >>to >> TARGET_LINK_LIBRARIES( vnl vcl mpreal) >> >> >> > >I did that, adding arprec.lib to the appropriate folder. >I add a new project to vxl workspace, I wrote a sample application >using only arprec and everything worked. >However, if I add to the code just the line >vnl_matrix<double> test_mat >I get 7 errors (pasted below). If I add instead >vnl_matrix<mp_real> test_mat >I get 26 errors...I guess the 2 libraries don't like to work together. >But my main problem now is that ARPREC DOESN'T WORK ANYWHERE RATHER >THAN IN A PROJECT INSIDE VXL...HOW CAN I FIX THAT WITHOUT REINSTALLING >EVERYTHING? >The error (if using arprec outside vxl workspace) is: >error LNK2001: unresolved external symbol "__declspec(dllimport) public: >__thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@@QAE@...) > >Could you please help me with this? >Thanks a lot, > >Riccardo > >**************************************************************************** >ERROR AFTER ADDING vnl_matrix<double> test_mat TO A SAMPLE APPLICATION USING >ARPREC >**************************************************************************** >sample code: > >#include <vnl/vnl_matrix.h> >#include <mp/mpreal.h> > >int main() { > mp::mp_init(300); > mp_real a, b(2.0); > vnl_matrix<double> test; > a = sqrt(b); > cout << "sqrt(2) = " << a << endl; > > mp::mp_finalize(); > return 0; >} > > >Configuration: vnl_test_arprec  Win32 >Release >Compiling... >vnl_test_arprec.cpp >Linking... >msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall >std::ios_base::Init::Init(void)" (??0Init@...@std@@QAE@...) already defined >in libcp.lib(iostream.obj) >msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall >std::ios_base::Init::~Init(void)" (??1Init@...@std@@QAE@...) already >defined in libcp.lib(iostream.obj) >msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall >std::_Winit::_Winit(void)" (??0_Winit@...@@QAE@...) already defined in >libcp.lib(wiostrea.obj) >msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall >std::_Winit::~_Winit(void)" (??1_Winit@...@@QAE@...) already defined in >libcp.lib(wiostrea.obj) >msvcprt.lib(MSVCP60.dll) : error LNK2005: "class std::basic_ostream<char,struct >std::char_traits<char> > & __cdecl std::operator<<(class >std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" >(??6std@@YAAAV?$basic_ostream@...?$char_ >traits@...@std@@@0@...@PBD@...) already defined in vnl_test_arprec.obj >MSVCRT.lib(MSVCRT.dll) : error LNK2005: _abort already defined in >LIBC.lib(abort.obj) >LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; >use /NODEFAULTLIB:library >Release/vnl_test_arprec.exe : fatal error LNK1169: one or more multiply defined >symbols found >Error executing link.exe. > > > > > >SF email is sponsored by  The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >_______________________________________________ >Vxlusers mailing list >Vxlusers@... >https://lists.sourceforge.net/lists/listinfo/vxlusers > > > > 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050415 20:07:01

Quoting Gehua Yang <yangg2@...>: > As you add a project into VXL workspace, have you ensured they are using > the same sets of libraries? Please refer to this email archive for details: > http://sourceforge.net/mailarchive/message.php?msg_id=6473201 > > Gehua > Thanks, that was indeed the problem. I discovered that to use vnl_matrix<mp_complex> mp_complex need to work also with vnl_vector and therefore with vnl_c_vector...it seems an overwhelming amount of work for me now (if you know a shortcut to get rid of these problems please let me know). So I need to stop my project for a while. Thanks for your assistant and to guide me to a better understing of Vxl. Best, Riccardo 
From: Gehua Yang <yangg2@rp...>  20050415 20:56:39

Riccardo Lattanzi wrote: >Thanks, that was indeed the problem. >I discovered that to use vnl_matrix<mp_complex> mp_complex need >to work also with vnl_vector and therefore with vnl_c_vector...it seems >an overwhelming amount of work for me now (if you know a shortcut to >get rid of these problems please let me know). >So I need to stop my project for a while. > >Thanks for your assistant and to guide me to a better understing >of Vxl. > > > > Could you try one more thing: add vnl_vector<mp_complex> and vnl_c_vector<mp_complex> instantiation file and compile them? I just skimmed through vnl_vector.txx and vnl_c_vector.txx. It looks like vnl_vector<mp_complex> should pass given the changes you have made so far. vnl_c_vector<mp_complex> may not because of issues related to vnl_complex_traits. I just want to get an idea how far it is from success. Thanks. Gehua 
From: Riccardo Lattanzi <lattanzi@MIT.EDU>  20050415 22:07:34

> Could you try one more thing: add vnl_vector<mp_complex> and > vnl_c_vector<mp_complex> instantiation file and compile them? I just > skimmed through vnl_vector.txx and vnl_c_vector.txx. It looks like > vnl_vector<mp_complex> should pass given the changes you have made so > far. vnl_c_vector<mp_complex> may not because of issues related to > vnl_complex_traits. I just want to get an idea how far it is from success. > > Thanks. > Gehua Indeed vnl_vector doesn't give any problem. The errors arise from vnl_c_vector and are partly related to vnl_complex_traits. For semplicity I'm pasting only the case of mp_complex (not of mp_real). If you think that it's something easy and not very long, I can try. Thanks, Riccardo In order to try to build I used some tricks and here is what I did before building vnl.lib and what happened: 1 added: vnl_vector+mp_complex.cxx vnl_c_vector+mp_complex.cxx 2 commented out the following function in vnl_vector.txx: cos_angle(vnl_vector<T> const& a, vnl_vector<T> const& b) angle (vnl_vector<T> const& a, vnl_vector<T> const& b) is_finite() (they were using vcl_sqrt or other function not specialized for mp_complex) 3 changed the following lines from vnl_c_vector.h line 112 static inline real_t std(T const *p, unsigned n) { return 0 ;} // it was: // return vcl_sqrt(real_t(sum_sq_diff_means(p, n))/real_t(abs_t(n1)));} 4 changed the following lines from vnl_c_vector.txx line 37 // tmp = abs_t(real_t(1) / vcl_sqrt(real_t(tmp))); (coomented out) (because of type casting problems) 5 After these notsodangerous changes the errors for vnl.lib are: vnl_c_vector+mp_complex.cxx D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(37) : error C2440: 'type cast' : cannot convert from 'class mp_complex' to 'double' No userdefinedconversion operator available that can perform this conversion, or the operator cannot be called C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __cdecl vnl_c_vector<class mp_complex>::normalize(class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(163) : error C2678: binary '' : no operator defined which takes a lefthand operand of type 'const class mp_complex' (or there is no acceptable conversion) C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __cdecl vnl_c_vector<class mp_complex>::negate(const class mp_complex *,class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(213) : error C2027: use of undefined type 'vnl_complex_traits<class mp_complex>' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::inner_product(const class mp_complex *,const class mp_complex *,uns igned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(213) : error C2660: 'conjugate' : function does not take 1 parameters C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::inner_product(const class mp_complex *,const class mp_complex *,uns igned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(221) : error C2027: use of undefined type 'vnl_complex_traits<class mp_complex>' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __cdecl vnl_c_vector<class mp_complex>::conjugate(const class mp_complex *,class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(221) : error C2660: 'conjugate' : function does not take 1 parameters C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'void __cdecl vnl_c_vector<class mp_complex>::conjugate(const class mp_complex *,class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(232) : error C2678: binary '>' : no operator defined which takes a lefthand operand of type 'const class mp_complex' (or there is no acceptable conversion) C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::max_value(const class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(243) : error C2678: binary '<' : no operator defined which takes a lefthand operand of type 'const class mp_complex' (or there is no acceptable conversion) C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xstring(583) : while compiling classtemplate member function 'class mp_complex __cdecl vnl_c_vector<class mp_complex>::min_value(const class mp_complex *,unsigned int)' D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(320) : error C2593: 'operator =' is ambiguous D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(119) : see reference to function template instantiation 'void __cdecl vnl_c_vector_one_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(331) : error C2440: 'type cast' : cannot convert from 'class mp_complex' to 'double' No userdefinedconversion operator available that can perform this conversion, or the operator cannot be called D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(123) : see reference to function template instantiation 'void __cdecl vnl_c_vector_two_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(337) : error C2593: 'operator =' is ambiguous D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(127) : see reference to function template instantiation 'void __cdecl vnl_c_vector_inf_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(341) : error C2678: binary '>' : no operator defined which takes a lefthand operand of type 'class mp_complex' (or there is no acceptable conversion) D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(127) : see reference to function template instantiation 'void __cdecl vnl_c_vector_inf_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(312) : error C2593: 'operator /=' is ambiguous D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(135) : see reference to function template instantiation 'void __cdecl vnl_c_vector_rms_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.txx(314) : error C2440: 'type cast' : cannot convert from 'class mp_complex' to 'double' No userdefinedconversion operator available that can perform this conversion, or the operator cannot be called D:\Vxl\vxl1.1.0\core\vnl/vnl_c_vector.h(135) : see reference to function template instantiation 'void __cdecl vnl_c_vector_rms_norm(const class mp_complex *,unsigned int,class mp_complex *)' being compiled 