OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
lapacke_sbdsqr_work.c File Reference
#include "lapacke_utils.h"

Go to the source code of this file.

Functions

lapack_int LAPACKE_sbdsqr_work (int matrix_layout, char uplo, lapack_int n, lapack_int ncvt, lapack_int nru, lapack_int ncc, float *d, float *e, float *vt, lapack_int ldvt, float *u, lapack_int ldu, float *c, lapack_int ldc, float *work)

Function Documentation

◆ LAPACKE_sbdsqr_work()

lapack_int LAPACKE_sbdsqr_work ( int matrix_layout,
char uplo,
lapack_int n,
lapack_int ncvt,
lapack_int nru,
lapack_int ncc,
float * d,
float * e,
float * vt,
lapack_int ldvt,
float * u,
lapack_int ldu,
float * c,
lapack_int ldc,
float * work )

Definition at line 35 of file lapacke_sbdsqr_work.c.

40{
41 lapack_int info = 0;
42 if( matrix_layout == LAPACK_COL_MAJOR ) {
43 /* Call LAPACK function and adjust info */
44 LAPACK_sbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt, &ldvt, u, &ldu,
45 c, &ldc, work, &info );
46 if( info < 0 ) {
47 info = info - 1;
48 }
49 } else if( matrix_layout == LAPACK_ROW_MAJOR ) {
50 lapack_int ldc_t = MAX(1,n);
51 lapack_int ldu_t = MAX(1,nru);
52 lapack_int ldvt_t = MAX(1,n);
53 float* vt_t = NULL;
54 float* u_t = NULL;
55 float* c_t = NULL;
56 /* Check leading dimension(s) */
57 if( ldc < ncc ) {
58 info = -14;
59 LAPACKE_xerbla( "LAPACKE_sbdsqr_work", info );
60 return info;
61 }
62 if( ldu < n ) {
63 info = -12;
64 LAPACKE_xerbla( "LAPACKE_sbdsqr_work", info );
65 return info;
66 }
67 if( ldvt < ncvt ) {
68 info = -10;
69 LAPACKE_xerbla( "LAPACKE_sbdsqr_work", info );
70 return info;
71 }
72 /* Allocate memory for temporary array(s) */
73 if( ncvt != 0 ) {
74 vt_t = (float*)
75 LAPACKE_malloc( sizeof(float) * ldvt_t * MAX(1,ncvt) );
76 if( vt_t == NULL ) {
78 goto exit_level_0;
79 }
80 }
81 if( nru != 0 ) {
82 u_t = (float*)LAPACKE_malloc( sizeof(float) * ldu_t * MAX(1,n) );
83 if( u_t == NULL ) {
85 goto exit_level_1;
86 }
87 }
88 if( ncc != 0 ) {
89 c_t = (float*)LAPACKE_malloc( sizeof(float) * ldc_t * MAX(1,ncc) );
90 if( c_t == NULL ) {
92 goto exit_level_2;
93 }
94 }
95 /* Transpose input matrices */
96 if( ncvt != 0 ) {
97 LAPACKE_sge_trans( matrix_layout, n, ncvt, vt, ldvt, vt_t, ldvt_t );
98 }
99 if( nru != 0 ) {
100 LAPACKE_sge_trans( matrix_layout, nru, n, u, ldu, u_t, ldu_t );
101 }
102 if( ncc != 0 ) {
103 LAPACKE_sge_trans( matrix_layout, n, ncc, c, ldc, c_t, ldc_t );
104 }
105 /* Call LAPACK function and adjust info */
106 LAPACK_sbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt_t, &ldvt_t, u_t,
107 &ldu_t, c_t, &ldc_t, work, &info );
108 if( info < 0 ) {
109 info = info - 1;
110 }
111 /* Transpose output matrices */
112 if( ncvt != 0 ) {
113 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, ncvt, vt_t, ldvt_t, vt,
114 ldvt );
115 }
116 if( nru != 0 ) {
117 LAPACKE_sge_trans( LAPACK_COL_MAJOR, nru, n, u_t, ldu_t, u, ldu );
118 }
119 if( ncc != 0 ) {
120 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, ncc, c_t, ldc_t, c, ldc );
121 }
122 /* Release memory and exit */
123 if( ncc != 0 ) {
124 LAPACKE_free( c_t );
125 }
126exit_level_2:
127 if( nru != 0 ) {
128 LAPACKE_free( u_t );
129 }
130exit_level_1:
131 if( ncvt != 0 ) {
132 LAPACKE_free( vt_t );
133 }
134exit_level_0:
135 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
136 LAPACKE_xerbla( "LAPACKE_sbdsqr_work", info );
137 }
138 } else {
139 info = -1;
140 LAPACKE_xerbla( "LAPACKE_sbdsqr_work", info );
141 }
142 return info;
143}
#define LAPACK_sbdsqr(...)
Definition lapack.h:356
#define lapack_int
Definition lapack.h:83
#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
void LAPACKE_xerbla(const char *name, lapack_int info)
void LAPACKE_sge_trans(int matrix_layout, lapack_int m, lapack_int n, const float *in, lapack_int ldin, float *out, lapack_int ldout)
#define MAX(x, y)
n