LAPACK  3.10.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zlacpy_work()

lapack_int LAPACKE_zlacpy_work ( int  matrix_layout,
char  uplo,
lapack_int  m,
lapack_int  n,
const lapack_complex_double a,
lapack_int  lda,
lapack_complex_double b,
lapack_int  ldb 
)

Definition at line 35 of file lapacke_zlacpy_work.c.

39 {
40  lapack_int info = 0;
41  if( matrix_layout == LAPACK_COL_MAJOR ) {
42  /* Call LAPACK function and adjust info */
43  LAPACK_zlacpy( &uplo, &m, &n, a, &lda, b, &ldb );
44  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
45  lapack_int lda_t = MAX(1,m);
46  lapack_int ldb_t = MAX(1,m);
47  lapack_complex_double* a_t = NULL;
48  lapack_complex_double* b_t = NULL;
49  /* Check leading dimension(s) */
50  if( lda < n ) {
51  info = -6;
52  LAPACKE_xerbla( "LAPACKE_zlacpy_work", info );
53  return info;
54  }
55  if( ldb < n ) {
56  info = -8;
57  LAPACKE_xerbla( "LAPACKE_zlacpy_work", info );
58  return info;
59  }
60  /* Allocate memory for temporary array(s) */
61  a_t = (lapack_complex_double*)
62  LAPACKE_malloc( sizeof(lapack_complex_double) * lda_t * MAX(1,n) );
63  if( a_t == NULL ) {
65  goto exit_level_0;
66  }
67  b_t = (lapack_complex_double*)
68  LAPACKE_malloc( sizeof(lapack_complex_double) * ldb_t * MAX(1,n) );
69  if( b_t == NULL ) {
71  goto exit_level_1;
72  }
73  /* Transpose input matrices */
74  LAPACKE_zge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
75  /* Call LAPACK function and adjust info */
76  LAPACK_zlacpy( &uplo, &m, &n, a_t, &lda_t, b_t, &ldb_t );
77  info = 0; /* LAPACK call is ok! */
78  /* Transpose output matrices */
79  LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, b_t, ldb_t, b, ldb );
80  /* Release memory and exit */
81  LAPACKE_free( b_t );
82 exit_level_1:
83  LAPACKE_free( a_t );
84 exit_level_0:
85  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
86  LAPACKE_xerbla( "LAPACKE_zlacpy_work", info );
87  }
88  } else {
89  info = -1;
90  LAPACKE_xerbla( "LAPACKE_zlacpy_work", info );
91  }
92  return info;
93 }
#define lapack_int
Definition: lapack.h:83
#define LAPACK_zlacpy(...)
Definition: lapack.h:9327
#define lapack_complex_double
Definition: lapack.h:63
#define LAPACK_COL_MAJOR
Definition: lapacke.h:53
#define LAPACKE_free(p)
Definition: lapacke.h:46
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:52
#define LAPACKE_malloc(size)
Definition: lapacke.h:43
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:56
void LAPACKE_xerbla(const char *name, lapack_int info)
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 MAX(x, y)
Definition: lapacke_utils.h:46
Here is the call graph for this function:
Here is the caller graph for this function: