LAPACK  3.7.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_dsgesv_work()

lapack_int LAPACKE_dsgesv_work ( int  matrix_layout,
lapack_int  n,
lapack_int  nrhs,
double *  a,
lapack_int  lda,
lapack_int ipiv,
double *  b,
lapack_int  ldb,
double *  x,
lapack_int  ldx,
double *  work,
float *  swork,
lapack_int iter 
)

Definition at line 36 of file lapacke_dsgesv_work.c.

41 {
42  lapack_int info = 0;
43  if( matrix_layout == LAPACK_COL_MAJOR ) {
44  /* Call LAPACK function and adjust info */
45  LAPACK_dsgesv( &n, &nrhs, a, &lda, ipiv, b, &ldb, x, &ldx, work, swork,
46  iter, &info );
47  if( info < 0 ) {
48  info = info - 1;
49  }
50  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
51  lapack_int lda_t = MAX(1,n);
52  lapack_int ldb_t = MAX(1,n);
53  lapack_int ldx_t = MAX(1,n);
54  double* a_t = NULL;
55  double* b_t = NULL;
56  double* x_t = NULL;
57  /* Check leading dimension(s) */
58  if( lda < n ) {
59  info = -5;
60  LAPACKE_xerbla( "LAPACKE_dsgesv_work", info );
61  return info;
62  }
63  if( ldb < nrhs ) {
64  info = -8;
65  LAPACKE_xerbla( "LAPACKE_dsgesv_work", info );
66  return info;
67  }
68  if( ldx < nrhs ) {
69  info = -10;
70  LAPACKE_xerbla( "LAPACKE_dsgesv_work", info );
71  return info;
72  }
73  /* Allocate memory for temporary array(s) */
74  a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) );
75  if( a_t == NULL ) {
77  goto exit_level_0;
78  }
79  b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,nrhs) );
80  if( b_t == NULL ) {
82  goto exit_level_1;
83  }
84  x_t = (double*)LAPACKE_malloc( sizeof(double) * ldx_t * MAX(1,nrhs) );
85  if( x_t == NULL ) {
87  goto exit_level_2;
88  }
89  /* Transpose input matrices */
90  LAPACKE_dge_trans( matrix_layout, n, n, a, lda, a_t, lda_t );
91  LAPACKE_dge_trans( matrix_layout, n, nrhs, b, ldb, b_t, ldb_t );
92  /* Call LAPACK function and adjust info */
93  LAPACK_dsgesv( &n, &nrhs, a_t, &lda_t, ipiv, b_t, &ldb_t, x_t, &ldx_t,
94  work, swork, iter, &info );
95  if( info < 0 ) {
96  info = info - 1;
97  }
98  /* Transpose output matrices */
99  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, a_t, lda_t, a, lda );
100  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, b_t, ldb_t, b, ldb );
101  LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx );
102  /* Release memory and exit */
103  LAPACKE_free( x_t );
104 exit_level_2:
105  LAPACKE_free( b_t );
106 exit_level_1:
107  LAPACKE_free( a_t );
108 exit_level_0:
109  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
110  LAPACKE_xerbla( "LAPACKE_dsgesv_work", info );
111  }
112  } else {
113  info = -1;
114  LAPACKE_xerbla( "LAPACKE_dsgesv_work", info );
115  }
116  return info;
117 }
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
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
void LAPACK_dsgesv(lapack_int *n, lapack_int *nrhs, double *a, lapack_int *lda, lapack_int *ipiv, double *b, lapack_int *ldb, double *x, lapack_int *ldx, double *work, float *swork, lapack_int *iter, lapack_int *info)
#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: