LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapacke_clarfb_work.c
Go to the documentation of this file.
1 /*****************************************************************************
2  Copyright (c) 2014, Intel Corp.
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of Intel Corporation nor the names of its contributors
14  may be used to endorse or promote products derived from this software
15  without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27  THE POSSIBILITY OF SUCH DAMAGE.
28 *****************************************************************************
29 * Contents: Native middle-level C interface to LAPACK function clarfb
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_clarfb_work( int matrix_layout, char side, char trans,
37  char direct, char storev, lapack_int m,
39  const lapack_complex_float* v, lapack_int ldv,
40  const lapack_complex_float* t, lapack_int ldt,
42  lapack_complex_float* work, lapack_int ldwork )
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_float *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_clarfb( &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_clarfb_work", info );
73  return info;
74  }
75  if( ldt < k ) {
76  info = -12;
77  LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
78  return info;
79  }
80  if( ldv < ncols_v ) {
81  info = -10;
82  LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
83  return info;
84  }
85  /* Allocate memory for temporary array(s) */
86  v_t = (lapack_complex_float*)
88  ldv_t * MAX(1,ncols_v) );
89  if( v_t == NULL ) {
91  goto exit_level_0;
92  }
93  t_t = (lapack_complex_float*)
94  LAPACKE_malloc( sizeof(lapack_complex_float) * ldt_t * MAX(1,k) );
95  if( t_t == NULL ) {
97  goto exit_level_1;
98  }
99  c_t = (lapack_complex_float*)
100  LAPACKE_malloc( sizeof(lapack_complex_float) * 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_ctr_trans( matrix_layout, 'l', 'u', k, v, ldv, v_t, ldv_t );
108  LAPACKE_cge_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_clarfb_work", -8 );
114  return -8;
115  }
116  LAPACKE_ctr_trans( matrix_layout, 'u', 'u', k, &v[(nrows_v-k)*ldv],
117  ldv, &v_t[nrows_v-k], ldv_t );
118  LAPACKE_cge_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_ctr_trans( matrix_layout, 'u', 'u', k, v, ldv, v_t, ldv_t );
123  LAPACKE_cge_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, 'f' ) ) {
127  if( k > ncols_v ) {
128  LAPACKE_xerbla( "LAPACKE_clarfb_work", -8 );
129  return -8;
130  }
131  LAPACKE_ctr_trans( matrix_layout, 'l', 'u', k, &v[ncols_v-k], ldv,
132  &v_t[(ncols_v-k)*ldv_t], ldv_t );
133  LAPACKE_cge_trans( matrix_layout, nrows_v, ncols_v-k, v, ldv, v_t,
134  ldv_t );
135  }
136  LAPACKE_cge_trans( matrix_layout, k, k, t, ldt, t_t, ldt_t );
137  LAPACKE_cge_trans( matrix_layout, m, n, c, ldc, c_t, ldc_t );
138  /* Call LAPACK function and adjust info */
139  LAPACK_clarfb( &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_cge_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_clarfb_work", info );
153  }
154  } else {
155  info = -1;
156  LAPACKE_xerbla( "LAPACKE_clarfb_work", info );
157  }
158  return info;
159 }
void LAPACKE_cge_trans(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
#define lapack_complex_float
Definition: lapacke.h:74
void LAPACKE_ctr_trans(int matrix_layout, char uplo, char diag, lapack_int n, const lapack_complex_float *in, lapack_int ldin, lapack_complex_float *out, lapack_int ldout)
lapack_int LAPACKE_clarfb_work(int matrix_layout, char side, char trans, char direct, char storev, lapack_int m, lapack_int n, lapack_int k, const lapack_complex_float *v, lapack_int ldv, const lapack_complex_float *t, lapack_int ldt, lapack_complex_float *c, lapack_int ldc, lapack_complex_float *work, lapack_int ldwork)
#define MAX(x, y)
Definition: lapacke_utils.h:47
#define LAPACKE_free(p)
Definition: lapacke.h:113
#define LAPACKE_malloc(size)
Definition: lapacke.h:110
void LAPACK_clarfb(char *side, char *trans, char *direct, char *storev, lapack_int *m, lapack_int *n, lapack_int *k, const lapack_complex_float *v, lapack_int *ldv, const lapack_complex_float *t, lapack_int *ldt, lapack_complex_float *c, lapack_int *ldc, lapack_complex_float *work, lapack_int *ldwork)
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)
#define lapack_int
Definition: lapacke.h:47
#define LAPACK_TRANSPOSE_MEMORY_ERROR
Definition: lapacke.h:123