LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapacke_cbbcsd_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 cbbcsd
30 * Author: Intel Corporation
31 * Generated November 2015
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_cbbcsd_work( int matrix_layout, char jobu1, char jobu2,
37  char jobv1t, char jobv2t, char trans,
39  float* theta, float* phi,
42  lapack_complex_float* v1t, lapack_int ldv1t,
43  lapack_complex_float* v2t, lapack_int ldv2t,
44  float* b11d, float* b11e, float* b12d,
45  float* b12e, float* b21d, float* b21e,
46  float* b22d, float* b22e, float* rwork,
47  lapack_int lrwork )
48 {
49  lapack_int info = 0;
50  if( matrix_layout == LAPACK_COL_MAJOR ) {
51  /* Call LAPACK function and adjust info */
52  LAPACK_cbbcsd( &jobu1, &jobu2, &jobv1t, &jobv2t, &trans, &m, &p, &q,
53  theta, phi, u1, &ldu1, u2, &ldu2, v1t, &ldv1t, v2t,
54  &ldv2t, b11d, b11e, b12d, b12e, b21d, b21e, b22d, b22e,
55  rwork, &lrwork, &info );
56  if( info < 0 ) {
57  info = info - 1;
58  }
59  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
60  lapack_int nrows_u1 = ( LAPACKE_lsame( jobu1, 'y' ) ? p : 1);
61  lapack_int nrows_u2 = ( LAPACKE_lsame( jobu2, 'y' ) ? m-p : 1);
62  lapack_int nrows_v1t = ( LAPACKE_lsame( jobv1t, 'y' ) ? q : 1);
63  lapack_int nrows_v2t = ( LAPACKE_lsame( jobv2t, 'y' ) ? m-q : 1);
64  lapack_int ldu1_t = MAX(1,nrows_u1);
65  lapack_int ldu2_t = MAX(1,nrows_u2);
66  lapack_int ldv1t_t = MAX(1,nrows_v1t);
67  lapack_int ldv2t_t = MAX(1,nrows_v2t);
68  lapack_complex_float* u1_t = NULL;
69  lapack_complex_float* u2_t = NULL;
70  lapack_complex_float* v1t_t = NULL;
71  lapack_complex_float* v2t_t = NULL;
72  /* Check leading dimension(s) */
73  if( ldu1 < p ) {
74  info = -13;
75  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
76  return info;
77  }
78  if( ldu2 < m-p ) {
79  info = -15;
80  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
81  return info;
82  }
83  if( ldv1t < q ) {
84  info = -17;
85  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
86  return info;
87  }
88  if( ldv2t < m-q ) {
89  info = -19;
90  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
91  return info;
92  }
93  /* Query optimal working array(s) size if requested */
94  if( lrwork == -1 ) {
95  LAPACK_cbbcsd( &jobu1, &jobu2, &jobv1t, &jobv2t, &trans, &m, &p, &q,
96  theta, phi, u1, &ldu1_t, u2, &ldu2_t, v1t, &ldv1t_t,
97  v2t, &ldv2t_t, b11d, b11e, b12d, b12e, b21d, b21e,
98  b22d, b22e, rwork, &lrwork, &info );
99  return (info < 0) ? (info - 1) : info;
100  }
101  /* Allocate memory for temporary array(s) */
102  if( LAPACKE_lsame( jobu1, 'y' ) ) {
103  u1_t = (lapack_complex_float*)
105  ldu1_t * MAX(1,p) );
106  if( u1_t == NULL ) {
108  goto exit_level_0;
109  }
110  }
111  if( LAPACKE_lsame( jobu2, 'y' ) ) {
112  u2_t = (lapack_complex_float*)
114  ldu2_t * MAX(1,m-p) );
115  if( u2_t == NULL ) {
117  goto exit_level_1;
118  }
119  }
120  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
121  v1t_t = (lapack_complex_float*)
123  ldv1t_t * MAX(1,q) );
124  if( v1t_t == NULL ) {
126  goto exit_level_2;
127  }
128  }
129  if( LAPACKE_lsame( jobv2t, 'y' ) ) {
130  v2t_t = (lapack_complex_float*)
132  ldv2t_t * MAX(1,m-q) );
133  if( v2t_t == NULL ) {
135  goto exit_level_3;
136  }
137  }
138  /* Transpose input matrices */
139  if( LAPACKE_lsame( jobu1, 'y' ) ) {
140  LAPACKE_cge_trans( matrix_layout, nrows_u1, p, u1, ldu1, u1_t,
141  ldu1_t );
142  }
143  if( LAPACKE_lsame( jobu2, 'y' ) ) {
144  LAPACKE_cge_trans( matrix_layout, nrows_u2, m-p, u2, ldu2, u2_t,
145  ldu2_t );
146  }
147  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
148  LAPACKE_cge_trans( matrix_layout, nrows_v1t, q, v1t, ldv1t, v1t_t,
149  ldv1t_t );
150  }
151  if( LAPACKE_lsame( jobv2t, 'y' ) ) {
152  LAPACKE_cge_trans( matrix_layout, nrows_v2t, m-q, v2t, ldv2t, v2t_t,
153  ldv2t_t );
154  }
155  /* Call LAPACK function and adjust info */
156  LAPACK_cbbcsd( &jobu1, &jobu2, &jobv1t, &jobv2t, &trans, &m, &p, &q,
157  theta, phi, u1_t, &ldu1_t, u2_t, &ldu2_t, v1t_t,
158  &ldv1t_t, v2t_t, &ldv2t_t, b11d, b11e, b12d, b12e, b21d,
159  b21e, b22d, b22e, rwork, &lrwork, &info );
160  if( info < 0 ) {
161  info = info - 1;
162  }
163  /* Transpose output matrices */
164  if( LAPACKE_lsame( jobu1, 'y' ) ) {
165  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_u1, p, u1_t, ldu1_t, u1,
166  ldu1 );
167  }
168  if( LAPACKE_lsame( jobu2, 'y' ) ) {
169  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_u2, m-p, u2_t, ldu2_t,
170  u2, ldu2 );
171  }
172  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
173  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_v1t, q, v1t_t, ldv1t_t,
174  v1t, ldv1t );
175  }
176  if( LAPACKE_lsame( jobv2t, 'y' ) ) {
177  LAPACKE_cge_trans( LAPACK_COL_MAJOR, nrows_v2t, m-q, v2t_t, ldv2t_t,
178  v2t, ldv2t );
179  }
180  /* Release memory and exit */
181  if( LAPACKE_lsame( jobv2t, 'y' ) ) {
182  LAPACKE_free( v2t_t );
183  }
184 exit_level_3:
185  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
186  LAPACKE_free( v1t_t );
187  }
188 exit_level_2:
189  if( LAPACKE_lsame( jobu2, 'y' ) ) {
190  LAPACKE_free( u2_t );
191  }
192 exit_level_1:
193  if( LAPACKE_lsame( jobu1, 'y' ) ) {
194  LAPACKE_free( u1_t );
195  }
196 exit_level_0:
197  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
198  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
199  }
200  } else {
201  info = -1;
202  LAPACKE_xerbla( "LAPACKE_cbbcsd_work", info );
203  }
204  return info;
205 }
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
lapack_int LAPACKE_cbbcsd_work(int matrix_layout, char jobu1, char jobu2, char jobv1t, char jobv2t, char trans, lapack_int m, lapack_int p, lapack_int q, float *theta, float *phi, lapack_complex_float *u1, lapack_int ldu1, lapack_complex_float *u2, lapack_int ldu2, lapack_complex_float *v1t, lapack_int ldv1t, lapack_complex_float *v2t, lapack_int ldv2t, float *b11d, float *b11e, float *b12d, float *b12e, float *b21d, float *b21e, float *b22d, float *b22e, float *rwork, lapack_int lrwork)
#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
lapack_logical LAPACKE_lsame(char ca, char cb)
Definition: lapacke_lsame.c:36
void LAPACK_cbbcsd(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, lapack_int *m, lapack_int *p, lapack_int *q, float *theta, float *phi, lapack_complex_float *u1, lapack_int *ldu1, lapack_complex_float *u2, lapack_int *ldu2, lapack_complex_float *v1t, lapack_int *ldv1t, lapack_complex_float *v2t, lapack_int *ldv2t, float *b11d, float *b11e, float *b12d, float *b12e, float *b21d, float *b21e, float *b22d, float *b22e, float *rwork, lapack_int *lrwork, 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