double LAPACKE_dlange_work( int matrix_layout, char norm, lapack_int m, lapack_int n, const double* a, lapack_int lda, double* work ) { lapack_int info = 0; double res = 0.; char norm_lapack; if( matrix_layout == LAPACK_COL_MAJOR ) { /* Call LAPACK function */ res = LAPACK_dlange( &norm, &m, &n, a, &lda, work ); } else if( matrix_layout == LAPACK_ROW_MAJOR ) { double* work_lapack = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -6; LAPACKE_xerbla( "LAPACKE_dlange_work", info ); return info; } if( LAPACKE_lsame( norm, '1' ) || LAPACKE_lsame( norm, 'o' ) ) { norm_lapack = 'i'; } else if( LAPACKE_lsame( norm, 'i' ) ) { norm_lapack = '1'; } else { norm_lapack = norm; } /* Allocate memory for work array(s) */ if( LAPACKE_lsame( norm_lapack, 'i' ) ) { work_lapack = (double*)LAPACKE_malloc( sizeof(double) * MAX(1,n) ); if( work_lapack == NULL ) { info = LAPACK_WORK_MEMORY_ERROR; goto exit_level_0; } } /* Call LAPACK function */ res = LAPACK_dlange( &norm_lapack, &n, &m, a, &lda, work_lapack ); /* Release memory and exit */ if( work_lapack ) { LAPACKE_free( work_lapack ); } exit_level_0: if( info == LAPACK_WORK_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dlange_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dlange_work", info ); } return res; }
double LAPACKE_dlange_work( int matrix_order, char norm, lapack_int m, lapack_int n, const double* a, lapack_int lda, double* work ) { lapack_int info = 0; double res = 0.; if( matrix_order == LAPACK_COL_MAJOR ) { /* Call LAPACK function and adjust info */ res = LAPACK_dlange( &norm, &m, &n, a, &lda, work ); if( info < 0 ) { info = info - 1; } } else if( matrix_order == LAPACK_ROW_MAJOR ) { lapack_int lda_t = MAX(1,m); double* a_t = NULL; /* Check leading dimension(s) */ if( lda < n ) { info = -6; LAPACKE_xerbla( "LAPACKE_dlange_work", info ); return info; } /* Allocate memory for temporary array(s) */ a_t = (double*)LAPACKE_malloc( sizeof(double) * lda_t * MAX(1,n) ); if( a_t == NULL ) { info = LAPACK_TRANSPOSE_MEMORY_ERROR; goto exit_level_0; } /* Transpose input matrices */ LAPACKE_dge_trans( matrix_order, m, n, a, lda, a_t, lda_t ); /* Call LAPACK function and adjust info */ res = LAPACK_dlange( &norm, &m, &n, a_t, &lda_t, work ); info = 0; /* LAPACK call is ok! */ /* Release memory and exit */ LAPACKE_free( a_t ); exit_level_0: if( info == LAPACK_TRANSPOSE_MEMORY_ERROR ) { LAPACKE_xerbla( "LAPACKE_dlange_work", info ); } } else { info = -1; LAPACKE_xerbla( "LAPACKE_dlange_work", info ); } return res; }