LAPACK  3.7.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zgesdd()

lapack_int LAPACKE_zgesdd ( int  matrix_layout,
char  jobz,
lapack_int  m,
lapack_int  n,
lapack_complex_double a,
lapack_int  lda,
double *  s,
lapack_complex_double u,
lapack_int  ldu,
lapack_complex_double vt,
lapack_int  ldvt 
)

Definition at line 36 of file lapacke_zgesdd.c.

41 {
42  lapack_int info = 0;
43  lapack_int lwork = -1;
44  /* Additional scalars declarations for work arrays */
45  size_t lrwork;
46  lapack_int* iwork = NULL;
47  double* rwork = NULL;
48  lapack_complex_double* work = NULL;
49  lapack_complex_double work_query;
50  if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
51  LAPACKE_xerbla( "LAPACKE_zgesdd", -1 );
52  return -1;
53  }
54 #ifndef LAPACK_DISABLE_NAN_CHECK
55  /* Optionally check input matrices for NaNs */
56  if( LAPACKE_zge_nancheck( matrix_layout, m, n, a, lda ) ) {
57  return -5;
58  }
59 #endif
60  /* Additional scalars initializations for work arrays */
61  if( LAPACKE_lsame( jobz, 'n' ) ) {
62  lrwork = MAX(1,7*MIN(m,n));
63  } else {
64  lrwork = (size_t)MAX(1,MIN(m,n)*MAX(5*MIN(m,n)+7,2*MAX(m,n)+2*MIN(m,n)+1));
65  }
66  /* Allocate memory for working array(s) */
67  iwork = (lapack_int*)
68  LAPACKE_malloc( sizeof(lapack_int) * MAX(1,8*MIN(m,n)) );
69  if( iwork == NULL ) {
71  goto exit_level_0;
72  }
73  rwork = (double*)LAPACKE_malloc( sizeof(double) * lrwork );
74  if( rwork == NULL ) {
76  goto exit_level_1;
77  }
78  /* Query optimal working array(s) size */
79  info = LAPACKE_zgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
80  ldvt, &work_query, lwork, rwork, iwork );
81  if( info != 0 ) {
82  goto exit_level_2;
83  }
84  lwork = LAPACK_Z2INT( work_query );
85  /* Allocate memory for work arrays */
86  work = (lapack_complex_double*)
87  LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
88  if( work == NULL ) {
90  goto exit_level_2;
91  }
92  /* Call middle-level interface */
93  info = LAPACKE_zgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
94  ldvt, work, lwork, rwork, iwork );
95  /* Release memory and exit */
96  LAPACKE_free( work );
97 exit_level_2:
98  LAPACKE_free( rwork );
99 exit_level_1:
100  LAPACKE_free( iwork );
101 exit_level_0:
102  if( info == LAPACK_WORK_MEMORY_ERROR ) {
103  LAPACKE_xerbla( "LAPACKE_zgesdd", info );
104  }
105  return info;
106 }
#define LAPACK_Z2INT(x)
Definition: lapacke.h:117
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define LAPACK_WORK_MEMORY_ERROR
Definition: lapacke.h:122
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define lapack_complex_double
Definition: lapacke.h:90
#define MIN(x, y)
Definition: lapacke_utils.h:50
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:36
lapack_int LAPACKE_zgesdd_work(int matrix_layout, char jobz, lapack_int m, lapack_int n, lapack_complex_double *a, lapack_int lda, double *s, lapack_complex_double *u, lapack_int ldu, lapack_complex_double *vt, lapack_int ldvt, lapack_complex_double *work, lapack_int lwork, double *rwork, lapack_int *iwork)
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
void LAPACKE_xerbla(const char *name, lapack_int info)
#define lapack_int
Definition: lapacke.h:47
lapack_logical LAPACKE_zge_nancheck(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *a, lapack_int lda)
Here is the call graph for this function: