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_sspgv_work( int matrix_order, lapack_int itype, char jobz,
00038 char uplo, lapack_int n, float* ap, float* bp,
00039 float* w, float* z, lapack_int ldz, float* work )
00040 {
00041 lapack_int info = 0;
00042 if( matrix_order == LAPACK_COL_MAJOR ) {
00043
00044 LAPACK_sspgv( &itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work,
00045 &info );
00046 if( info < 0 ) {
00047 info = info - 1;
00048 }
00049 } else if( matrix_order == LAPACK_ROW_MAJOR ) {
00050 lapack_int ldz_t = MAX(1,n);
00051 float* z_t = NULL;
00052 float* ap_t = NULL;
00053 float* bp_t = NULL;
00054
00055 if( ldz < n ) {
00056 info = -10;
00057 LAPACKE_xerbla( "LAPACKE_sspgv_work", info );
00058 return info;
00059 }
00060
00061 if( LAPACKE_lsame( jobz, 'v' ) ) {
00062 z_t = (float*)LAPACKE_malloc( sizeof(float) * ldz_t * MAX(1,n) );
00063 if( z_t == NULL ) {
00064 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00065 goto exit_level_0;
00066 }
00067 }
00068 ap_t = (float*)
00069 LAPACKE_malloc( sizeof(float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 );
00070 if( ap_t == NULL ) {
00071 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00072 goto exit_level_1;
00073 }
00074 bp_t = (float*)
00075 LAPACKE_malloc( sizeof(float) * ( MAX(1,n) * MAX(2,n+1) ) / 2 );
00076 if( bp_t == NULL ) {
00077 info = LAPACK_TRANSPOSE_MEMORY_ERROR;
00078 goto exit_level_2;
00079 }
00080
00081 LAPACKE_ssp_trans( matrix_order, uplo, n, ap, ap_t );
00082 LAPACKE_ssp_trans( matrix_order, uplo, n, bp, bp_t );
00083
00084 LAPACK_sspgv( &itype, &jobz, &uplo, &n, ap_t, bp_t, w, z_t, &ldz_t,
00085 work, &info );
00086 if( info < 0 ) {
00087 info = info - 1;
00088 }
00089
00090 if( LAPACKE_lsame( jobz, 'v' ) ) {
00091 LAPACKE_sge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz );
00092 }
00093 LAPACKE_ssp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap );
00094 LAPACKE_ssp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp );
00095
00096 LAPACKE_free( bp_t );
00097 exit_level_2:
00098 LAPACKE_free( ap_t );
00099 exit_level_1:
00100 if( LAPACKE_lsame( jobz, 'v' ) ) {
00101 LAPACKE_free( z_t );
00102 }
00103 exit_level_0:
00104 if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) {
00105 LAPACKE_xerbla( "LAPACKE_sspgv_work", info );
00106 }
00107 } else {
00108 info = -1;
00109 LAPACKE_xerbla( "LAPACKE_sspgv_work", info );
00110 }
00111 return info;
00112 }