lapack_int LAPACKE_dspgst_work( int matrix_order, lapack_int itype, char uplo, lapack_int n, double* ap, const double* bp ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dspgst( &itype, &uplo, &n, ap, bp, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { double* ap_t = NULL; double* bp_t = NULL; /* Allocate memory for temporary array(s) */ ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } bp_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_dsp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_dsp_trans( matrix_order, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_dspgst( &itype, &uplo, &n, ap_t, bp_t, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_1: LAPACKE_free( ap_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dspgst_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dspgst_work", info ); } return info; }
lapack_int LAPACKE_dopgtr_work( int matrix_order, char uplo, lapack_int n, const double* ap, const double* tau, double* q, lapack_int ldq, double* work ) { lapack_int info = 0; lapack_int ldq_t; double *q_t = NULL, *ap_t = NULL; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dopgtr( &uplo, &n, ap, tau, q, &ldq, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { ldq_t = MAX(1,n); /* Check leading dimension(s) */ if( ldq < n ) { info = -7; LAPACKE_xerbla( "LAPACKE_dopgtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ q_t = (double*)LAPACKE_malloc( sizeof(double) * ldq_t * MAX(1,n) ); if( q_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_dsp_trans( matrix_order, uplo, n, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_dopgtr( &uplo, &n, ap_t, tau, q_t, &ldq_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, q_t, ldq_t, q, ldq ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( q_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dopgtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dopgtr_work", info ); } return info; }
lapack_int LAPACKE_dspgv_work( int matrix_order, lapack_int itype, char jobz, char uplo, lapack_int n, double* ap, double* bp, double* w, double* z, lapack_int ldz, double* work ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dspgv( &itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldz_t = MAX(1,n); double* z_t = NULL; double* ap_t = NULL; double* bp_t = NULL; /* Check leading dimension(s) */ if( ldz < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); return info; } /* Allocate memory for temporary array(s) */ if( LAPACKE_lsame( jobz, 'v' ) ) { z_t = (double*)LAPACKE_malloc( sizeof(double) * ldz_t * MAX(1,n) ); if( z_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } } ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } bp_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( bp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } /* Transpose input matrices */ LAPACKE_dsp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_dsp_trans( matrix_order, uplo, n, bp, bp_t ); /* Call LAPACK function and adjust info */ LAPACK_dspgv( &itype, &jobz, &uplo, &n, ap_t, bp_t, w, z_t, &ldz_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, n, z_t, ldz_t, z, ldz ); } LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, ap_t, ap ); LAPACKE_dsp_trans( LAPACK_COL_MAJOR, uplo, n, bp_t, bp ); /* Release memory and exit */ LAPACKE_free( bp_t ); exit_level_2: LAPACKE_free( ap_t ); exit_level_1: if( LAPACKE_lsame( jobz, 'v' ) ) { LAPACKE_free( z_t ); } exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dspgv_work", info ); } return info; }
lapack_int LAPACKE_dopmtr_work( int matrix_order, char side, char uplo, char trans, lapack_int m, lapack_int n, const double* ap, const double* tau, double* c, lapack_int ldc, double* work ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dopmtr( &side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int r = LAPACKE_lsame( side, 'l' ) ? m : n; lapack_int ldc_t = MAX(1,m); double* c_t = NULL; double* ap_t = NULL; /* Check leading dimension(s) */ if( ldc < n ) { info = -10; LAPACKE_xerbla( "LAPACKE_dopmtr_work", info ); return info; } /* Allocate memory for temporary array(s) */ c_t = (double*)LAPACKE_malloc( sizeof(double) * ldc_t * MAX(1,n) ); if( c_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,r) * MAX(2,r+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_order, m, n, c, ldc, c_t, ldc_t ); LAPACKE_dsp_trans( matrix_order, uplo, r, ap, ap_t ); /* Call LAPACK function and adjust info */ LAPACK_dopmtr( &side, &uplo, &trans, &m, &n, ap_t, tau, c_t, &ldc_t, work, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, m, n, c_t, ldc_t, c, ldc ); /* Release memory and exit */ LAPACKE_free( ap_t ); exit_level_1: LAPACKE_free( c_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dopmtr_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dopmtr_work", info ); } return info; }
lapack_int LAPACKE_dsprfs_work( int matrix_order, char uplo, lapack_int n, lapack_int nrhs, const double* ap, const double* afp, const lapack_int* ipiv, const double* b, lapack_int ldb, double* x, lapack_int ldx, double* ferr, double* berr, double* work, lapack_int* iwork ) { lapack_int info = 0; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ LAPACK_dsprfs( &uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int ldb_t = MAX(1,n); lapack_int ldx_t = MAX(1,n); double* b_t = NULL; double* x_t = NULL; double* ap_t = NULL; double* afp_t = NULL; /* Check leading dimension(s) */ if( ldb < nrhs ) { info = -9; LAPACKE_xerbla( "LAPACKE_dsprfs_work", info ); return info; } if( ldx < nrhs ) { info = -11; LAPACKE_xerbla( "LAPACKE_dsprfs_work", info ); return info; } /* Allocate memory for temporary array(s) */ b_t = (double*)LAPACKE_malloc( sizeof(double) * ldb_t * MAX(1,nrhs) ); if( b_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } x_t = (double*)LAPACKE_malloc( sizeof(double) * ldx_t * MAX(1,nrhs) ); if( x_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_1; } ap_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( ap_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_2; } afp_t = (double*) LAPACKE_malloc( sizeof(double) * ( MAX(1,n) * MAX(2,n+1) ) / 2 ); if( afp_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_3; } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_order, n, nrhs, b, ldb, b_t, ldb_t ); LAPACKE_dge_trans( matrix_order, n, nrhs, x, ldx, x_t, ldx_t ); LAPACKE_dsp_trans( matrix_order, uplo, n, ap, ap_t ); LAPACKE_dsp_trans( matrix_order, uplo, n, afp, afp_t ); /* Call LAPACK function and adjust info */ LAPACK_dsprfs( &uplo, &n, &nrhs, ap_t, afp_t, ipiv, b_t, &ldb_t, x_t, &ldx_t, ferr, berr, work, iwork, &info ); if( info < 0 ) { info = info - 1; } /* Transpose output matrices */ LAPACKE_dge_trans( LAPACK_COL_MAJOR, n, nrhs, x_t, ldx_t, x, ldx ); /* Release memory and exit */ LAPACKE_free( afp_t ); exit_level_3: LAPACKE_free( ap_t ); exit_level_2: LAPACKE_free( x_t ); exit_level_1: LAPACKE_free( b_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dsprfs_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dsprfs_work", info ); } return info; }