LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zhesv_aa_2stage_work()

lapack_int LAPACKE_zhesv_aa_2stage_work ( int  matrix_layout,
char  uplo,
lapack_int  n,
lapack_int  nrhs,
lapack_complex_double a,
lapack_int  lda,
lapack_complex_double tb,
lapack_int  ltb,
lapack_int ipiv,
lapack_int ipiv2,
lapack_complex_double b,
lapack_int  ldb,
lapack_complex_double work,
lapack_int  lwork 
)

Definition at line 36 of file lapacke_zhesv_aa_2stage_work.c.

41 {
42  lapack_int info = 0;
43  if( matrix_layout == LAPACK_COL_MAJOR ) {
44  /* Call LAPACK function and adjust info */
45  LAPACK_zhesv_aa_2stage( &uplo, &n, &nrhs, a, &lda, tb,
46  &ltb, ipiv, ipiv2, b, &ldb, work, &lwork,
47  &info );
48  if( info < 0 ) {
49  info = info - 1;
50  }
51  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
52  lapack_int lda_t = MAX(1,n);
53  lapack_int ldb_t = MAX(1,n);
54  lapack_complex_double* a_t = NULL;
55  lapack_complex_double* tb_t = NULL;
56  lapack_complex_double* b_t = NULL;
57  /* Check leading dimension(s) */
58  if( lda < n ) {
59  info = -6;
60  LAPACKE_xerbla( "LAPACKE_zhesv_aa_2stage_work", info );
61  return info;
62  }
63  if( ltb < 4*n ) {
64  info = -8;
65  LAPACKE_xerbla( "LAPACKE_zhesv_aa_2stage_work", info );
66  return info;
67  }
68  if( ldb < nrhs ) {
69  info = -12;
70  LAPACKE_xerbla( "LAPACKE_zhesv_aa_2stage_work", info );
71  return info;
72  }
73  /* Query optimal working array(s) size if requested */
74  if( lwork == -1 ) {
75  LAPACK_zhesv_aa_2stage( &uplo, &n, &nrhs, a, &lda_t,
76  tb, &ltb, ipiv, ipiv2, b, &ldb_t, work,
77  &lwork, &info );
78  return (info < 0) ? (info - 1) : info;
79  }
80  /* Allocate memory for temporary array(s) */
81  a_t = (lapack_complex_double*)LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
82  if( a_t == NULL ) {
84  goto exit_level_0;
85  }
87  if( tb_t == NULL ) {
89  goto exit_level_1;
90  }
91  b_t = (lapack_complex_double*)LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,nrhs) );
92  if( b_t == NULL ) {
94  goto exit_level_2;
95  }
96  /* Transpose input matrices */
97  LAPACKE_zhe_trans( matrix_layout, uplo, n, a, lda, a_t, lda_t );
98  LAPACKE_zge_trans( matrix_layout, n, nrhs, b, ldb, b_t, ldb_t );
99  /* Call LAPACK function and adjust info */
100  LAPACK_zhesv_aa_2stage( &uplo, &n, &nrhs, a_t, &lda_t,
101  tb_t, &ltb, ipiv, ipiv2, b_t, &ldb_t, work,
102  &lwork, &info );
103  if( info < 0 ) {
104  info = info - 1;
105  }
106  /* Transpose output matrices */
107  LAPACKE_zhe_trans( LAPACK_COL_MAJOR, uplo, n, a_t, lda_t, a, lda );
108  LAPACKE_zge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb );
109  /* Release memory and exit */
110  LAPACKE_free( b_t );
111 exit_level_2:
112  LAPACKE_free( tb_t );
113 exit_level_1:
114  LAPACKE_free( a_t );
115 exit_level_0:
116  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
117  LAPACKE_xerbla( "LAPACKE_zhesv_aa_2stage_work", info );
118  }
119  } else {
120  info = -1;
121  LAPACKE_xerbla( "LAPACKE_zhesv_aa_2stage_work", info );
122  }
123  return info;
124 }
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACK_COL_MAJOR
Definition: lapacke.h:120
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
void LAPACKE_zge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
#define lapack_int
Definition: lapacke.h:47
void LAPACKE_zhe_trans(int matrix_layout, char uplo, lapack_int n, const lapack_complex_double *in, lapack_int ldin, lapack_complex_double *out, lapack_int ldout)
#define lapack_complex_double
Definition: lapacke.h:90
void LAPACK_zhesv_aa_2stage(char *uplo, lapack_int *n, lapack_int *nrhs, lapack_complex_double *a, lapack_int *lda, lapack_complex_double *tb, lapack_int *ltb, lapack_int *ipiv, lapack_int *ipiv2, lapack_complex_double *b, lapack_int *ldb, lapack_complex_double *work, lapack_int *lwork, lapack_int *info)
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
#define LAPACKE_free(p)
Definition: lapacke.h:113
void LAPACKE_xerbla(const char *name, lapack_int info)
Here is the call graph for this function:
Here is the caller graph for this function: