2001: 2002: 2003: 2004: 2005: 2006: 2007: 2008: 2009: 2010: 2011: 2012: Jan Feb Mar Apr May Jun Jul Aug Sep Oct (8) Nov (8) Dec (4) Jan (53) Feb (15) Mar (51) Apr (54) May (41) Jun (48) Jul (32) Aug (22) Sep (61) Oct (31) Nov (31) Dec (27) Jan (45) Feb (18) Mar (25) Apr (39) May (34) Jun (20) Jul (13) Aug (16) Sep (18) Oct (14) Nov (17) Dec (13) Jan (53) Feb (12) Mar (38) Apr (29) May (72) Jun (38) Jul (41) Aug (11) Sep (21) Oct (30) Nov (35) Dec (14) Jan (66) Feb (14) Mar (24) Apr (50) May (40) Jun (29) Jul (37) Aug (27) Sep (26) Oct (58) Nov (43) Dec (23) Jan (84) Feb (36) Mar (24) Apr (42) May (20) Jun (41) Jul (40) Aug (42) Sep (23) Oct (38) Nov (31) Dec (28) Jan (11) Feb (34) Mar (14) Apr (29) May (45) Jun (5) Jul (10) Aug (6) Sep (38) Oct (44) Nov (19) Dec (22) Jan (37) Feb (24) Mar (29) Apr (14) May (24) Jun (47) Jul (26) Aug (4) Sep (14) Oct (45) Nov (25) Dec (16) Jan (33) Feb (34) Mar (45) Apr (45) May (30) Jun (47) Jul (37) Aug (19) Sep (15) Oct (16) Nov (24) Dec (31) Jan (32) Feb (25) Mar (12) Apr (5) May (2) Jun (9) Jul (31) Aug (10) Sep (12) Oct (20) Nov (6) Dec (41) Jan (23) Feb (8) Mar (41) Apr (8) May (15) Jun (10) Jul (8) Aug (14) Sep (16) Oct (13) Nov (15) Dec (8) Jan (6) Feb (14) Mar (22) Apr (40) May (27) Jun (18) Jul (2) Aug (6) Sep (10) Oct (32) Nov (5) Dec (2) Jan (14) Feb (2) Mar (15) Apr (2) May (6) Jun (7) Jul (25) Aug (6) Sep (3) Oct Nov (8) Dec
 [Vxl-users] complex matrices, multiprecision data types From: Riccardo Lattanzi - 2005-01-10 22:24 Hi, A friend of mine has just introduced me to VNL, but I'm not sure if I'll be able to use it as-is 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 ---------------------------------------------------------

 Re: [Vxl-users] complex matrices, multiprecision data types From: Ian Scott - 2005-01-11 13:21 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 as-is 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 > 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 > 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 and complex types. Writing a basic LU decomposition based class would be possible. Ian.

 Re: [Vxl-users] complex matrices, multiprecision data types From: Riccardo Lattanzi - 2005-01-11 17:02 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 > > > 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 and complex > 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 re-definition of the basic arithmetic operators to smartly handle the new type. I could write my own "matrix-inverter" 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 type-specific operators instead of the standard + - * / ? Or do you suggest to write my own LU decomposition using the ARPREC library? Thank for your help. Riccardo

 Re: [Vxl-users] complex matrices, multiprecision data types From: Ian Scott - 2005-04-05 13:02 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 >>#include >>#include >>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, you can implicitly instantiate vcl_pair by using vcl_pair, 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; which will include all the code associated vcl_pair, specialised for 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, we have template instatiation file e.g. vnl/Templates/vnl_matrix+double-.cxx, that invokes the macro appropriately, e.g. #include 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.

 Re: [Vxl-users] complex matrices, multiprecision data types From: Gehua Yang - 2005-04-08 22:02 The vnl_numeric_traits 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 >. I believe it won't take more than 10 minutes. By the way, I notice your directory name is vxl-1.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 re-build just vnl >from VisualC++6 I get this error both for vnl_matrix >and vnl_vector: > >----------------------------------------------------------------------------- >vnl_vector+mp_complex-.cxx >D:\Vxl\vxl-1.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\vxl-1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling >class-template member function 'class mp_complex __cdecl vnl_c_vectormp_complex>::mean(const class mp_complex *,unsigned int)' >------------------------------------------------------------------------------- >vnl_matrix+mp_complex-.cxx >D:\Vxl\vxl-1.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\vxl-1.1.0\core\vnl/vnl_c_vector.h(105) : while compiling >class-template member function 'class mp_complex __cdecl vnl_c_vectormp_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 > > > > > >

 Re: [Vxl-users] complex matrices, multiprecision data types From: Riccardo Lattanzi - 2005-04-13 19:08 Quoting Gehua Yang : > > > One example you could look at is vnl_matrix+vnl_rational-.cxx, which > include vnl_rational_traits.h. vnl_rational is also a non-standard > 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. 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 ad-hoc 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

 Re: [Vxl-users] complex matrices, multiprecision data types From: Gehua Yang - 2005-04-13 19:28 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 ad-hoc 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 right-click 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. > > > >

 Re: [Vxl-users] complex matrices, multiprecision data types From: Riccardo Lattanzi - 2005-04-13 21:03 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 #include #include const mp_complex vnl_numeric_traits::zero = mp_complex(0.0,0.0); const mp_complex vnl_numeric_traits::one = mp_complex(1.0,1.0); const mp_complex vnl_numeric_traits::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

 Re: [Vxl-users] complex matrices, multiprecision data types From: Gehua Yang - 2005-04-13 22:08 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 >#include >#include > >const mp_complex vnl_numeric_traits::zero = mp_complex(0.0,0.0); >const mp_complex vnl_numeric_traits::one = mp_complex(1.0,1.0); >const mp_complex vnl_numeric_traits::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.

 Re: [Vxl-users] complex matrices, multiprecision data types From: Riccardo Lattanzi - 2005-04-13 22:35 > >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 int main () { return 0; } The error is: error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@...) I don't what that error means in this case. Could the building of vnl.lib have caused that? Best Regards, Riccardo

 Re: [Vxl-users] complex matrices, multiprecision data types From: Gehua Yang - 2005-04-14 15:54 >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 >int main () >{ >return 0; >} > >The error is: >error LNK2001: unresolved external symbol "__declspec(dllimport) public: >__thiscall mp_real::~mp_real(void)" (__imp_??1mp_real@...) > >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