LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
lapacke_zuncsd2by1_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 zuncsd2by1
30 * Author: Intel Corporation
31 * Generated June 2016
32 *****************************************************************************/
33 
34 #include "lapacke_utils.h"
35 
36 lapack_int LAPACKE_zuncsd2by1_work( int matrix_layout, char jobu1, char jobu2,
37  char jobv1t, lapack_int m, lapack_int p,
40  double* theta, lapack_complex_double* u1,
43  lapack_int ldv1t, lapack_complex_double* work,
44  lapack_int lwork, double* rwork, lapack_int lrwork,
45  lapack_int* iwork )
46 {
47  lapack_int info = 0;
48  if( matrix_layout == LAPACK_COL_MAJOR ) {
49  /* Call LAPACK function and adjust info */
50  LAPACK_zuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
51  &q, x11, &ldx11, x21, &ldx21,
52  theta, u1, &ldu1, u2, &ldu2, v1t, &ldv1t,
53  work, &lwork, rwork, &lrwork, iwork, &info );
54  if( info < 0 ) {
55  info = info - 1;
56  }
57  } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
58  lapack_int nrows_x11 = p;
59  lapack_int nrows_x21 = m-p;
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 ldu1_t = MAX(1,nrows_u1);
64  lapack_int ldu2_t = MAX(1,nrows_u2);
65  lapack_int ldv1t_t = MAX(1,nrows_v1t);
66  lapack_int ldx11_t = MAX(1,nrows_x11);
67  lapack_int ldx21_t = MAX(1,nrows_x21);
68  lapack_complex_double* x11_t = NULL;
69  lapack_complex_double* x21_t = NULL;
70  lapack_complex_double* u1_t = NULL;
71  lapack_complex_double* u2_t = NULL;
72  lapack_complex_double* v1t_t = NULL;
73  /* Check leading dimension(s) */
74  if( ldu1 < p ) {
75  info = -21;
76  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
77  return info;
78  }
79  if( ldu2 < m-p ) {
80  info = -23;
81  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
82  return info;
83  }
84  if( ldv1t < q ) {
85  info = -25;
86  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
87  return info;
88  }
89  if( ldx11 < q ) {
90  info = -12;
91  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
92  return info;
93  }
94  if( ldx21 < q ) {
95  info = -16;
96  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
97  return info;
98  }
99  /* Query optimal working array(s) size if requested */
100  if( lrwork == -1 || lwork == -1 ) {
101  LAPACK_zuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
102  &q, x11, &ldx11_t, x21, &ldx21_t,
103  theta, u1, &ldu1_t, u2, &ldu2_t, v1t, &ldv1t_t,
104  work, &lwork, rwork, &lrwork, iwork, &info );
105  return (info < 0) ? (info - 1) : info;
106  }
107  /* Allocate memory for temporary array(s) */
108  x11_t = (lapack_complex_double*)LAPACKE_malloc( sizeof(lapack_complex_double) * ldx11_t * MAX(1,q) );
109  if( x11_t == NULL ) {
111  goto exit_level_0;
112  }
113  x21_t = (lapack_complex_double*)LAPACKE_malloc( sizeof(lapack_complex_double) * ldx21_t * MAX(1,q) );
114  if( x21_t == NULL ) {
116  goto exit_level_1;
117  }
118  if( LAPACKE_lsame( jobu1, 'y' ) ) {
119  u1_t = (lapack_complex_double*)
120  LAPACKE_malloc( sizeof(lapack_complex_double) * ldu1_t * MAX(1,p) );
121  if( u1_t == NULL ) {
123  goto exit_level_2;
124  }
125  }
126  if( LAPACKE_lsame( jobu2, 'y' ) ) {
127  u2_t = (lapack_complex_double*)
128  LAPACKE_malloc( sizeof(lapack_complex_double) * ldu2_t * MAX(1,m-p) );
129  if( u2_t == NULL ) {
131  goto exit_level_3;
132  }
133  }
134  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
135  v1t_t = (lapack_complex_double*)
136  LAPACKE_malloc( sizeof(lapack_complex_double) * ldv1t_t * MAX(1,q) );
137  if( v1t_t == NULL ) {
139  goto exit_level_4;
140  }
141  }
142  /* Transpose input matrices */
143  LAPACKE_zge_trans( matrix_layout, nrows_x11, q, x11, ldx11, x11_t,
144  ldx11_t );
145  LAPACKE_zge_trans( matrix_layout, nrows_x21, q, x21, ldx21, x21_t,
146  ldx21_t );
147  /* Call LAPACK function and adjust info */
148  LAPACK_zuncsd2by1( &jobu1, &jobu2, &jobv1t, &m, &p,
149  &q, x11_t, &ldx11_t, x21_t, &ldx21_t,
150  theta, u1_t, &ldu1_t, u2_t, &ldu2_t, v1t_t, &ldv1t_t,
151  work, &lwork, rwork, &lrwork, iwork, &info );
152  if( info < 0 ) {
153  info = info - 1;
154  }
155  /* Transpose output matrices */
156  LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_x11, q, x11_t, ldx11_t, x11,
157  ldx11 );
158  LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_x21, q, x21_t, ldx21_t, x21,
159  ldx21 );
160  if( LAPACKE_lsame( jobu1, 'y' ) ) {
161  LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_u1, p, u1_t, ldu1_t, u1,
162  ldu1 );
163  }
164  if( LAPACKE_lsame( jobu2, 'y' ) ) {
165  LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_u2, m-p, u2_t, ldu2_t,
166  u2, ldu2 );
167  }
168  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
169  LAPACKE_zge_trans( LAPACK_COL_MAJOR, nrows_v1t, q, v1t_t, ldv1t_t,
170  v1t, ldv1t );
171  }
172  /* Release memory and exit */
173  if( LAPACKE_lsame( jobv1t, 'y' ) ) {
174  LAPACKE_free( v1t_t );
175  }
176 exit_level_4:
177  if( LAPACKE_lsame( jobu2, 'y' ) ) {
178  LAPACKE_free( u2_t );
179  }
180 exit_level_3:
181  if( LAPACKE_lsame( jobu1, 'y' ) ) {
182  LAPACKE_free( u1_t );
183  }
184 exit_level_2:
185  LAPACKE_free( x21_t );
186 exit_level_1:
187  LAPACKE_free( x11_t );
188 exit_level_0:
189  if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
190  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
191  }
192  } else {
193  info = -1;
194  LAPACKE_xerbla( "LAPACKE_zuncsd2by1_work", info );
195  }
196  return info;
197 }
void LAPACK_zuncsd2by1(char *jobu1, char *jobu2, char *jobv1t, lapack_int *m, lapack_int *p, lapack_int *q, lapack_complex_double *x11, lapack_int *ldx11, lapack_complex_double *x21, lapack_int *ldx21, double *theta, lapack_complex_double *u1, lapack_int *ldu1, lapack_complex_double *u2, lapack_int *ldu2, lapack_complex_double *v1t, lapack_int *ldv1t, lapack_complex_double *work, lapack_int *lwork, double *rwork, lapack_int *lrwork, lapack_int *iwork, lapack_int *info)
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:119
lapack_int LAPACKE_zuncsd2by1_work(int matrix_layout, char jobu1, char jobu2, char jobv1t, lapack_int m, lapack_int p, lapack_int q, lapack_complex_double *x11, lapack_int ldx11, lapack_complex_double *x21, lapack_int ldx21, double *theta, lapack_complex_double *u1, lapack_int ldu1, lapack_complex_double *u2, lapack_int ldu2, lapack_complex_double *v1t, lapack_int ldv1t, lapack_complex_double *work, lapack_int lwork, double *rwork, lapack_int lrwork, lapack_int *iwork)
#define lapack_complex_double
Definition: lapacke.h:90
#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
#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
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)