LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_chbgvd_work()

lapack_int LAPACKE_chbgvd_work ( int  matrix_layout,
char  jobz,
char  uplo,
lapack_int  n,
lapack_int  ka,
lapack_int  kb,
lapack_complex_float ab,
lapack_int  ldab,
lapack_complex_float bb,
lapack_int  ldbb,
float *  w,
lapack_complex_float z,
lapack_int  ldz,
lapack_complex_float work,
lapack_int  lwork,
float *  rwork,
lapack_int  lrwork,
lapack_int iwork,
lapack_int  liwork 
)

Definition at line 36 of file lapacke_chbgvd_work.c.

45 {
46  lapack_int info = 0;
47  if( matrix_layout == LAPACK_COL_MAJOR ) {
48  /* Call LAPACK function and adjust info */
49  LAPACK_chbgvd( &jobz, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, w, z,
50  &ldz, work, &lwork, rwork, &lrwork, iwork, &liwork,
51  &info );
52  if( info < 0 ) {
53  info = info - 1;
54  }
55  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
56  lapack_int ldab_t = MAX(1,ka+1);
57  lapack_int ldbb_t = MAX(1,kb+1);
58  lapack_int ldz_t = MAX(1,n);
59  lapack_complex_float* ab_t = NULL;
60  lapack_complex_float* bb_t = NULL;
61  lapack_complex_float* z_t = NULL;
62  /* Check leading dimension(s) */
63  if( ldab < n ) {
64  info = -8;
65  LAPACKE_xerbla( "LAPACKE_chbgvd_work", info );
66  return info;
67  }
68  if( ldbb < n ) {
69  info = -10;
70  LAPACKE_xerbla( "LAPACKE_chbgvd_work", info );
71  return info;
72  }
73  if( ldz < n ) {
74  info = -13;
75  LAPACKE_xerbla( "LAPACKE_chbgvd_work", info );
76  return info;
77  }
78  /* Query optimal working array(s) size if requested */
79  if( liwork == -1 || lrwork == -1 || lwork == -1 ) {
80  LAPACK_chbgvd( &jobz, &uplo, &n, &ka, &kb, ab, &ldab_t, bb, &ldbb_t,
81  w, z, &ldz_t, work, &lwork, rwork, &lrwork, iwork,
82  &liwork, &info );
83  return (info < 0) ? (info - 1) : info;
84  }
85  /* Allocate memory for temporary array(s) */
86  ab_t = (lapack_complex_float*)
87  LAPACKE_malloc( sizeof(lapack_complex_float) * ldab_t * MAX(1,n) );
88  if( ab_t == NULL ) {
90  goto exit_level_0;
91  }
92  bb_t = (lapack_complex_float*)
93  LAPACKE_malloc( sizeof(lapack_complex_float) * ldbb_t * MAX(1,n) );
94  if( bb_t == NULL ) {
96  goto exit_level_1;
97  }
98  if( LAPACKE_lsame( jobz, 'v' ) ) {
99  z_t = (lapack_complex_float*)
101  ldz_t * MAX(1,n) );
102  if( z_t == NULL ) {
104  goto exit_level_2;
105  }
106  }
107  /* Transpose input matrices */
108  LAPACKE_chb_trans( matrix_layout, uplo, n, ka, ab, ldab, ab_t, ldab_t );
109  LAPACKE_chb_trans( matrix_layout, uplo, n, kb, bb, ldbb, bb_t, ldbb_t );
110  /* Call LAPACK function and adjust info */
111  LAPACK_chbgvd( &jobz, &uplo, &n, &ka, &kb, ab_t, &ldab_t, bb_t, &ldbb_t,
112  w, z_t, &ldz_t, work, &lwork, rwork, &lrwork, iwork,
113  &liwork, &info );
114  if( info < 0 ) {
115  info = info - 1;
116  }
117  /* Transpose output matrices */
118  LAPACKE_chb_trans( LAPACK_COL_MAJOR, uplo, n, ka, ab_t, ldab_t, ab,
119  ldab );
120  LAPACKE_chb_trans( LAPACK_COL_MAJOR, uplo, n, kb, bb_t, ldbb_t, bb,
121  ldbb );
122  if( LAPACKE_lsame( jobz, 'v' ) ) {
123  LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
124  }
125  /* Release memory and exit */
126  if( LAPACKE_lsame( jobz, 'v' ) ) {
127  LAPACKE_free( z_t );
128  }
129 exit_level_2:
130  LAPACKE_free( bb_t );
131 exit_level_1:
132  LAPACKE_free( ab_t );
133 exit_level_0:
134  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
135  LAPACKE_xerbla( "LAPACKE_chbgvd_work", info );
136  }
137  } else {
138  info = -1;
139  LAPACKE_xerbla( "LAPACKE_chbgvd_work", info );
140  }
141  return info;
142 }
void LAPACKE_cge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define lapack_complex_float
Definition: lapacke.h:74
void LAPACK_chbgvd(char *jobz, char *uplo, lapack_int *n, lapack_int *ka, lapack_int *kb, lapack_complex_float *ab, lapack_int *ldab, lapack_complex_float *bb, lapack_int *ldbb, float *w, lapack_complex_float *z, lapack_int *ldz, lapack_complex_float *work, lapack_int *lwork, float *rwork, lapack_int *lrwork, lapack_int *iwork, lapack_int *liwork, lapack_int *info)
#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
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
void LAPACKE_xerbla(const char *name, lapack_int info)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123
void LAPACKE_chb_trans(int matrix_layout, char uplo, lapack_int n, lapack_int kd, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
Here is the call graph for this function:
Here is the caller graph for this function: