Today I begin to learn to use boost ublas.
And I have successfully done svd for a real matrix. To do svd for a
complex matrix, I simply change codes from double to std::complex like
the following.
But it does not work.
#include <boost/numeric/bindings/lapack/gesdd.hpp>
#include<boost/numeric/bindings/traits/ublas_matrix.hpp>
#include<boost/numeric/bindings/traits/ublas_vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
int main()
{
using namespace boost::numeric::bindings::lapack;
using namespace boost::numeric::ublas;
matrix<std::complex<double>, column_major> A (4,2);
A(0,0)=std::complex<double>(2, 5);
A(0,1)=4;
A(1,0)=1;
A(1,1)=3;
A(2,0)=0;
A(2,1)=0;
A(3,0)=0;
A(3,1)=0;
std::cout << A << std::endl;
matrix<std::complex<double>, column_major> U(4,4);
matrix<std::complex<double>, column_major> V(2,2);
vector<std::complex<double>> S(2);
gesdd(A, S, U, V);
std::cout << U << std::endl;
std::cout << S << std::endl;
std::cout << V << std::endl;
return 0;
}
When compiles the program, MSVC8 will tell that it found no gesdd
method for complex type arguments.
Please help me.
Thanks
Allen
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Allen Chen wrote:
> Today I begin to learn to use boost ublas.
There is also a mailing list especially for boost ublas.
> And I have successfully done svd for a real matrix.
> To do svd for a complex matrix, I simply change codes
> from double to std::complex like the following.
> But it does not work.
The singular values "S" are still real, even for a complex matrix. So you should write "vector<double> S(2);" instead of "vector<std::complex<double>> S(2);".
Regards,
Thomas
Thanks! I will join the mailing list.
>
>> And I have successfully done svd for a real matrix.
>> To do svd for a complex matrix, I simply change codes
>> from double to std::complex like the following.
>> But it does not work.
>
> The singular values "S" are still real, even for a complex matrix. So you should write "vector<double> S(2);" instead of "vector<std::complex<double>> S(2);".
>
Oh, that's great, it does work now.
I forget the thing that singual value is already real.
Thank you very much.
Merry christmas!
Allen
> Regards,
> Thomas