Blaze 3.9
gesvd.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_LAPACK_CLAPACK_GESVD_H_
36#define _BLAZE_MATH_LAPACK_CLAPACK_GESVD_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
44#include <blaze/util/Complex.h>
46#include <blaze/util/Types.h>
47
48
49//=================================================================================================
50//
51// LAPACK FORWARD DECLARATIONS
52//
53//=================================================================================================
54
55//*************************************************************************************************
57#if !defined(INTEL_MKL_VERSION)
58extern "C" {
59
60void sgesvd_( char* jobu, char* jobv, blaze::blas_int_t* m, blaze::blas_int_t* n, float* A,
61 blaze::blas_int_t* lda, float* s, float* U, blaze::blas_int_t* ldu, float* V,
62 blaze::blas_int_t* ldv, float* work, blaze::blas_int_t* lwork, blaze::blas_int_t* info,
64void dgesvd_( char* jobu, char* jobv, blaze::blas_int_t* m, blaze::blas_int_t* n, double* A,
65 blaze::blas_int_t* lda, double* s, double* U, blaze::blas_int_t* ldu, double* V,
66 blaze::blas_int_t* ldv, double* work, blaze::blas_int_t* lwork, blaze::blas_int_t* info,
68void cgesvd_( char* jobu, char* jobv, blaze::blas_int_t* m, blaze::blas_int_t* n, float* A,
69 blaze::blas_int_t* lda, float* s, float* U, blaze::blas_int_t* ldu, float* V,
70 blaze::blas_int_t* ldv, float* work, blaze::blas_int_t* lwork, float* rwork,
72void zgesvd_( char* jobu, char* jobv, blaze::blas_int_t* m, blaze::blas_int_t* n, double* A,
73 blaze::blas_int_t* lda, double* s, double* U, blaze::blas_int_t* ldu, double* V,
74 blaze::blas_int_t* ldv, double* work, blaze::blas_int_t* lwork, double* rwork,
76
77}
78#endif
80//*************************************************************************************************
81
82
83
84
85namespace blaze {
86
87//=================================================================================================
88//
89// LAPACK SVD FUNCTIONS (GESVD)
90//
91//=================================================================================================
92
93//*************************************************************************************************
96void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, float* A,
97 blas_int_t lda, float* s, float* U, blas_int_t ldu, float* V,
98 blas_int_t ldv, float* work, blas_int_t lwork, blas_int_t* info );
99
100void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, double* A,
101 blas_int_t lda, double* s, double* U, blas_int_t ldu, double* V,
102 blas_int_t ldv, double* work, blas_int_t lwork, blas_int_t* info );
103
104void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, complex<float>* A,
105 blas_int_t lda, float* s, complex<float>* U, blas_int_t ldu,
107 blas_int_t lwork, float* rwork, blas_int_t* info );
108
109void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, complex<double>* A,
110 blas_int_t lda, double* s, complex<double>* U, blas_int_t ldu,
112 blas_int_t lwork, double* rwork, blas_int_t* info );
114//*************************************************************************************************
115
116
117//*************************************************************************************************
179inline void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, float* A,
180 blas_int_t lda, float* s, float* U, blas_int_t ldu, float* V,
181 blas_int_t ldv, float* work, blas_int_t lwork, blas_int_t* info )
182{
183#if defined(INTEL_MKL_VERSION)
184 BLAZE_STATIC_ASSERT( sizeof( MKL_INT ) == sizeof( blas_int_t ) );
185#endif
186
187 sgesvd_( &jobu, &jobv, &m, &n, A, &lda, s, U, &ldu, V, &ldv, work, &lwork, info
188#if !defined(INTEL_MKL_VERSION)
190#endif
191 );
192}
193//*************************************************************************************************
194
195
196//*************************************************************************************************
258inline void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, double* A,
259 blas_int_t lda, double* s, double* U, blas_int_t ldu, double* V,
260 blas_int_t ldv, double* work, blas_int_t lwork, blas_int_t* info )
261{
262#if defined(INTEL_MKL_VERSION)
263 BLAZE_STATIC_ASSERT( sizeof( MKL_INT ) == sizeof( blas_int_t ) );
264#endif
265
266 dgesvd_( &jobu, &jobv, &m, &n, A, &lda, s, U, &ldu, V, &ldv, work, &lwork, info
267#if !defined(INTEL_MKL_VERSION)
269#endif
270 );
271}
272//*************************************************************************************************
273
274
275//*************************************************************************************************
338inline void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, complex<float>* A,
339 blas_int_t lda, float* s, complex<float>* U, blas_int_t ldu,
340 complex<float>* V, blas_int_t ldv, complex<float>* work,
341 blas_int_t lwork, float* rwork, blas_int_t* info )
342{
343 BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
344
345#if defined(INTEL_MKL_VERSION)
346 BLAZE_STATIC_ASSERT( sizeof( MKL_INT ) == sizeof( blas_int_t ) );
347 BLAZE_STATIC_ASSERT( sizeof( MKL_Complex8 ) == sizeof( complex<float> ) );
348 using ET = MKL_Complex8;
349#else
350 using ET = float;
351#endif
352
353 cgesvd_( &jobu, &jobv, &m, &n, reinterpret_cast<ET*>( A ), &lda, s,
354 reinterpret_cast<ET*>( U ), &ldu, reinterpret_cast<ET*>( V ), &ldv,
355 reinterpret_cast<ET*>( work ), &lwork, rwork, info
356#if !defined(INTEL_MKL_VERSION)
358#endif
359 );
360}
361//*************************************************************************************************
362
363
364//*************************************************************************************************
427inline void gesvd( char jobu, char jobv, blas_int_t m, blas_int_t n, complex<double>* A,
428 blas_int_t lda, double* s, complex<double>* U, blas_int_t ldu,
429 complex<double>* V, blas_int_t ldv, complex<double>* work,
430 blas_int_t lwork, double* rwork, blas_int_t* info )
431{
432 BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
433
434#if defined(INTEL_MKL_VERSION)
435 BLAZE_STATIC_ASSERT( sizeof( MKL_INT ) == sizeof( blas_int_t ) );
436 BLAZE_STATIC_ASSERT( sizeof( MKL_Complex16 ) == sizeof( complex<double> ) );
437 using ET = MKL_Complex16;
438#else
439 using ET = double;
440#endif
441
442 zgesvd_( &jobu, &jobv, &m, &n, reinterpret_cast<ET*>( A ), &lda, s,
443 reinterpret_cast<ET*>( U ), &ldu, reinterpret_cast<ET*>( V ), &ldv,
444 reinterpret_cast<ET*>( work ), &lwork, rwork, info
445#if !defined(INTEL_MKL_VERSION)
447#endif
448 );
449}
450//*************************************************************************************************
451
452} // namespace blaze
453
454#endif
Header file for the complex data type.
Compile time assertion.
Complex data type of the Blaze library.
void gesvd(DenseMatrix< MT1, SO > &A, DenseMatrix< MT2, SO > &U, DenseVector< VT, TF > &s, DenseMatrix< MT3, SO > &V, char jobu, char jobv)
LAPACK kernel for the singular value decomposition (SVD) of the given dense general matrix.
Definition: gesvd.h:1170
int32_t blas_int_t
Signed integer type used in the BLAS/LAPACK wrapper functions.
Definition: Types.h:64
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
size_t fortran_charlen_t
Type of the hidden arguments of character type within a Fortran forward declaration.
Definition: Types.h:186
Header file for basic BLAS type definitions.
Header file for basic type definitions.