Boost logo

Ublas :

Subject: Re: [ublas] problem regards to using boost binding library for svd in lapack under vc 9.0
From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2009-04-22 08:58:36


* ZGESVD computes the singular value decomposition (SVD) of a complex
* M-by-N matrix A, optionally computing the left and/or right singular
* vectors. The SVD is written
*
* A = U * SIGMA * conjugate-transpose(V)
*
* where SIGMA is an M-by-N matrix which is zero except for its
* min(m,n) diagonal elements, U is an M-by-M unitary matrix, and
* V is an N-by-N unitary matrix. The diagonal elements of SIGMA
* are the singular values of A; they are real and non-negative, and
* are returned in descending order. The first min(m,n) columns of
* U and V are the left and right singular vectors of A.
*
* Note that the routine returns V**H, not V.
*
* Arguments
* =========
*
* JOBU (input) CHARACTER*1
* Specifies options for computing all or part of the matrix U:
* = 'A': all M columns of U are returned in array U:
* = 'S': the first min(m,n) columns of U (the left singular
* vectors) are returned in the array U;
* = 'O': the first min(m,n) columns of U (the left singular
* vectors) are overwritten on the array A;
* = 'N': no columns of U (no left singular vectors) are
* computed.
*
* JOBVT (input) CHARACTER*1
* Specifies options for computing all or part of the matrix
* V**H:
* = 'A': all N rows of V**H are returned in the array VT;
* = 'S': the first min(m,n) rows of V**H (the right singular
* vectors) are returned in the array VT;
* = 'O': the first min(m,n) rows of V**H (the right singular
* vectors) are overwritten on the array A;
* = 'N': no rows of V**H (no right singular vectors) are
* computed.
*
* JOBVT and JOBU cannot both be 'O'.

ianshu Zhang wrote:
> Hi, Thomas,
>
> Thanks for your guide. Now the svd works for me now.
>
> However, there is one thing confused me. The following codes will give
> an assertion fail until I specify the svd function to gesdd('A',A, S,
> U, V) or gesdd(A, S). Therefore I'm confused by the jobz option. Can
> somebody simply explain about the "O","N","A","S" option?
>
> #define BOOST_NUMERIC_BINDINGS_USE_CLAPACK
> //#define BIND_FORTRAN_LOWERCASE_UNDERSCORE
>
> #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>
> #include <boost/numeric/ublas/io.hpp>
> #include <iostream>
> #include <complex>
>
>
> 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>(1, 2);
> A(0,1)=std::complex<double>(3, 4);
> A(1,0)=std::complex<double>(5, 6);
> A(1,1)=std::complex<double>(7, 8);
> A(2,0)=std::complex<double>(9, 10);
> A(2,1)=std::complex<double>(11, 12);
> A(3,0)=std::complex<double>(13, 14);
> A(3,1)=std::complex<double>(15, 16);
>
> std::cout << A << std::endl;
>
> matrix<std::complex<double>, column_major> U(4,4);
> matrix<std::complex<double>, column_major> V(2,2);
> vector<double> S(2);
>
> gesdd(A, S, U, V);
> //gesdd(A, S);
>
> std::cout << U << std::endl;
> std::cout << S << std::endl;
> std::cout << V << std::endl;
> std::cin.get();
> return 0;
> }
>
> BRs,
>
>
> Get news, entertainment and everything you care about at Live.com.
> Check it out! <http://www.live.com/getstarted.aspx%20>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>