LAPACK  3.7.1
LAPACK: Linear Algebra PACKage

◆ LAPACKE_zlarfb_work()

lapack_int LAPACKE_zlarfb_work ( int  matrix_layout,
char  side,
char  trans,
char  direct,
char  storev,
lapack_int  m,
lapack_int  n,
lapack_int  k,
const lapack_complex_double v,
lapack_int  ldv,
const lapack_complex_double t,
lapack_int  ldt,
lapack_complex_double c,
lapack_int  ldc,
lapack_complex_double work,
lapack_int  ldwork 
)

Definition at line 36 of file lapacke_zlarfb_work.c.

43 {
44  lapack_int info = 0;
45  lapack_int nrows_v, ncols_v;
46  lapack_int ldc_t, ldt_t, ldv_t;
47  lapack_complex_double *v_t = NULL, *t_t = NULL, *c_t = NULL;
48  if( matrix_layout == LAPACK_COL_MAJOR ) {
49  /* Call LAPACK function and adjust info */
50  LAPACK_zlarfb( &side, &trans, &direct, &storev, &m, &n, &k, v, &ldv, t,
51  &ldt, c, &ldc, work, &ldwork );
52  if( info < 0 ) {
53  info = info - 1;
54  }
55  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
56  nrows_v = ( LAPACKE_lsame( storev, 'c' ) &&
57  LAPACKE_lsame( side, 'l' ) ) ? m :
58  ( ( LAPACKE_lsame( storev, 'c' ) &&
59  LAPACKE_lsame( side, 'r' ) ) ? n :
60  ( LAPACKE_lsame( storev, 'r' ) ? k : 1) );
61  ncols_v = LAPACKE_lsame( storev, 'c' ) ? k :
62  ( ( LAPACKE_lsame( storev, 'r' ) &&
63  LAPACKE_lsame( side, 'l' ) ) ? m :
64  ( ( LAPACKE_lsame( storev, 'r' ) &&
65  LAPACKE_lsame( side, 'r' ) ) ? n : 1) );
66  ldc_t = MAX(1,m);
67  ldt_t = MAX(1,k);
68  ldv_t = MAX(1,nrows_v);
69  /* Check leading dimension(s) */
70  if( ldc < n ) {
71  info = -14;
72  LAPACKE_xerbla( "LAPACKE_zlarfb_work", info );
73  return info;
74  }
75  if( ldt < k ) {
76  info = -12;
77  LAPACKE_xerbla( "LAPACKE_zlarfb_work", info );
78  return info;
79  }
80  if( ldv < ncols_v ) {
81  info = -10;
82  LAPACKE_xerbla( "LAPACKE_zlarfb_work", info );
83  return info;
84  }
85  /* Allocate memory for temporary array(s) */
86  v_t = (lapack_complex_double*)
88  ldv_t * MAX(1,ncols_v) );
89  if( v_t == NULL ) {
91  goto exit_level_0;
92  }
93  t_t = (lapack_complex_double*)
94  LAPACKE_malloc( sizeof(lapack_complex_double) * ldt_t * MAX(1,k) );
95  if( t_t == NULL ) {
97  goto exit_level_1;
98  }
99  c_t = (lapack_complex_double*)
100  LAPACKE_malloc( sizeof(lapack_complex_double) * ldc_t * MAX(1,n) );
101  if( c_t == NULL ) {
103  goto exit_level_2;
104  }
105  /* Transpose input matrices */
106  if( LAPACKE_lsame( storev, 'c' ) && LAPACKE_lsame( direct, 'f' ) ) {
107  LAPACKE_ztr_trans( matrix_layout, 'l', 'u', k, v, ldv, v_t, ldv_t );
108  LAPACKE_zge_trans( matrix_layout, nrows_v-k, ncols_v, &v[k*ldv], ldv,
109  &v_t[k], ldv_t );
110  } else if( LAPACKE_lsame( storev, 'c' ) &&
111  LAPACKE_lsame( direct, 'b' ) ) {
112  if( k > nrows_v ) {
113  LAPACKE_xerbla( "LAPACKE_zlarfb_work", -8 );
114  return -8;
115  }
116  LAPACKE_ztr_trans( matrix_layout, 'u', 'u', k, &v[(nrows_v-k)*ldv],
117  ldv, &v_t[nrows_v-k], ldv_t );
118  LAPACKE_zge_trans( matrix_layout, nrows_v-k, ncols_v, v, ldv, v_t,
119  ldv_t );
120  } else if( LAPACKE_lsame( storev, 'r' ) &&
121  LAPACKE_lsame( direct, 'f' ) ) {
122  LAPACKE_ztr_trans( matrix_layout, 'u', 'u', k, v, ldv, v_t, ldv_t );
123  LAPACKE_zge_trans( matrix_layout, nrows_v, ncols_v-k, &v[k], ldv,
124  &v_t[k*ldv_t], ldv_t );
125  } else if( LAPACKE_lsame( storev, 'r' ) &&
126  LAPACKE_lsame( direct, 'b' ) ) {
127  if( k > ncols_v ) {
128  LAPACKE_xerbla( "LAPACKE_zlarfb_work", -8 );
129  return -8;
130  }
131  LAPACKE_ztr_trans( matrix_layout, 'l', 'u', k, &v[ncols_v-k], ldv,
132  &v_t[(ncols_v-k)*ldv_t], ldv_t );
133  LAPACKE_zge_trans( matrix_layout, nrows_v, ncols_v-k, v, ldv, v_t,
134  ldv_t );
135  }
136  LAPACKE_zge_trans( matrix_layout, k, k, t, ldt, t_t, ldt_t );
137  LAPACKE_zge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t );
138  /* Call LAPACK function and adjust info */
139  LAPACK_zlarfb( &side, &trans, &direct, &storev, &m, &n, &k, v_t, &ldv_t,
140  t_t, &ldt_t, c_t, &ldc_t, work, &ldwork );
141  info = 0; /* LAPACK call is ok! */
142  /* Transpose output matrices */
143  LAPACKE_zge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc );
144  /* Release memory and exit */
145  LAPACKE_free( c_t );
146 exit_level_2:
147  LAPACKE_free( t_t );
148 exit_level_1:
149  LAPACKE_free( v_t );
150 exit_level_0:
151  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
152  LAPACKE_xerbla( "LAPACKE_zlarfb_work", info );
153  }
154  } else {
155  info = -1;
156  LAPACKE_xerbla( "LAPACKE_zlarfb_work", info );
157  }
158  return info;
159 }
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define lapack_complex_double
Definition: lapacke.h:90
void LAPACKE_ztr_trans(int matrix_layout, char uplo, char diag, 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: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)
void LAPACK_zlarfb(char *side, char *trans, char *direct, char *storev, lapack_int *m, lapack_int *n, lapack_int *k, const lapack_complex_double *v, lapack_int *ldv, const lapack_complex_double *t, lapack_int *ldt, lapack_complex_double *c, lapack_int *ldc, lapack_complex_double *work, lapack_int *ldwork)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123
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)
Here is the call graph for this function:
Here is the caller graph for this function: