32 #ifndef __VMML__VMMLIB_LAPACK_SVD__HPP__
33 #define __VMML__VMMLIB_LAPACK_SVD__HPP__
35 #include <vmmlib/matrix.hpp>
36 #include <vmmlib/vector.hpp>
37 #include <vmmlib/exception.hpp>
39 #include <vmmlib/lapack_types.hpp>
40 #include <vmmlib/lapack_includes.hpp>
78 template<
typename float_t >
96 friend std::ostream& operator << ( std::ostream& os,
101 <<
" jobvt " << p.jobvt
106 <<
" ldvt " << p.ldvt
107 <<
" lwork " << p.lwork
108 <<
" info " << p.info
117 int dgesvd_(
char *jobu,
char *jobvt, integer *m, integer *n,
118 doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
119 ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork,
124 template<
typename float_t >
127 VMMLIB_ERROR(
"not implemented for this type.", VMMLIB_HERE );
133 svd_call( svd_params< float >& p )
158 svd_call( svd_params< double >& p )
183 template<
size_t M,
size_t N,
typename float_t >
207 bool compute_and_overwrite_input(
218 inline bool test_success( lapack::lapack_int info );
227 template<
size_t M,
size_t N,
typename float_t >
241 p.work =
new float_t;
245 lapack::svd_call( p );
247 p.lwork =
static_cast< lapack::lapack_int
>( p.work[0] );
250 p.work =
new float_t[ p.lwork ];
256 template<
size_t M,
size_t N,
typename float_t >
257 lapack_svd< M, N, float_t >::~lapack_svd()
264 template<
size_t M,
size_t N,
typename float_t >
266 lapack_svd< M, N, float_t >::compute_full(
268 matrix< M, M, float_t >& U,
269 vector< N, float_t >& S,
270 matrix< N, N, float_t >& Vt
275 m_type* AA =
new m_type( A );
285 lapack::svd_call< float_t >( p );
292 template<
size_t M,
size_t N,
typename float_t >
294 lapack_svd< M, N, float_t >::compute(
297 vector< N, float_t >& S,
298 matrix< N, N, float_t >& Vt
303 m_type* AA =
new m_type( A );
313 lapack::svd_call< float_t >( p );
319 template<
size_t M,
size_t N,
typename float_t >
321 lapack_svd< M, N, float_t >::compute_and_overwrite_input(
323 vector< N, float_t >& S
332 lapack::svd_call< float_t >( p );
337 template<
size_t M,
size_t N,
typename float_t >
341 vector< N, float_t >& S )
349 m_type* AA =
new m_type( A );
358 lapack::svd_call< float_t >( p );