OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
lapacke_cgejsv_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 cgejsv
30* Author: Intel Corporation
31*****************************************************************************/
32
33#include "lapacke_utils.h"
34
35lapack_int LAPACKE_cgejsv_work( int matrix_layout, char joba, char jobu,
36 char jobv, char jobr, char jobt, char jobp,
38 lapack_int lda, float* sva, lapack_complex_float* u,
40 lapack_complex_float* cwork, lapack_int lwork,
41 float* rwork, lapack_int lrwork,
42 lapack_int* iwork )
43{
44 lapack_int info = 0;
45 if( matrix_layout == LAPACK_COL_MAJOR ) {
46 /* Call LAPACK function and adjust info */
47 LAPACK_cgejsv( &joba, &jobu, &jobv, &jobr, &jobt, &jobp, &m, &n, a,
48 &lda, sva, u, &ldu, v, &ldv, cwork, &lwork, rwork, &lrwork,
49 iwork, &info );
50 if( info < 0 ) {
51 info = info - 1;
52 }
53 } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
54 lapack_int nu = LAPACKE_lsame( jobu, 'n' ) ? 1 : m;
55 lapack_int nv = LAPACKE_lsame( jobv, 'n' ) ? 1 : n;
56 lapack_int ncols_u = LAPACKE_lsame( jobu, 'n' ) ? 1 :
57 LAPACKE_lsame( jobu, 'f' ) ? m : n;
58 lapack_int lda_t = MAX(1,m);
59 lapack_int ldu_t = MAX(1,nu);
60 lapack_int ldv_t = MAX(1,nv);
61 lapack_complex_float* a_t = NULL;
62 lapack_complex_float* u_t = NULL;
63 lapack_complex_float* v_t = NULL;
64 /* Check leading dimension(s) */
65 if( lda < n ) {
66 info = -11;
67 LAPACKE_xerbla( "LAPACKE_cgejsv_work", info );
68 return info;
69 }
70 if( ldu < ncols_u ) {
71 info = -14;
72 LAPACKE_xerbla( "LAPACKE_cgejsv_work", info );
73 return info;
74 }
75 if( ldv < n ) {
76 info = -16;
77 LAPACKE_xerbla( "LAPACKE_cgejsv_work", info );
78 return info;
79 }
80 /* Allocate memory for temporary array(s) */
82 LAPACKE_malloc( sizeof(lapack_complex_float) * lda_t * MAX(1,n) );
83 if( a_t == NULL ) {
85 goto exit_level_0;
86 }
87 if( LAPACKE_lsame( jobu, 'f' ) || LAPACKE_lsame( jobu, 'u' ) ||
88 LAPACKE_lsame( jobu, 'w' ) ) {
90 LAPACKE_malloc( sizeof(lapack_complex_float) * ldu_t * MAX(1,ncols_u) );
91 if( u_t == NULL ) {
93 goto exit_level_1;
94 }
95 }
96 if( LAPACKE_lsame( jobv, 'j' ) || LAPACKE_lsame( jobv, 'v' ) ||
97 LAPACKE_lsame( jobv, 'w' ) ) {
99 LAPACKE_malloc( sizeof(lapack_complex_float) * ldv_t * MAX(1,n) );
100 if( v_t == NULL ) {
102 goto exit_level_2;
103 }
104 }
105 /* Transpose input matrices */
106 LAPACKE_cge_trans( matrix_layout, m, n, a, lda, a_t, lda_t );
107 /* Call LAPACK function and adjust info */
108 LAPACK_cgejsv( &joba, &jobu, &jobv, &jobr, &jobt, &jobp, &m, &n, a_t,
109 &lda_t, sva, u_t, &ldu_t, v_t, &ldv_t, cwork, &lwork,
110 rwork, &lrwork, iwork, &info );
111 if( info < 0 ) {
112 info = info - 1;
113 }
114 /* Transpose output matrices */
115 if( LAPACKE_lsame( jobu, 'f' ) || LAPACKE_lsame( jobu, 'u' ) ||
116 LAPACKE_lsame( jobu, 'w' ) ) {
117 LAPACKE_cge_trans( LAPACK_COL_MAJOR, nu, ncols_u, u_t, ldu_t, u, ldu );
118 }
119 if( LAPACKE_lsame( jobv, 'j' ) || LAPACKE_lsame( jobv, 'v' ) ||
120 LAPACKE_lsame( jobv, 'w' ) ) {
121 LAPACKE_cge_trans( LAPACK_COL_MAJOR, nv, n, v_t, ldv_t, v, ldv );
122 }
123 /* Release memory and exit */
124 if( LAPACKE_lsame( jobv, 'j' ) || LAPACKE_lsame( jobv, 'v' ) ||
125 LAPACKE_lsame( jobv, 'w' ) ) {
126 LAPACKE_free( v_t );
127 }
128exit_level_2:
129 if( LAPACKE_lsame( jobu, 'f' ) || LAPACKE_lsame( jobu, 'u' ) ||
130 LAPACKE_lsame( jobu, 'w' ) ) {
131 LAPACKE_free( u_t );
132 }
133exit_level_1:
134 LAPACKE_free( a_t );
135exit_level_0:
136 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
137 LAPACKE_xerbla( "LAPACKE_cgejsv_work", info );
138 }
139 } else {
140 info = -1;
141 LAPACKE_xerbla( "LAPACKE_cgejsv_work", info );
142 }
143 return info;
144}
#define LAPACK_cgejsv(...)
Definition lapack.h:2025
#define lapack_int
Definition lapack.h:83
#define lapack_complex_float
Definition lapack.h:45
#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
lapack_int LAPACKE_cgejsv_work(int matrix_layout, char joba, char jobu, char jobv, char jobr, char jobt, char jobp, lapack_int m, lapack_int n, lapack_complex_float *a, lapack_int lda, float *sva, lapack_complex_float *u, lapack_int ldu, lapack_complex_float *v, lapack_int ldv, lapack_complex_float *cwork, lapack_int lwork, float *rwork, lapack_int lrwork, lapack_int *iwork)
lapack_logical LAPACKE_lsame(char ca, char cb)
void LAPACKE_xerbla(const char *name, lapack_int info)
#define MAX(x, y)
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)
n