OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
lapacke_zuncsd.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 high-level C interface to LAPACK function zuncsd
30* Author: Intel Corporation
31*****************************************************************************/
32
33#include "lapacke_utils.h"
34
35lapack_int LAPACKE_zuncsd( int matrix_layout, char jobu1, char jobu2,
36 char jobv1t, char jobv2t, char trans, char signs,
42 double* theta, lapack_complex_double* u1,
46 lapack_int ldv2t )
47{
48 lapack_int info = 0;
49 lapack_int lrwork = -1;
50 lapack_int lwork = -1;
51 lapack_int* iwork = NULL;
52 double* rwork = NULL;
53 lapack_complex_double* work = NULL;
54 double rwork_query;
55 lapack_complex_double work_query;
56 int lapack_layout;
57 if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
58 LAPACKE_xerbla( "LAPACKE_zuncsd", -1 );
59 return -1;
60 }
61 if( LAPACKE_lsame( trans, 'n' ) && matrix_layout == LAPACK_COL_MAJOR ) {
62 lapack_layout = LAPACK_COL_MAJOR;
63 } else {
64 lapack_layout = LAPACK_ROW_MAJOR;
65 }
66#ifndef LAPACK_DISABLE_NAN_CHECK
67 if( LAPACKE_get_nancheck() ) {
68 /* Optionally check input matrices for NaNs */
69 if( LAPACKE_zge_nancheck( lapack_layout, p, q, x11, ldx11 ) ) {
70 return -11;
71 }
72 if( LAPACKE_zge_nancheck( lapack_layout, p, m-q, x12, ldx12 ) ) {
73 return -13;
74 }
75 if( LAPACKE_zge_nancheck( lapack_layout, m-p, q, x21, ldx21 ) ) {
76 return -15;
77 }
78 if( LAPACKE_zge_nancheck( lapack_layout, m-p, m-q, x22, ldx22 ) ) {
79 return -17;
80 }
81 }
82#endif
83 /* Allocate memory for working array(s) */
84 iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * MAX(1,m-MIN(MIN(p,m-p),MIN(q,m-q))) );
85 if( iwork == NULL ) {
87 goto exit_level_0;
88 }
89 /* Query optimal working array(s) size */
90 info = LAPACKE_zuncsd_work( matrix_layout, jobu1, jobu2, jobv1t, jobv2t,
91 trans, signs, m, p, q, x11, ldx11, x12, ldx12,
92 x21, ldx21, x22, ldx22, theta, u1, ldu1, u2,
93 ldu2, v1t, ldv1t, v2t, ldv2t, &work_query,
94 lwork, &rwork_query, lrwork, iwork );
95 if( info != 0 ) {
96 goto exit_level_1;
97 }
98 lrwork = (lapack_int)rwork_query;
99 lwork = LAPACK_Z2INT( work_query );
100 /* Allocate memory for work arrays */
101 rwork = (double*)LAPACKE_malloc( sizeof(double) * lrwork );
102 if( rwork == NULL ) {
104 goto exit_level_1;
105 }
106 work = (lapack_complex_double*)
107 LAPACKE_malloc( sizeof(lapack_complex_double) * lwork );
108 if( work == NULL ) {
110 goto exit_level_2;
111 }
112 /* Call middle-level interface */
113 info = LAPACKE_zuncsd_work( matrix_layout, jobu1, jobu2, jobv1t, jobv2t,
114 trans, signs, m, p, q, x11, ldx11, x12, ldx12,
115 x21, ldx21, x22, ldx22, theta, u1, ldu1, u2,
116 ldu2, v1t, ldv1t, v2t, ldv2t, work, lwork,
117 rwork, lrwork, iwork );
118 /* Release memory and exit */
119 LAPACKE_free( work );
120exit_level_2:
121 LAPACKE_free( rwork );
122exit_level_1:
123 LAPACKE_free( iwork );
124exit_level_0:
125 if( info == LAPACK_WORK_MEMORY_ERROR ) {
126 LAPACKE_xerbla( "LAPACKE_zuncsd", info );
127 }
128 return info;
129}
#define lapack_int
Definition lapack.h:83
#define lapack_complex_double
Definition lapack.h:63
#define LAPACK_WORK_MEMORY_ERROR
Definition lapacke.h:55
lapack_int LAPACKE_zuncsd_work(int matrix_layout, char jobu1, char jobu2, char jobv1t, char jobv2t, char trans, char signs, lapack_int m, lapack_int p, lapack_int q, lapack_complex_double *x11, lapack_int ldx11, lapack_complex_double *x12, lapack_int ldx12, lapack_complex_double *x21, lapack_int ldx21, lapack_complex_double *x22, lapack_int ldx22, 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 *v2t, lapack_int ldv2t, lapack_complex_double *work, lapack_int lwork, double *rwork, lapack_int lrwork, lapack_int *iwork)
#define LAPACK_COL_MAJOR
Definition lapacke.h:53
#define LAPACKE_free(p)
Definition lapacke.h:46
#define LAPACK_ROW_MAJOR
Definition lapacke.h:52
int LAPACKE_get_nancheck(void)
#define LAPACK_Z2INT(x)
Definition lapacke.h:50
#define LAPACKE_malloc(size)
Definition lapacke.h:43
lapack_logical LAPACKE_lsame(char ca, char cb)
void LAPACKE_xerbla(const char *name, lapack_int info)
lapack_logical LAPACKE_zge_nancheck(int matrix_layout, lapack_int m, lapack_int n, const lapack_complex_double *a, lapack_int lda)
#define MIN(x, y)
#define MAX(x, y)
lapack_int LAPACKE_zuncsd(int matrix_layout, char jobu1, char jobu2, char jobv1t, char jobv2t, char trans, char signs, lapack_int m, lapack_int p, lapack_int q, lapack_complex_double *x11, lapack_int ldx11, lapack_complex_double *x12, lapack_int ldx12, lapack_complex_double *x21, lapack_int ldx21, lapack_complex_double *x22, lapack_int ldx22, 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 *v2t, lapack_int ldv2t)