LAPACK  3.8.0
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  if( LAPACKE_get_nancheck() ) {
56  /* Optionally check input matrices for NaNs */
57  if( LAPACKE_zge_nancheck( matrix_layout, m, n, a, lda ) ) {
58  return -5;
59  }
60  }
61 #endif
62  /* Additional scalars initializations for work arrays */
63  if( LAPACKE_lsame( jobz, 'n' ) ) {
64  lrwork = MAX(1,7*MIN(m,n));
65  } else {
66  lrwork = (size_t)MAX(1,MIN(m,n)*MAX(5*MIN(m,n)+7,2*MAX(m,n)+2*MIN(m,n)+1));
67  }
68  /* Allocate memory for working array(s) */
69  iwork = (lapack_int*)
70  LAPACKE_malloc( sizeof(lapack_int) * MAX(1,8*MIN(m,n)) );
71  if( iwork == NULL ) {
73  goto exit_level_0;
74  }
75  rwork = (double*)LAPACKE_malloc( sizeof(double) * lrwork );
76  if( rwork == NULL ) {
78  goto exit_level_1;
79  }
80  /* Query optimal working array(s) size */
81  info = LAPACKE_zgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
82  ldvt, &work_query, lwork, rwork, iwork );
83  if( info != 0 ) {
84  goto exit_level_2;
85  }
86  lwork = LAPACK_Z2INT( work_query );
87  /* Allocate memory for work arrays */
88  work = (lapack_complex_double*)
89  LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
90  if( work == NULL ) {
92  goto exit_level_2;
93  }
94  /* Call middle-level interface */
95  info = LAPACKE_zgesdd_work( matrix_layout, jobz, m, n, a, lda, s, u, ldu, vt,
96  ldvt, work, lwork, rwork, iwork );
97  /* Release memory and exit */
98  LAPACKE_free( work );
99 exit_level_2:
100  LAPACKE_free( rwork );
101 exit_level_1:
102  LAPACKE_free( iwork );
103 exit_level_0:
104  if( info == LAPACK_WORK_MEMORY_ERROR ) {
105  LAPACKE_xerbla( "LAPACKE_zgesdd", info );
106  }
107  return info;
108 }
#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)
int LAPACKE_get_nancheck()
Here is the call graph for this function: