LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dsysvx_work()

lapack_int LAPACKE_dsysvx_work ( int  matrix_layout,
char  fact,
char  uplo,
lapack_int  n,
lapack_int  nrhs,
const double *  a,
lapack_int  lda,
double *  af,
lapack_int  ldaf,
lapack_int ipiv,
const double *  b,
lapack_int  ldb,
double *  x,
lapack_int  ldx,
double *  rcond,
double *  ferr,
double *  berr,
double *  work,
lapack_int  lwork,
lapack_int iwork 
)

Definition at line 36 of file lapacke_dsysvx_work.c.

44 {
45  lapack_int info = 0;
46  if( matrix_layout == LAPACK_COL_MAJOR ) {
47  /* Call LAPACK function and adjust info */
48  LAPACK_dsysvx( &fact, &uplo, &n, &nrhs, a, &lda, af, &ldaf, ipiv, b,
49  &ldb, x, &ldx, rcond, ferr, berr, work, &lwork, iwork,
50  &info );
51  if( info < 0 ) {
52  info = info - 1;
53  }
54  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
55  lapack_int lda_t = MAX(1,n);
56  lapack_int ldaf_t = MAX(1,n);
57  lapack_int ldb_t = MAX(1,n);
58  lapack_int ldx_t = MAX(1,n);
59  double* a_t = NULL;
60  double* af_t = NULL;
61  double* b_t = NULL;
62  double* x_t = NULL;
63  /* Check leading dimension(s) */
64  if( lda < n ) {
65  info = -7;
66  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
67  return info;
68  }
69  if( ldaf < n ) {
70  info = -9;
71  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
72  return info;
73  }
74  if( ldb < nrhs ) {
75  info = -12;
76  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
77  return info;
78  }
79  if( ldx < nrhs ) {
80  info = -14;
81  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
82  return info;
83  }
84  /* Query optimal working array(s) size if requested */
85  if( lwork == -1 ) {
86  LAPACK_dsysvx( &fact, &uplo, &n, &nrhs, a, &lda_t, af, &ldaf_t,
87  ipiv, b, &ldb_t, x, &ldx_t, rcond, ferr, berr, work,
88  &lwork, iwork, &info );
89  return (info < 0) ? (info - 1) : info;
90  }
91  /* Allocate memory for temporary array(s) */
92  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
93  if( a_t == NULL ) {
95  goto exit_level_0;
96  }
97  af_t = (double*)LAPACKE_malloc( sizeof(double) * ldaf_t * MAX(1,n) );
98  if( af_t == NULL ) {
100  goto exit_level_1;
101  }
102  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,nrhs) );
103  if( b_t == NULL ) {
105  goto exit_level_2;
106  }
107  x_t = (double*)LAPACKE_malloc( sizeof(double) * ldx_t * MAX(1,nrhs) );
108  if( x_t == NULL ) {
110  goto exit_level_3;
111  }
112  /* Transpose input matrices */
113  LAPACKE_dsy_trans( matrix_layout, uplo, n, a, lda, a_t, lda_t );
114  if( LAPACKE_lsame( fact, 'f' ) ) {
115  LAPACKE_dsy_trans( matrix_layout, uplo, n, af, ldaf, af_t, ldaf_t );
116  }
117  LAPACKE_dge_trans( matrix_layout, n, nrhs, b, ldb, b_t, ldb_t );
118  /* Call LAPACK function and adjust info */
119  LAPACK_dsysvx( &fact, &uplo, &n, &nrhs, a_t, &lda_t, af_t, &ldaf_t,
120  ipiv, b_t, &ldb_t, x_t, &ldx_t, rcond, ferr, berr, work,
121  &lwork, iwork, &info );
122  if( info < 0 ) {
123  info = info - 1;
124  }
125  /* Transpose output matrices */
126  if( LAPACKE_lsame( fact, 'n' ) ) {
127  LAPACKE_dsy_trans( LAPACK_COL_MAJOR, uplo, n, af_t, ldaf_t, af,
128  ldaf );
129  }
130  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx );
131  /* Release memory and exit */
132  LAPACKE_free( x_t );
133 exit_level_3:
134  LAPACKE_free( b_t );
135 exit_level_2:
136  LAPACKE_free( af_t );
137 exit_level_1:
138  LAPACKE_free( a_t );
139 exit_level_0:
140  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
141  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
142  }
143  } else {
144  info = -1;
145  LAPACKE_xerbla( "LAPACKE_dsysvx_work", info );
146  }
147  return info;
148 }
void LAPACKE_dge_trans(int matrix_layout, lapack_int m, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define LAPACKE_free(p)
Definition: lapacke.h:113
void LAPACK_dsysvx(char *fact, char *uplo, lapack_int *n, lapack_int *nrhs, const double *a, lapack_int *lda, double *af, lapack_int *ldaf, lapack_int *ipiv, const double *b, lapack_int *ldb, double *x, lapack_int *ldx, double *rcond, double *ferr, double *berr, double *work, lapack_int *lwork, lapack_int *iwork, 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
void LAPACKE_dsy_trans(int matrix_layout, char uplo, lapack_int n, const double *in, lapack_int ldin, double *out, lapack_int ldout)
#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
Here is the call graph for this function:
Here is the caller graph for this function: