00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "lapacke.h"
00035 #include "lapacke_utils.h"
00036
00037 lapack_int LAPACKE_cbdsqr_work( int matrix_order, char uplo, lapack_int n,
00038 lapack_int ncvt, lapack_int nru, lapack_int ncc,
00039 float* d, float* e, lapack_complex_float* vt,
00040 lapack_int ldvt, lapack_complex_float* u,
00041 lapack_int ldu, lapack_complex_float* c,
00042 lapack_int ldc, float* work )
00043 {
00044 lapack_int info = 0;
00045 if( matrix_order == LAPACK_COL_MAJOR ) {
00046
00047 LAPACK_cbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt, &ldvt, u, &ldu,
00048 c, &ldc, work, &info );
00049 if( info < 0 ) {
00050 info = info - 1;
00051 }
00052 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00053 lapack_int ldc_t = MAX(1,n);
00054 lapack_int ldu_t = MAX(1,nru);
00055 lapack_int ldvt_t = MAX(1,n);
00056 lapack_complex_float* vt_t = NULL;
00057 lapack_complex_float* u_t = NULL;
00058 lapack_complex_float* c_t = NULL;
00059
00060 if( ldc < ncc ) {
00061 info = -14;
00062 LAPACKE_xerbla( "LAPACKE_cbdsqr_work", info );
00063 return info;
00064 }
00065 if( ldu < n ) {
00066 info = -12;
00067 LAPACKE_xerbla( "LAPACKE_cbdsqr_work", info );
00068 return info;
00069 }
00070 if( ldvt < ncvt ) {
00071 info = -10;
00072 LAPACKE_xerbla( "LAPACKE_cbdsqr_work", info );
00073 return info;
00074 }
00075
00076 if( ncvt != 0 ) {
00077 vt_t = (lapack_complex_float*)
00078 LAPACKE_malloc( sizeof(lapack_complex_float) *
00079 ldvt_t * MAX(1,ncvt) );
00080 if( vt_t == NULL ) {
00081 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00082 goto exit_level_0;
00083 }
00084 }
00085 if( nru != 0 ) {
00086 u_t = (lapack_complex_float*)
00087 LAPACKE_malloc( sizeof(lapack_complex_float) *
00088 ldu_t * MAX(1,n) );
00089 if( u_t == NULL ) {
00090 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00091 goto exit_level_1;
00092 }
00093 }
00094 if( ncc != 0 ) {
00095 c_t = (lapack_complex_float*)
00096 LAPACKE_malloc( sizeof(lapack_complex_float) *
00097 ldc_t * MAX(1,ncc) );
00098 if( c_t == NULL ) {
00099 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00100 goto exit_level_2;
00101 }
00102 }
00103
00104 if( ncvt != 0 ) {
00105 LAPACKE_cge_trans( matrix_order, n, ncvt, vt, ldvt, vt_t, ldvt_t );
00106 }
00107 if( nru != 0 ) {
00108 LAPACKE_cge_trans( matrix_order, nru, n, u, ldu, u_t, ldu_t );
00109 }
00110 if( ncc != 0 ) {
00111 LAPACKE_cge_trans( matrix_order, n, ncc, c, ldc, c_t, ldc_t );
00112 }
00113
00114 LAPACK_cbdsqr( &uplo, &n, &ncvt, &nru, &ncc, d, e, vt_t, &ldvt_t, u_t,
00115 &ldu_t, c_t, &ldc_t, work, &info );
00116 if( info < 0 ) {
00117 info = info - 1;
00118 }
00119
00120 if( ncvt != 0 ) {
00121 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, ncvt, vt_t, ldvt_t, vt,
00122 ldvt );
00123 }
00124 if( nru != 0 ) {
00125 LAPACKE_cge_trans( LAPACK_COL_MAJOR, nru, n, u_t, ldu_t, u, ldu );
00126 }
00127 if( ncc != 0 ) {
00128 LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, ncc, c_t, ldc_t, c, ldc );
00129 }
00130
00131 if( ncc != 0 ) {
00132 LAPACKE_free( c_t );
00133 }
00134 exit_level_2:
00135 if( nru != 0 ) {
00136 LAPACKE_free( u_t );
00137 }
00138 exit_level_1:
00139 if( ncvt != 0 ) {
00140 LAPACKE_free( vt_t );
00141 }
00142 exit_level_0:
00143 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00144 LAPACKE_xerbla( "LAPACKE_cbdsqr_work", info );
00145 }
00146 } else {
00147 info = -1;
00148 LAPACKE_xerbla( "LAPACKE_cbdsqr_work", info );
00149 }
00150 return info;
00151 }