diff --git a/CMakeLists.txt b/CMakeLists.txt index 844d5ad9..b5c4c7a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,7 +301,6 @@ add_library( src/lagge.cc src/laghe.cc src/lagsy.cc - src/lamch.cc src/langb.cc src/lange.cc src/langt.cc diff --git a/src/bbcsd.cc b/src/bbcsd.cc index 40cdcddb..4e4e2f1c 100644 --- a/src/bbcsd.cc +++ b/src/bbcsd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -36,28 +37,18 @@ int64_t bbcsd( float* B22D, float* B22E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv2t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); char jobv2t_ = to_char_csd( jobv2t ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; - lapack_int ldv2t_ = (lapack_int) ldv2t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); + lapack_int ldv2t_ = to_lapack_int( ldv2t ); lapack_int info_ = 0; // query for workspace size @@ -132,28 +123,18 @@ int64_t bbcsd( double* B22D, double* B22E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv2t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); char jobv2t_ = to_char_csd( jobv2t ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; - lapack_int ldv2t_ = (lapack_int) ldv2t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); + lapack_int ldv2t_ = to_lapack_int( ldv2t ); lapack_int info_ = 0; // query for workspace size @@ -228,28 +209,18 @@ int64_t bbcsd( float* B22D, float* B22E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv2t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); char jobv2t_ = to_char_csd( jobv2t ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; - lapack_int ldv2t_ = (lapack_int) ldv2t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); + lapack_int ldv2t_ = to_lapack_int( ldv2t ); lapack_int info_ = 0; // query for workspace size @@ -509,28 +480,18 @@ int64_t bbcsd( double* B22D, double* B22E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv2t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); char jobv2t_ = to_char_csd( jobv2t ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; - lapack_int ldv2t_ = (lapack_int) ldv2t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); + lapack_int ldv2t_ = to_lapack_int( ldv2t ); lapack_int info_ = 0; // query for workspace size diff --git a/src/bdsdc.cc b/src/bdsdc.cc index 779929f6..49a4c4f9 100644 --- a/src/bdsdc.cc +++ b/src/bdsdc.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,17 +27,11 @@ int64_t bdsdc( float* Q, int64_t* IQ ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // IQ disabled for now, due to complicated dimension @@ -192,17 +187,11 @@ int64_t bdsdc( double* Q, int64_t* IQ ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // IQ disabled for now, due to complicated dimension diff --git a/src/bdsqr.cc b/src/bdsqr.cc index 3975825d..75af4239 100644 --- a/src/bdsqr.cc +++ b/src/bdsqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,24 +26,14 @@ int64_t bdsqr( float* U, int64_t ldu, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nru) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ncvt_ = (lapack_int) ncvt; - lapack_int nru_ = (lapack_int) nru; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int ldvt_ = (lapack_int) ldvt; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int ncvt_ = to_lapack_int( ncvt ); + lapack_int nru_ = to_lapack_int( nru ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int ldvt_ = to_lapack_int( ldvt ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -73,24 +64,14 @@ int64_t bdsqr( double* U, int64_t ldu, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nru) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ncvt_ = (lapack_int) ncvt; - lapack_int nru_ = (lapack_int) nru; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int ldvt_ = (lapack_int) ldvt; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int ncvt_ = to_lapack_int( ncvt ); + lapack_int nru_ = to_lapack_int( nru ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int ldvt_ = to_lapack_int( ldvt ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -121,24 +102,14 @@ int64_t bdsqr( std::complex* U, int64_t ldu, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nru) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ncvt_ = (lapack_int) ncvt; - lapack_int nru_ = (lapack_int) nru; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int ldvt_ = (lapack_int) ldvt; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int ncvt_ = to_lapack_int( ncvt ); + lapack_int nru_ = to_lapack_int( nru ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int ldvt_ = to_lapack_int( ldvt ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -268,24 +239,14 @@ int64_t bdsqr( std::complex* U, int64_t ldu, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nru) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ncvt_ = (lapack_int) ncvt; - lapack_int nru_ = (lapack_int) nru; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int ldvt_ = (lapack_int) ldvt; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int ncvt_ = to_lapack_int( ncvt ); + lapack_int nru_ = to_lapack_int( nru ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int ldvt_ = to_lapack_int( ldvt ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace diff --git a/src/bdsvdx.cc b/src/bdsvdx.cc index 0d9ec5ee..502f2849 100644 --- a/src/bdsvdx.cc +++ b/src/bdsvdx.cc @@ -4,10 +4,11 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" -#if LAPACK_VERSION >= 30600 // >= v3.6 +#if LAPACK_VERSION >= 30600 // >= 3.6.0 #include @@ -27,21 +28,14 @@ int64_t bdsvdx( float* S, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -202,21 +196,14 @@ int64_t bdsvdx( double* S, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -241,4 +228,4 @@ int64_t bdsvdx( } // namespace lapack -#endif // LAPACK >= v3.6 +#endif // LAPACK >= 3.6.0 diff --git a/src/disna.cc b/src/disna.cc index 7ee3b91f..ca2b69ab 100644 --- a/src/disna.cc +++ b/src/disna.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t disna( float const* D, float* SEP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char jobcond_ = to_char( jobcond ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_sdisna( @@ -47,14 +43,9 @@ int64_t disna( double const* D, double* SEP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char jobcond_ = to_char( jobcond ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ddisna( diff --git a/src/gbbrd.cc b/src/gbbrd.cc index da625fda..703b584b 100644 --- a/src/gbbrd.cc +++ b/src/gbbrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,28 +27,16 @@ int64_t gbbrd( float* PT, int64_t ldpt, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldpt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldpt_ = (lapack_int) ldpt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldpt_ = to_lapack_int( ldpt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -80,28 +69,16 @@ int64_t gbbrd( double* PT, int64_t ldpt, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldpt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldpt_ = (lapack_int) ldpt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldpt_ = to_lapack_int( ldpt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -134,28 +111,16 @@ int64_t gbbrd( std::complex* PT, int64_t ldpt, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldpt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldpt_ = (lapack_int) ldpt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldpt_ = to_lapack_int( ldpt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace @@ -275,28 +240,16 @@ int64_t gbbrd( std::complex* PT, int64_t ldpt, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ncc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldpt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ncc_ = (lapack_int) ncc; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldpt_ = (lapack_int) ldpt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ncc_ = to_lapack_int( ncc ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldpt_ = to_lapack_int( ldpt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gbcon.cc b/src/gbcon.cc index b42a685e..956775a9 100644 --- a/src/gbcon.cc +++ b/src/gbcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,18 +24,11 @@ int64_t gbcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -69,18 +63,11 @@ int64_t gbcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -115,18 +102,11 @@ int64_t gbcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -213,18 +193,11 @@ int64_t gbcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/gbequ.cc b/src/gbequ.cc index 81dcc012..33f302aa 100644 --- a/src/gbequ.cc +++ b/src/gbequ.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -25,19 +26,11 @@ int64_t gbequ( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_sgbequ( @@ -62,19 +55,11 @@ int64_t gbequ( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_dgbequ( @@ -99,19 +84,11 @@ int64_t gbequ( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_cgbequ( @@ -201,19 +178,11 @@ int64_t gbequ( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_zgbequ( diff --git a/src/gbequb.cc b/src/gbequb.cc index 09c72f70..d0719456 100644 --- a/src/gbequb.cc +++ b/src/gbequb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -25,19 +26,11 @@ int64_t gbequb( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_sgbequb( @@ -62,19 +55,11 @@ int64_t gbequb( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_dgbequb( @@ -99,19 +84,11 @@ int64_t gbequb( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_cgbequb( @@ -208,19 +185,11 @@ int64_t gbequb( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_zgbequb( diff --git a/src/gbrfs.cc b/src/gbrfs.cc index 3012880d..4eff2a82 100644 --- a/src/gbrfs.cc +++ b/src/gbrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,24 +28,13 @@ int64_t gbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -52,8 +42,8 @@ int64_t gbrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -90,24 +80,13 @@ int64_t gbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -115,8 +94,8 @@ int64_t gbrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -153,24 +132,13 @@ int64_t gbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -178,8 +146,8 @@ int64_t gbrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -302,24 +270,13 @@ int64_t gbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -327,8 +284,8 @@ int64_t gbrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gbrfsx.cc b/src/gbrfsx.cc index 66b0d845..246bd7e3 100644 --- a/src/gbrfsx.cc +++ b/src/gbrfsx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -34,27 +35,14 @@ int64_t gbrfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -62,10 +50,10 @@ int64_t gbrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -111,27 +99,14 @@ int64_t gbrfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -139,10 +114,10 @@ int64_t gbrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -188,27 +163,14 @@ int64_t gbrfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -216,10 +178,10 @@ int64_t gbrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -566,27 +528,14 @@ int64_t gbrfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -594,10 +543,10 @@ int64_t gbrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gbsv.cc b/src/gbsv.cc index d680b74a..4ed22a0e 100644 --- a/src/gbsv.cc +++ b/src/gbsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,20 +24,11 @@ int64_t gbsv( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -44,7 +36,7 @@ int64_t gbsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgbsv( @@ -69,20 +61,11 @@ int64_t gbsv( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -90,7 +73,7 @@ int64_t gbsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgbsv( @@ -115,20 +98,11 @@ int64_t gbsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -136,7 +110,7 @@ int64_t gbsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgbsv( @@ -243,20 +217,11 @@ int64_t gbsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -264,7 +229,7 @@ int64_t gbsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgbsv( diff --git a/src/gbsvx.cc b/src/gbsvx.cc index cdc44026..a5840843 100644 --- a/src/gbsvx.cc +++ b/src/gbsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -31,26 +32,15 @@ int64_t gbsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -58,8 +48,8 @@ int64_t gbsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -107,26 +97,15 @@ int64_t gbsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -134,8 +113,8 @@ int64_t gbsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -183,26 +162,15 @@ int64_t gbsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -210,8 +178,8 @@ int64_t gbsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -480,26 +448,15 @@ int64_t gbsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -507,8 +464,8 @@ int64_t gbsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gbtrf.cc b/src/gbtrf.cc index 74ebd709..da3ccd8f 100644 --- a/src/gbtrf.cc +++ b/src/gbtrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,11 @@ int64_t gbtrf( float* AB, int64_t ldab, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (min(m,n)) ); @@ -64,19 +57,11 @@ int64_t gbtrf( double* AB, int64_t ldab, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (min(m,n)) ); @@ -106,19 +91,11 @@ int64_t gbtrf( std::complex* AB, int64_t ldab, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (min(m,n)) ); @@ -216,19 +193,11 @@ int64_t gbtrf( std::complex* AB, int64_t ldab, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (min(m,n)) ); diff --git a/src/gbtrs.cc b/src/gbtrs.cc index ba7932f9..83662281 100644 --- a/src/gbtrs.cc +++ b/src/gbtrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,12 @@ int64_t gbtrs( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -45,7 +37,7 @@ int64_t gbtrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgbtrs( @@ -68,21 +60,12 @@ int64_t gbtrs( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -90,7 +73,7 @@ int64_t gbtrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgbtrs( @@ -113,21 +96,12 @@ int64_t gbtrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -135,7 +109,7 @@ int64_t gbtrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgbtrs( @@ -220,21 +194,12 @@ int64_t gbtrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -242,7 +207,7 @@ int64_t gbtrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgbtrs( diff --git a/src/gebak.cc b/src/gebak.cc index 4987ca06..210fd7db 100644 --- a/src/gebak.cc +++ b/src/gebak.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,21 +22,13 @@ int64_t gebak( float const* scale, int64_t m, float* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_sgebak( @@ -56,21 +49,13 @@ int64_t gebak( double const* scale, int64_t m, double* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_dgebak( @@ -91,21 +76,13 @@ int64_t gebak( float const* scale, int64_t m, std::complex* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_cgebak( @@ -175,21 +152,13 @@ int64_t gebak( double const* scale, int64_t m, std::complex* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_zgebak( diff --git a/src/gebal.cc b/src/gebal.cc index 802c0343..c06b1f05 100644 --- a/src/gebal.cc +++ b/src/gebal.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,16 +24,11 @@ int64_t gebal( int64_t* ihi, float* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; LAPACK_sgebal( @@ -57,16 +53,11 @@ int64_t gebal( int64_t* ihi, double* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; LAPACK_dgebal( @@ -91,16 +82,11 @@ int64_t gebal( int64_t* ihi, float* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; LAPACK_cgebal( @@ -214,16 +200,11 @@ int64_t gebal( int64_t* ihi, double* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; LAPACK_zgebal( diff --git a/src/gebrd.cc b/src/gebrd.cc index 61645252..1db459c2 100644 --- a/src/gebrd.cc +++ b/src/gebrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,15 +26,9 @@ int64_t gebrd( float* tauq, float* taup ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -79,15 +74,9 @@ int64_t gebrd( double* tauq, double* taup ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -133,15 +122,9 @@ int64_t gebrd( std::complex* tauq, std::complex* taup ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -315,15 +298,9 @@ int64_t gebrd( std::complex* tauq, std::complex* taup ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gecon.cc b/src/gecon.cc index 2b7671b6..72889023 100644 --- a/src/gecon.cc +++ b/src/gecon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t gecon( float const* A, int64_t lda, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t gecon( double const* A, int64_t lda, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -88,14 +79,9 @@ int64_t gecon( std::complex const* A, int64_t lda, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -159,14 +145,9 @@ int64_t gecon( std::complex const* A, int64_t lda, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/geequ.cc b/src/geequ.cc index d52a6bf3..d1f1e874 100644 --- a/src/geequ.cc +++ b/src/geequ.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -25,15 +26,9 @@ int64_t geequ( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_sgeequ( @@ -58,15 +53,9 @@ int64_t geequ( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dgeequ( @@ -91,15 +80,9 @@ int64_t geequ( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cgeequ( @@ -181,15 +164,9 @@ int64_t geequ( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zgeequ( diff --git a/src/geequb.cc b/src/geequb.cc index 026ad9cf..d735ddb0 100644 --- a/src/geequb.cc +++ b/src/geequb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -25,15 +26,9 @@ int64_t geequb( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_sgeequb( @@ -58,15 +53,9 @@ int64_t geequb( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dgeequb( @@ -91,15 +80,9 @@ int64_t geequb( float* colcnd, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cgeequb( @@ -188,15 +171,9 @@ int64_t geequb( double* colcnd, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zgeequb( diff --git a/src/gees.cc b/src/gees.cc index 19805680..a95d3318 100644 --- a/src/gees.cc +++ b/src/gees.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,18 +24,12 @@ int64_t gees( std::complex* W, float* VS, int64_t ldvs ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // split-complex representation @@ -93,18 +88,12 @@ int64_t gees( std::complex* W, double* VS, int64_t ldvs ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // split-complex representation @@ -163,18 +152,12 @@ int64_t gees( std::complex* W, std::complex* VS, int64_t ldvs ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // query for workspace size @@ -227,18 +210,12 @@ int64_t gees( std::complex* W, std::complex* VS, int64_t ldvs ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geesx.cc b/src/geesx.cc index f988387c..429b83a5 100644 --- a/src/geesx.cc +++ b/src/geesx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,19 +26,13 @@ int64_t geesx( float* rconde, float* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // split-complex representation @@ -103,19 +98,13 @@ int64_t geesx( double* rconde, double* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // split-complex representation @@ -181,19 +170,13 @@ int64_t geesx( float* rconde, float* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // query for workspace size @@ -248,19 +231,13 @@ int64_t geesx( double* rconde, double* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvs) > std::numeric_limits::max() ); - } char jobvs_ = to_char( jobvs ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvs_ = (lapack_int) ldvs; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int sdim_ = 0; // out + lapack_int ldvs_ = to_lapack_int( ldvs ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geev.cc b/src/geev.cc index a8b27675..dca777eb 100644 --- a/src/geev.cc +++ b/src/geev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t geev( float* VL, int64_t ldvl, float* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -89,19 +83,12 @@ int64_t geev( double* VL, int64_t ldvl, double* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -154,19 +141,12 @@ int64_t geev( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size @@ -315,19 +295,12 @@ int64_t geev( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gehrd.cc b/src/gehrd.cc index 9d923244..5f464e5b 100644 --- a/src/gehrd.cc +++ b/src/gehrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t gehrd( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -69,17 +63,10 @@ int64_t gehrd( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -116,17 +103,10 @@ int64_t gehrd( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -240,17 +220,10 @@ int64_t gehrd( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gelq.cc b/src/gelq.cc index 3215725f..8e1a6193 100644 --- a/src/gelq.cc +++ b/src/gelq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t gelq( float* A, int64_t lda, float* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -69,17 +63,10 @@ int64_t gelq( double* A, int64_t lda, double* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -115,17 +102,10 @@ int64_t gelq( std::complex* A, int64_t lda, std::complex* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -161,17 +141,10 @@ int64_t gelq( std::complex* A, int64_t lda, std::complex* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gelq2.cc b/src/gelq2.cc index 54f35d4b..4f81e735 100644 --- a/src/gelq2.cc +++ b/src/gelq2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t gelq2( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -54,15 +49,9 @@ int64_t gelq2( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -86,15 +75,9 @@ int64_t gelq2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -167,15 +150,9 @@ int64_t gelq2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gelqf.cc b/src/gelqf.cc index d04dd695..0408a0b0 100644 --- a/src/gelqf.cc +++ b/src/gelqf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t gelqf( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,15 +62,9 @@ int64_t gelqf( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -112,15 +101,9 @@ int64_t gelqf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -206,15 +189,9 @@ int64_t gelqf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gels.cc b/src/gels.cc index 0a6dd243..815edffd 100644 --- a/src/gels.cc +++ b/src/gels.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,20 +27,12 @@ int64_t gels( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -82,20 +75,12 @@ int64_t gels( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -134,20 +119,12 @@ int64_t gels( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -276,20 +253,12 @@ int64_t gels( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gelsd.cc b/src/gelsd.cc index f49a6ed9..329b80ce 100644 --- a/src/gelsd.cc +++ b/src/gelsd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,20 +25,12 @@ int64_t gelsd( float* S, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -84,20 +77,12 @@ int64_t gelsd( double* S, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -144,20 +129,12 @@ int64_t gelsd( float* S, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -290,20 +267,12 @@ int64_t gelsd( double* S, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size diff --git a/src/gelss.cc b/src/gelss.cc index f9ff1249..4cddabff 100644 --- a/src/gelss.cc +++ b/src/gelss.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,20 +25,12 @@ int64_t gelss( float* S, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -79,20 +72,12 @@ int64_t gelss( double* S, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -134,20 +119,12 @@ int64_t gelss( float* S, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -260,20 +237,12 @@ int64_t gelss( double* S, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int rank_ = (lapack_int) *rank; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size diff --git a/src/gelsy.cc b/src/gelsy.cc index 1e62bae3..836586e2 100644 --- a/src/gelsy.cc +++ b/src/gelsy.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,11 @@ int64_t gelsy( int64_t* jpvt, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -44,7 +37,7 @@ int64_t gelsy( #else lapack_int* jpvt_ptr = jpvt; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -89,19 +82,11 @@ int64_t gelsy( int64_t* jpvt, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -109,7 +94,7 @@ int64_t gelsy( #else lapack_int* jpvt_ptr = jpvt; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -154,19 +139,11 @@ int64_t gelsy( int64_t* jpvt, float rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -174,7 +151,7 @@ int64_t gelsy( #else lapack_int* jpvt_ptr = jpvt; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -322,19 +299,11 @@ int64_t gelsy( int64_t* jpvt, double rcond, int64_t* rank ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -342,7 +311,7 @@ int64_t gelsy( #else lapack_int* jpvt_ptr = jpvt; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // query for workspace size diff --git a/src/gemlq.cc b/src/gemlq.cc index b3ccc349..4483465e 100644 --- a/src/gemlq.cc +++ b/src/gemlq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,23 +25,14 @@ int64_t gemlq( float const* T, int64_t tsize, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -81,23 +73,14 @@ int64_t gemlq( double const* T, int64_t tsize, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -138,23 +121,14 @@ int64_t gemlq( std::complex const* T, int64_t tsize, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -195,23 +169,14 @@ int64_t gemlq( std::complex const* T, int64_t tsize, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gemqr.cc b/src/gemqr.cc index b663c2f9..e1f54244 100644 --- a/src/gemqr.cc +++ b/src/gemqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,23 +25,14 @@ int64_t gemqr( float const* T, int64_t tsize, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -81,23 +73,14 @@ int64_t gemqr( double const* T, int64_t tsize, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -138,23 +121,14 @@ int64_t gemqr( std::complex const* T, int64_t tsize, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -195,23 +169,14 @@ int64_t gemqr( std::complex const* T, int64_t tsize, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gemqrt.cc b/src/gemqrt.cc index 80e952e1..630a80da 100644 --- a/src/gemqrt.cc +++ b/src/gemqrt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30400 // >= 3.4.0 @@ -28,25 +29,15 @@ int64_t gemqrt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // Set workspace size @@ -80,25 +71,15 @@ int64_t gemqrt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // Set workspace size @@ -132,25 +113,15 @@ int64_t gemqrt( if (trans == Op::Trans) trans = Op::ConjTrans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // Set workspace size @@ -259,25 +230,15 @@ int64_t gemqrt( if (trans == Op::Trans) trans = Op::ConjTrans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // Set workspace size diff --git a/src/geql2.cc b/src/geql2.cc index b8bb16d7..cdeedbfb 100644 --- a/src/geql2.cc +++ b/src/geql2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t geql2( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -54,15 +49,9 @@ int64_t geql2( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -86,15 +75,9 @@ int64_t geql2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -172,15 +155,9 @@ int64_t geql2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/geqlf.cc b/src/geqlf.cc index 49bea48d..2c7a8afd 100644 --- a/src/geqlf.cc +++ b/src/geqlf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t geqlf( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,15 +62,9 @@ int64_t geqlf( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -112,15 +101,9 @@ int64_t geqlf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -211,15 +194,9 @@ int64_t geqlf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geqp3.cc b/src/geqp3.cc index 791e90f7..dab25e58 100644 --- a/src/geqp3.cc +++ b/src/geqp3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t geqp3( int64_t* jpvt, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -79,15 +74,9 @@ int64_t geqp3( int64_t* jpvt, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -136,15 +125,9 @@ int64_t geqp3( int64_t* jpvt, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); @@ -197,15 +180,9 @@ int64_t geqp3( int64_t* jpvt, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > jpvt_( &jpvt[0], &jpvt[(n)] ); diff --git a/src/geqr.cc b/src/geqr.cc index 4f1ef92b..1d3c776e 100644 --- a/src/geqr.cc +++ b/src/geqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,17 +25,10 @@ int64_t geqr( float* A, int64_t lda, float* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -75,17 +69,10 @@ int64_t geqr( double* A, int64_t lda, double* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -126,17 +113,10 @@ int64_t geqr( std::complex* A, int64_t lda, std::complex* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size @@ -266,17 +246,10 @@ int64_t geqr( std::complex* A, int64_t lda, std::complex* T, int64_t tsize ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(tsize) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int tsize_ = (lapack_int) tsize; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int tsize_ = to_lapack_int( tsize ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geqr2.cc b/src/geqr2.cc index 78d07384..0c69c03f 100644 --- a/src/geqr2.cc +++ b/src/geqr2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t geqr2( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -54,15 +49,9 @@ int64_t geqr2( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -86,15 +75,9 @@ int64_t geqr2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -170,15 +153,9 @@ int64_t geqr2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/geqrf.cc b/src/geqrf.cc index fedc1bd3..ab128b5c 100644 --- a/src/geqrf.cc +++ b/src/geqrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t geqrf( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,15 +62,9 @@ int64_t geqrf( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -112,15 +101,9 @@ int64_t geqrf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -208,15 +191,9 @@ int64_t geqrf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geqrfp.cc b/src/geqrfp.cc index f1475a26..78bfb387 100644 --- a/src/geqrfp.cc +++ b/src/geqrfp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,15 +24,9 @@ int64_t geqrfp( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,15 +62,9 @@ int64_t geqrfp( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -111,15 +100,9 @@ int64_t geqrfp( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -155,15 +138,9 @@ int64_t geqrfp( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/geqrt.cc b/src/geqrt.cc index 3753ca15..0845de7b 100644 --- a/src/geqrt.cc +++ b/src/geqrt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,19 +24,11 @@ int64_t geqrt( float* A, int64_t lda, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -58,19 +51,11 @@ int64_t geqrt( double* A, int64_t lda, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -93,19 +78,11 @@ int64_t geqrt( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -128,19 +105,11 @@ int64_t geqrt( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace diff --git a/src/geqrt2.cc b/src/geqrt2.cc index da6bbdc5..e44efc95 100644 --- a/src/geqrt2.cc +++ b/src/geqrt2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30400 // >= 3.4 @@ -22,17 +23,10 @@ int64_t geqrt2( float* A, int64_t lda, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_sgeqrt2( @@ -51,17 +45,10 @@ int64_t geqrt2( double* A, int64_t lda, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_dgeqrt2( @@ -80,17 +67,10 @@ int64_t geqrt2( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_cgeqrt2( @@ -109,17 +89,10 @@ int64_t geqrt2( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_zgeqrt2( diff --git a/src/geqrt3.cc b/src/geqrt3.cc index 968f2ae9..0ef7a046 100644 --- a/src/geqrt3.cc +++ b/src/geqrt3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30400 // >= 3.4 @@ -22,17 +23,10 @@ int64_t geqrt3( float* A, int64_t lda, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_sgeqrt3( @@ -51,17 +45,10 @@ int64_t geqrt3( double* A, int64_t lda, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_dgeqrt3( @@ -80,17 +67,10 @@ int64_t geqrt3( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_cgeqrt3( @@ -109,17 +89,10 @@ int64_t geqrt3( std::complex* A, int64_t lda, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_zgeqrt3( diff --git a/src/gerfs.cc b/src/gerfs.cc index 83224e24..807cba80 100644 --- a/src/gerfs.cc +++ b/src/gerfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,20 +28,11 @@ int64_t gerfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -48,8 +40,8 @@ int64_t gerfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -86,20 +78,11 @@ int64_t gerfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -107,8 +90,8 @@ int64_t gerfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -145,20 +128,11 @@ int64_t gerfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -166,8 +140,8 @@ int64_t gerfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -278,20 +252,11 @@ int64_t gerfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -299,8 +264,8 @@ int64_t gerfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gerfsx.cc b/src/gerfsx.cc index af0f42a7..0d6f8a2a 100644 --- a/src/gerfsx.cc +++ b/src/gerfsx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -34,23 +35,12 @@ int64_t gerfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -58,10 +48,10 @@ int64_t gerfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -107,23 +97,12 @@ int64_t gerfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -131,10 +110,10 @@ int64_t gerfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -180,23 +159,12 @@ int64_t gerfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -204,10 +172,10 @@ int64_t gerfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -525,23 +493,12 @@ int64_t gerfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -549,10 +506,10 @@ int64_t gerfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gerq2.cc b/src/gerq2.cc index 03f6829c..37c28175 100644 --- a/src/gerq2.cc +++ b/src/gerq2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t gerq2( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -54,15 +49,9 @@ int64_t gerq2( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -86,15 +75,9 @@ int64_t gerq2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -173,15 +156,9 @@ int64_t gerq2( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gerqf.cc b/src/gerqf.cc index 005a0039..d3e60281 100644 --- a/src/gerqf.cc +++ b/src/gerqf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t gerqf( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,15 +62,9 @@ int64_t gerqf( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -112,15 +101,9 @@ int64_t gerqf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -212,15 +195,9 @@ int64_t gerqf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gesdd.cc b/src/gesdd.cc index 4102971e..1b912cd0 100644 --- a/src/gesdd.cc +++ b/src/gesdd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,20 +25,12 @@ int64_t gesdd( float* U, int64_t ldu, float* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -86,20 +79,12 @@ int64_t gesdd( double* U, int64_t ldu, double* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -148,20 +133,12 @@ int64_t gesdd( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -333,20 +310,12 @@ int64_t gesdd( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gesv.cc b/src/gesv.cc index 91f69f99..dfa98d7b 100644 --- a/src/gesv.cc +++ b/src/gesv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,16 +24,9 @@ int64_t gesv( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -40,7 +34,7 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgesv( @@ -65,16 +59,9 @@ int64_t gesv( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -82,7 +69,7 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgesv( @@ -107,16 +94,9 @@ int64_t gesv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -124,7 +104,7 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgesv( @@ -198,16 +178,9 @@ int64_t gesv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -215,7 +188,7 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgesv( @@ -241,17 +214,9 @@ int64_t gesv( double* X, int64_t ldx, int64_t* iter ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -259,9 +224,9 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int iter_ = (lapack_int) *iter; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int iter_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -295,17 +260,9 @@ int64_t gesv( std::complex* X, int64_t ldx, int64_t* iter ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -313,9 +270,9 @@ int64_t gesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int iter_ = (lapack_int) *iter; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int iter_ = 0; // out lapack_int info_ = 0; // allocate workspace diff --git a/src/gesvd.cc b/src/gesvd.cc index 3df559cc..92367ef6 100644 --- a/src/gesvd.cc +++ b/src/gesvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,21 +25,13 @@ int64_t gesvd( float* U, int64_t ldu, float* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -83,21 +76,13 @@ int64_t gesvd( double* U, int64_t ldu, double* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -142,21 +127,13 @@ int64_t gesvd( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -314,21 +291,13 @@ int64_t gesvd( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gesvdx.cc b/src/gesvdx.cc index 21e36db2..a942f578 100644 --- a/src/gesvdx.cc +++ b/src/gesvdx.cc @@ -4,10 +4,11 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" -#if LAPACK_VERSION >= 30600 // >= v3.6 +#if LAPACK_VERSION >= 30600 // >= 3.6.0 #include @@ -27,27 +28,17 @@ int64_t gesvdx( float* U, int64_t ldu, float* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); char range_ = to_char( range ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -98,27 +89,17 @@ int64_t gesvdx( double* U, int64_t ldu, double* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); char range_ = to_char( range ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -169,27 +150,17 @@ int64_t gesvdx( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); char range_ = to_char( range ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -374,27 +345,17 @@ int64_t gesvdx( std::complex* U, int64_t ldu, std::complex* VT, int64_t ldvt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvt) > std::numeric_limits::max() ); - } char jobu_ = to_char( jobu ); char jobvt_ = to_char( jobvt ); char range_ = to_char( range ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldvt_ = (lapack_int) ldvt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldvt_ = to_lapack_int( ldvt ); lapack_int info_ = 0; // query for workspace size @@ -444,4 +405,4 @@ int64_t gesvdx( } // namespace lapack -#endif // LAPACK >= v3.6 +#endif // LAPACK >= 3.6.0 diff --git a/src/gesvx.cc b/src/gesvx.cc index 6bfd7b16..aec1b09d 100644 --- a/src/gesvx.cc +++ b/src/gesvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -32,22 +33,13 @@ int64_t gesvx( float* berr, float* rpivotgrowth ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -55,8 +47,8 @@ int64_t gesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -106,22 +98,13 @@ int64_t gesvx( double* berr, double* rpivotgrowth ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -129,8 +112,8 @@ int64_t gesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -180,22 +163,13 @@ int64_t gesvx( float* berr, float* rpivotgrowth ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -203,8 +177,8 @@ int64_t gesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -465,22 +439,13 @@ int64_t gesvx( double* berr, double* rpivotgrowth ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -488,8 +453,8 @@ int64_t gesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/getf2.cc b/src/getf2.cc index f5ae879c..870a4ce2 100644 --- a/src/getf2.cc +++ b/src/getf2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t getf2( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -60,15 +55,9 @@ int64_t getf2( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -98,15 +87,9 @@ int64_t getf2( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -178,15 +161,9 @@ int64_t getf2( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); diff --git a/src/getrf.cc b/src/getrf.cc index b6446ce5..03dc8790 100644 --- a/src/getrf.cc +++ b/src/getrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t getrf( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -60,15 +55,9 @@ int64_t getrf( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -98,15 +87,9 @@ int64_t getrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -178,15 +161,9 @@ int64_t getrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); diff --git a/src/getrf2.cc b/src/getrf2.cc index f00b4912..ff61bcb7 100644 --- a/src/getrf2.cc +++ b/src/getrf2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,9 @@ int64_t getrf2( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -62,15 +57,9 @@ int64_t getrf2( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -100,15 +89,9 @@ int64_t getrf2( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, min( m, n )) ); @@ -208,15 +191,9 @@ int64_t getrf2( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (min(m,n)) ); diff --git a/src/getri.cc b/src/getri.cc index f0259769..95e3e30b 100644 --- a/src/getri.cc +++ b/src/getri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,13 +23,8 @@ int64_t getri( float* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -73,13 +69,8 @@ int64_t getri( double* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -124,13 +115,8 @@ int64_t getri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -207,13 +193,8 @@ int64_t getri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); diff --git a/src/getrs.cc b/src/getrs.cc index 48774f4c..90f8f7d4 100644 --- a/src/getrs.cc +++ b/src/getrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t getrs( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -42,7 +36,7 @@ int64_t getrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgetrs( @@ -65,17 +59,10 @@ int64_t getrs( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -84,7 +71,7 @@ int64_t getrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgetrs( @@ -107,17 +94,10 @@ int64_t getrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -126,7 +106,7 @@ int64_t getrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgetrs( @@ -202,17 +182,10 @@ int64_t getrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( max( 1, (n) ) ); @@ -221,7 +194,7 @@ int64_t getrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgetrs( diff --git a/src/getsls.cc b/src/getsls.cc index b2470055..7921f127 100644 --- a/src/getsls.cc +++ b/src/getsls.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,20 +28,12 @@ int64_t getsls( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -95,20 +88,12 @@ int64_t getsls( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -159,20 +144,12 @@ int64_t getsls( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -223,20 +200,12 @@ int64_t getsls( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggbak.cc b/src/ggbak.cc index c14a1553..f2707730 100644 --- a/src/ggbak.cc +++ b/src/ggbak.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,21 +22,13 @@ int64_t ggbak( float const* rscale, int64_t m, float* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_sggbak( @@ -57,21 +50,13 @@ int64_t ggbak( double const* rscale, int64_t m, double* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_dggbak( @@ -93,21 +78,13 @@ int64_t ggbak( float const* rscale, int64_t m, std::complex* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_cggbak( @@ -129,21 +106,13 @@ int64_t ggbak( double const* rscale, int64_t m, std::complex* V, int64_t ldv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); char side_ = to_char( side ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int m_ = (lapack_int) m; - lapack_int ldv_ = (lapack_int) ldv; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int m_ = to_lapack_int( m ); + lapack_int ldv_ = to_lapack_int( ldv ); lapack_int info_ = 0; LAPACK_zggbak( diff --git a/src/ggbal.cc b/src/ggbal.cc index 6d5a1ead..624c12aa 100644 --- a/src/ggbal.cc +++ b/src/ggbal.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,18 +26,12 @@ int64_t ggbal( float* lscale, float* rscale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; // from docs @@ -71,18 +66,12 @@ int64_t ggbal( double* lscale, double* rscale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; // from docs @@ -117,18 +106,12 @@ int64_t ggbal( float* lscale, float* rscale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; // from docs @@ -163,18 +146,12 @@ int64_t ggbal( double* lscale, double* rscale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char balance_ = to_char( balance ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ilo_ = (lapack_int) *ilo; - lapack_int ihi_ = (lapack_int) *ihi; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ilo_ = 0; // out + lapack_int ihi_ = 0; // out lapack_int info_ = 0; // from docs diff --git a/src/gges.cc b/src/gges.cc index 023afe4c..4348a20d 100644 --- a/src/gges.cc +++ b/src/gges.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,23 +28,15 @@ int64_t gges( float* VSL, int64_t ldvsl, float* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -112,23 +105,15 @@ int64_t gges( double* VSL, int64_t ldvsl, double* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -197,23 +182,15 @@ int64_t gges( std::complex* VSL, int64_t ldvsl, std::complex* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size @@ -276,23 +253,15 @@ int64_t gges( std::complex* VSL, int64_t ldvsl, std::complex* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gges3.cc b/src/gges3.cc index 163bfc8c..c6394a5c 100644 --- a/src/gges3.cc +++ b/src/gges3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,23 +30,15 @@ int64_t gges3( float* VSL, int64_t ldvsl, float* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -114,23 +107,15 @@ int64_t gges3( double* VSL, int64_t ldvsl, double* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -199,23 +184,15 @@ int64_t gges3( std::complex* VSL, int64_t ldvsl, std::complex* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size @@ -278,23 +255,15 @@ int64_t gges3( std::complex* VSL, int64_t ldvsl, std::complex* VSR, int64_t ldvsr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggesx.cc b/src/ggesx.cc index 58038471..59f06642 100644 --- a/src/ggesx.cc +++ b/src/ggesx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,24 +30,16 @@ int64_t ggesx( float* rconde, float* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -126,24 +119,16 @@ int64_t ggesx( double* rconde, double* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // split-complex representation @@ -223,24 +208,16 @@ int64_t ggesx( float* rconde, float* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size @@ -314,24 +291,16 @@ int64_t ggesx( double* rconde, double* rcondv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvsr) > std::numeric_limits::max() ); - } char jobvsl_ = to_char( jobvsl ); char jobvsr_ = to_char( jobvsr ); char sort_ = to_char( sort ); char sense_ = to_char( sense ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int sdim_ = (lapack_int) *sdim; - lapack_int ldvsl_ = (lapack_int) ldvsl; - lapack_int ldvsr_ = (lapack_int) ldvsr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int sdim_ = 0; // out + lapack_int ldvsl_ = to_lapack_int( ldvsl ); + lapack_int ldvsr_ = to_lapack_int( ldvsr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggev.cc b/src/ggev.cc index eb25a80c..33173986 100644 --- a/src/ggev.cc +++ b/src/ggev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,21 +26,13 @@ int64_t ggev( float* VL, int64_t ldvl, float* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -97,21 +90,13 @@ int64_t ggev( double* VL, int64_t ldvl, double* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -169,21 +154,13 @@ int64_t ggev( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size @@ -237,21 +214,13 @@ int64_t ggev( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggev3.cc b/src/ggev3.cc index 2ecb6bdf..525cc829 100644 --- a/src/ggev3.cc +++ b/src/ggev3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,21 +28,13 @@ int64_t ggev3( float* VL, int64_t ldvl, float* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -99,21 +92,13 @@ int64_t ggev3( double* VL, int64_t ldvl, double* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // split-complex representation @@ -171,21 +156,13 @@ int64_t ggev3( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size @@ -239,21 +216,13 @@ int64_t ggev3( std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - } char jobvl_ = to_char( jobvl ); char jobvr_ = to_char( jobvr ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggglm.cc b/src/ggglm.cc index 353dea39..052ee1a3 100644 --- a/src/ggglm.cc +++ b/src/ggglm.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,19 +26,11 @@ int64_t ggglm( float* X, float* Y ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -83,19 +76,11 @@ int64_t ggglm( double* X, double* Y ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -141,19 +126,11 @@ int64_t ggglm( std::complex* X, std::complex* Y ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -283,19 +260,11 @@ int64_t ggglm( std::complex* X, std::complex* Y ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gghrd.cc b/src/gghrd.cc index b387f0d2..365f5df8 100644 --- a/src/gghrd.cc +++ b/src/gghrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,25 +23,15 @@ int64_t gghrd( float* Q, int64_t ldq, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; LAPACK_sgghrd( @@ -64,25 +55,15 @@ int64_t gghrd( double* Q, int64_t ldq, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; LAPACK_dgghrd( @@ -106,25 +87,15 @@ int64_t gghrd( std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; LAPACK_cgghrd( @@ -148,25 +119,15 @@ int64_t gghrd( std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; LAPACK_zgghrd( diff --git a/src/gglse.cc b/src/gglse.cc index bde0e7b8..f7581fae 100644 --- a/src/gglse.cc +++ b/src/gglse.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,19 +26,11 @@ int64_t gglse( float* D, float* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -83,19 +76,11 @@ int64_t gglse( double* D, double* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -141,19 +126,11 @@ int64_t gglse( std::complex* D, std::complex* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -290,19 +267,11 @@ int64_t gglse( std::complex* D, std::complex* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggqrf.cc b/src/ggqrf.cc index aaa43612..8b4c7449 100644 --- a/src/ggqrf.cc +++ b/src/ggqrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,19 +24,11 @@ int64_t ggqrf( float* B, int64_t ldb, float* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -77,19 +70,11 @@ int64_t ggqrf( double* B, int64_t ldb, double* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -131,19 +116,11 @@ int64_t ggqrf( std::complex* B, int64_t ldb, std::complex* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -185,19 +162,11 @@ int64_t ggqrf( std::complex* B, int64_t ldb, std::complex* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggrqf.cc b/src/ggrqf.cc index ea8cac88..f2ead9f0 100644 --- a/src/ggrqf.cc +++ b/src/ggrqf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,19 +24,11 @@ int64_t ggrqf( float* B, int64_t ldb, float* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -77,19 +70,11 @@ int64_t ggrqf( double* B, int64_t ldb, double* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -131,19 +116,11 @@ int64_t ggrqf( std::complex* B, int64_t ldb, std::complex* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -185,19 +162,11 @@ int64_t ggrqf( std::complex* B, int64_t ldb, std::complex* taub ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggsvd3.cc b/src/ggsvd3.cc index 36e41ee1..e9c8de50 100644 --- a/src/ggsvd3.cc +++ b/src/ggsvd3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -30,30 +31,19 @@ int64_t ggsvd3( float* V, int64_t ldv, float* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -114,30 +104,19 @@ int64_t ggsvd3( double* V, int64_t ldv, double* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -198,30 +177,19 @@ int64_t ggsvd3( std::complex* V, int64_t ldv, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -286,30 +254,19 @@ int64_t ggsvd3( std::complex* V, int64_t ldv, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int p_ = (lapack_int) p; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int p_ = to_lapack_int( p ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ggsvp3.cc b/src/ggsvp3.cc index 170592f5..d7facb17 100644 --- a/src/ggsvp3.cc +++ b/src/ggsvp3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,30 +30,19 @@ int64_t ggsvp3( float* Q, int64_t ldq, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -110,30 +100,19 @@ int64_t ggsvp3( double* Q, int64_t ldq, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -191,30 +170,19 @@ int64_t ggsvp3( std::complex* Q, int64_t ldq, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size @@ -276,30 +244,19 @@ int64_t ggsvp3( std::complex* Q, int64_t ldq, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_jobu( jobu ); char jobv_ = to_char( jobv ); char jobq_ = to_char_jobq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int k_ = (lapack_int) *k; - lapack_int l_ = (lapack_int) *l; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int k_ = 0; // out + lapack_int l_ = 0; // out + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // query for workspace size diff --git a/src/gtcon.cc b/src/gtcon.cc index 51d8c0a1..94076981 100644 --- a/src/gtcon.cc +++ b/src/gtcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,12 +27,8 @@ int64_t gtcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -72,12 +69,8 @@ int64_t gtcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -118,12 +111,8 @@ int64_t gtcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -218,12 +207,8 @@ int64_t gtcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/gtrfs.cc b/src/gtrfs.cc index 1fa5f27e..8422723d 100644 --- a/src/gtrfs.cc +++ b/src/gtrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -32,16 +33,9 @@ int64_t gtrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -49,8 +43,8 @@ int64_t gtrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -97,16 +91,9 @@ int64_t gtrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -114,8 +101,8 @@ int64_t gtrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -162,16 +149,9 @@ int64_t gtrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -179,8 +159,8 @@ int64_t gtrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -318,16 +298,9 @@ int64_t gtrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -335,8 +308,8 @@ int64_t gtrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gtsv.cc b/src/gtsv.cc index 19451255..12cf3fb6 100644 --- a/src/gtsv.cc +++ b/src/gtsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,15 +24,9 @@ int64_t gtsv( float* DU, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgtsv( @@ -55,15 +50,9 @@ int64_t gtsv( double* DU, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgtsv( @@ -87,15 +76,9 @@ int64_t gtsv( std::complex* DU, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgtsv( @@ -170,15 +153,9 @@ int64_t gtsv( std::complex* DU, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgtsv( diff --git a/src/gtsvx.cc b/src/gtsvx.cc index dc0daadc..935f7181 100644 --- a/src/gtsvx.cc +++ b/src/gtsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -33,17 +34,10 @@ int64_t gtsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -51,8 +45,8 @@ int64_t gtsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -103,17 +97,10 @@ int64_t gtsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -121,8 +108,8 @@ int64_t gtsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -173,17 +160,10 @@ int64_t gtsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -191,8 +171,8 @@ int64_t gtsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -399,17 +379,10 @@ int64_t gtsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -417,8 +390,8 @@ int64_t gtsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/gttrf.cc b/src/gttrf.cc index 176eb1c9..84713139 100644 --- a/src/gttrf.cc +++ b/src/gttrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,11 +26,7 @@ int64_t gttrf( float* DU2, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -65,11 +62,7 @@ int64_t gttrf( double* DU2, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -105,11 +98,7 @@ int64_t gttrf( std::complex* DU2, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -201,11 +190,7 @@ int64_t gttrf( std::complex* DU2, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/gttrs.cc b/src/gttrs.cc index a9c3100e..5790573f 100644 --- a/src/gttrs.cc +++ b/src/gttrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,15 +27,9 @@ int64_t gttrs( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -42,7 +37,7 @@ int64_t gttrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sgttrs( @@ -71,15 +66,9 @@ int64_t gttrs( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -87,7 +76,7 @@ int64_t gttrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dgttrs( @@ -116,15 +105,9 @@ int64_t gttrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -132,7 +115,7 @@ int64_t gttrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cgttrs( @@ -226,15 +209,9 @@ int64_t gttrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -242,7 +219,7 @@ int64_t gttrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zgttrs( diff --git a/src/hbev.cc b/src/hbev.cc index b7847cd4..f2db47a3 100644 --- a/src/hbev.cc +++ b/src/hbev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t hbev( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -62,19 +56,12 @@ int64_t hbev( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hbev_2stage.cc b/src/hbev_2stage.cc index 2afc7d8b..c897a327 100644 --- a/src/hbev_2stage.cc +++ b/src/hbev_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t hbev_2stage( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -81,19 +75,12 @@ int64_t hbev_2stage( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hbevd.cc b/src/hbevd.cc index 8248d59b..08aa1274 100644 --- a/src/hbevd.cc +++ b/src/hbevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t hbevd( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -85,19 +79,12 @@ int64_t hbevd( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hbevd_2stage.cc b/src/hbevd_2stage.cc index b5f2dd1d..d8c560f2 100644 --- a/src/hbevd_2stage.cc +++ b/src/hbevd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t hbevd_2stage( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -87,19 +81,12 @@ int64_t hbevd_2stage( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hbevx.cc b/src/hbevx.cc index 2fa09a75..393f3c66 100644 --- a/src/hbevx.cc +++ b/src/hbevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,32 +21,22 @@ int64_t hbevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab, std::complex* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -63,7 +54,7 @@ int64_t hbevx( LAPACK_chbevx( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_float*) AB, &ldab_, - (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], @@ -74,10 +65,10 @@ int64_t hbevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -88,32 +79,22 @@ int64_t hbevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab, std::complex* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -131,7 +112,7 @@ int64_t hbevx( LAPACK_zhbevx( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_double*) AB, &ldab_, - (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], @@ -142,10 +123,10 @@ int64_t hbevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/hbevx_2stage.cc b/src/hbevx_2stage.cc index e27f9f53..be1e78f8 100644 --- a/src/hbevx_2stage.cc +++ b/src/hbevx_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,32 +23,22 @@ int64_t hbevx_2stage( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab, std::complex* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -65,7 +56,7 @@ int64_t hbevx_2stage( LAPACK_chbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_float*) AB, &ldab_, - (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) qry_work, &ineg_one, @@ -86,7 +77,7 @@ int64_t hbevx_2stage( LAPACK_chbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_float*) AB, &ldab_, - (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], &lwork_, @@ -97,10 +88,10 @@ int64_t hbevx_2stage( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -111,32 +102,22 @@ int64_t hbevx_2stage( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab, std::complex* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -154,7 +135,7 @@ int64_t hbevx_2stage( LAPACK_zhbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_double*) AB, &ldab_, - (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) qry_work, &ineg_one, @@ -175,7 +156,7 @@ int64_t hbevx_2stage( LAPACK_zhbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, (lapack_complex_double*) AB, &ldab_, - (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], &lwork_, @@ -186,10 +167,10 @@ int64_t hbevx_2stage( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/hbgst.cc b/src/hbgst.cc index 1e127e4f..2d5f498f 100644 --- a/src/hbgst.cc +++ b/src/hbgst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,23 +23,14 @@ int64_t hbgst( std::complex const* BB, int64_t ldbb, std::complex* X, int64_t ldx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -66,23 +58,14 @@ int64_t hbgst( std::complex const* BB, int64_t ldbb, std::complex* X, int64_t ldx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hbgv.cc b/src/hbgv.cc index 888f99e2..09236c15 100644 --- a/src/hbgv.cc +++ b/src/hbgv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,23 +24,14 @@ int64_t hbgv( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -69,23 +61,14 @@ int64_t hbgv( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hbgvd.cc b/src/hbgvd.cc index 95a700f7..17654f60 100644 --- a/src/hbgvd.cc +++ b/src/hbgvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,23 +24,14 @@ int64_t hbgvd( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -96,23 +88,14 @@ int64_t hbgvd( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hbgvx.cc b/src/hbgvx.cc index db1ac274..9413aa87 100644 --- a/src/hbgvx.cc +++ b/src/hbgvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,36 +22,24 @@ int64_t hbgvx( std::complex* AB, int64_t ldab, std::complex* BB, int64_t ldbb, std::complex* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -69,7 +58,7 @@ int64_t hbgvx( &jobz_, &range_, &uplo_, &n_, &ka_, &kb_, (lapack_complex_float*) AB, &ldab_, (lapack_complex_float*) BB, &ldbb_, - (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], @@ -80,10 +69,10 @@ int64_t hbgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -95,36 +84,24 @@ int64_t hbgvx( std::complex* AB, int64_t ldab, std::complex* BB, int64_t ldbb, std::complex* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -143,7 +120,7 @@ int64_t hbgvx( &jobz_, &range_, &uplo_, &n_, &ka_, &kb_, (lapack_complex_double*) AB, &ldab_, (lapack_complex_double*) BB, &ldbb_, - (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], @@ -154,10 +131,10 @@ int64_t hbgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/hbtrd.cc b/src/hbtrd.cc index e8cda8c9..0ed00165 100644 --- a/src/hbtrd.cc +++ b/src/hbtrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,19 +24,12 @@ int64_t hbtrd( float* E, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace @@ -63,19 +57,12 @@ int64_t hbtrd( double* E, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hecon.cc b/src/hecon.cc index cc107fea..eb344dd9 100644 --- a/src/hecon.cc +++ b/src/hecon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,14 +24,9 @@ int64_t hecon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -107,14 +103,9 @@ int64_t hecon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hecon_rk.cc b/src/hecon_rk.cc index 6a5ae0aa..fd71b279 100644 --- a/src/hecon_rk.cc +++ b/src/hecon_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,14 +27,9 @@ int64_t hecon_rk( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -146,14 +142,9 @@ int64_t hecon_rk( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/heequb.cc b/src/heequb.cc index b1ec479d..1a143bb3 100644 --- a/src/heequb.cc +++ b/src/heequb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t heequb( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -103,14 +99,9 @@ int64_t heequb( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/heev.cc b/src/heev.cc index 89e43097..a98fcebf 100644 --- a/src/heev.cc +++ b/src/heev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t heev( std::complex* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -120,15 +116,10 @@ int64_t heev( std::complex* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/heev_2stage.cc b/src/heev_2stage.cc index c98cd0ad..2e55d382 100644 --- a/src/heev_2stage.cc +++ b/src/heev_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,10 @@ int64_t heev_2stage( std::complex* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -152,15 +148,10 @@ int64_t heev_2stage( std::complex* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/heevd.cc b/src/heevd.cc index b6eed6c1..ff9ba6ba 100644 --- a/src/heevd.cc +++ b/src/heevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t heevd( std::complex* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -138,15 +134,10 @@ int64_t heevd( std::complex* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/heevd_2stage.cc b/src/heevd_2stage.cc index 49c57712..0232dfac 100644 --- a/src/heevd_2stage.cc +++ b/src/heevd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,10 @@ int64_t heevd_2stage( std::complex* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -170,15 +166,10 @@ int64_t heevd_2stage( std::complex* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/heevr.cc b/src/heevr.cc index 5bd43214..e13d0116 100644 --- a/src/heevr.cc +++ b/src/heevr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,15 @@ int64_t heevr( std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,nfound), n >= nfound @@ -301,23 +294,15 @@ int64_t heevr( std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,nfound), n >= nfound diff --git a/src/heevr_2stage.cc b/src/heevr_2stage.cc index 292e70dd..17de693d 100644 --- a/src/heevr_2stage.cc +++ b/src/heevr_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,23 +28,15 @@ int64_t heevr_2stage( std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,nfound), n >= nfound @@ -333,23 +326,15 @@ int64_t heevr_2stage( std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,nfound), n >= nfound diff --git a/src/heevx.cc b/src/heevx.cc index 85f81f3e..726ead79 100644 --- a/src/heevx.cc +++ b/src/heevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,15 @@ int64_t heevx( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -236,23 +229,15 @@ int64_t heevx( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); diff --git a/src/heevx_2stage.cc b/src/heevx_2stage.cc index 0d677517..9f8c3bb0 100644 --- a/src/heevx_2stage.cc +++ b/src/heevx_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,23 +28,15 @@ int64_t heevx_2stage( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -268,23 +261,15 @@ int64_t heevx_2stage( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); diff --git a/src/hegst.cc b/src/hegst.cc index c74e7c93..adb15372 100644 --- a/src/hegst.cc +++ b/src/hegst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,11 @@ int64_t hegst( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chegst( @@ -51,18 +45,11 @@ int64_t hegst( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhegst( diff --git a/src/hegv.cc b/src/hegv.cc index 2d87c3d0..9420fb3e 100644 --- a/src/hegv.cc +++ b/src/hegv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t hegv( std::complex* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -79,19 +73,12 @@ int64_t hegv( std::complex* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hegv_2stage.cc b/src/hegv_2stage.cc index 2c1c63c2..1ff1f077 100644 --- a/src/hegv_2stage.cc +++ b/src/hegv_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t hegv_2stage( std::complex* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -81,19 +75,12 @@ int64_t hegv_2stage( std::complex* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hegvd.cc b/src/hegvd.cc index d67de3c7..c4a64e4d 100644 --- a/src/hegvd.cc +++ b/src/hegvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t hegvd( std::complex* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -85,19 +79,12 @@ int64_t hegvd( std::complex* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hegvx.cc b/src/hegvx.cc index 0329a0b2..3e1b6e17 100644 --- a/src/hegvx.cc +++ b/src/hegvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,32 +21,22 @@ int64_t hegvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, std::complex* B, int64_t ldb, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -63,7 +54,7 @@ int64_t hegvx( LAPACK_chegvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_float*) A, &lda_, - (lapack_complex_float*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) qry_work, &ineg_one, @@ -84,7 +75,7 @@ int64_t hegvx( LAPACK_chegvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_float*) A, &lda_, - (lapack_complex_float*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], &lwork_, @@ -95,10 +86,10 @@ int64_t hegvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -109,32 +100,22 @@ int64_t hegvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, std::complex* B, int64_t ldb, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -152,7 +133,7 @@ int64_t hegvx( LAPACK_zhegvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_double*) A, &lda_, - (lapack_complex_double*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) qry_work, &ineg_one, @@ -173,7 +154,7 @@ int64_t hegvx( LAPACK_zhegvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_double*) A, &lda_, - (lapack_complex_double*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], &lwork_, @@ -184,10 +165,10 @@ int64_t hegvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/herfs.cc b/src/herfs.cc index f398328a..0ed25ca7 100644 --- a/src/herfs.cc +++ b/src/herfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,20 +28,11 @@ int64_t herfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -48,8 +40,8 @@ int64_t herfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -170,20 +162,11 @@ int64_t herfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -191,8 +174,8 @@ int64_t herfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/herfsx.cc b/src/herfsx.cc index e63cbe87..812fbdf1 100644 --- a/src/herfsx.cc +++ b/src/herfsx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -33,23 +34,12 @@ int64_t herfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -57,10 +47,10 @@ int64_t herfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -376,23 +366,12 @@ int64_t herfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -400,10 +379,10 @@ int64_t herfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hesv.cc b/src/hesv.cc index ca647539..6c289683 100644 --- a/src/hesv.cc +++ b/src/hesv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t hesv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -41,7 +35,7 @@ int64_t hesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -163,17 +157,10 @@ int64_t hesv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -181,7 +168,7 @@ int64_t hesv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hesv_aa.cc b/src/hesv_aa.cc index 9719f66f..cf865105 100644 --- a/src/hesv_aa.cc +++ b/src/hesv_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t hesv_aa( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -43,7 +37,7 @@ int64_t hesv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -157,17 +151,10 @@ int64_t hesv_aa( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -175,7 +162,7 @@ int64_t hesv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hesv_rk.cc b/src/hesv_rk.cc index b8baa764..f4d3a8b7 100644 --- a/src/hesv_rk.cc +++ b/src/hesv_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,17 +27,10 @@ int64_t hesv_rk( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -44,7 +38,7 @@ int64_t hesv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -205,17 +199,10 @@ int64_t hesv_rk( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -223,7 +210,7 @@ int64_t hesv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hesv_rook.cc b/src/hesv_rook.cc index 99503f19..6e399864 100644 --- a/src/hesv_rook.cc +++ b/src/hesv_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t hesv_rook( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -43,7 +37,7 @@ int64_t hesv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -90,17 +84,10 @@ int64_t hesv_rook( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -108,7 +95,7 @@ int64_t hesv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hesvx.cc b/src/hesvx.cc index 86b932cd..d1f53e98 100644 --- a/src/hesvx.cc +++ b/src/hesvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -28,21 +29,12 @@ int64_t hesvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -50,8 +42,8 @@ int64_t hesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size @@ -247,21 +239,12 @@ int64_t hesvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -269,8 +252,8 @@ int64_t hesvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size diff --git a/src/heswapr.cc b/src/heswapr.cc index 1b453c2d..d4708845 100644 --- a/src/heswapr.cc +++ b/src/heswapr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30301 // >= 3.3.1 @@ -22,18 +23,11 @@ void heswapr( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_cheswapr( &uplo_, &n_, @@ -77,18 +71,11 @@ void heswapr( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_zheswapr( &uplo_, &n_, diff --git a/src/hetrd.cc b/src/hetrd.cc index 6915581e..063ea3ab 100644 --- a/src/hetrd.cc +++ b/src/hetrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t hetrd( float* E, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -182,14 +178,9 @@ int64_t hetrd( double* E, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hetrd_2stage.cc b/src/hetrd_2stage.cc index 611dba4b..529d50eb 100644 --- a/src/hetrd_2stage.cc +++ b/src/hetrd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,17 +28,11 @@ int64_t hetrd_2stage( std::complex* tau, std::complex* hous2, int64_t lhous2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lhous2) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int lhous2_ = (lapack_int) lhous2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int lhous2_ = to_lapack_int( lhous2 ); lapack_int info_ = 0; // query for workspace size @@ -196,17 +191,11 @@ int64_t hetrd_2stage( std::complex* tau, std::complex* hous2, int64_t lhous2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lhous2) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int lhous2_ = (lapack_int) lhous2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int lhous2_ = to_lapack_int( lhous2 ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hetrf.cc b/src/hetrf.cc index fa0f58a4..e6acd99b 100644 --- a/src/hetrf.cc +++ b/src/hetrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t hetrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -187,14 +183,9 @@ int64_t hetrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/hetrf_aa.cc b/src/hetrf_aa.cc index 3146d20b..9948b5ed 100644 --- a/src/hetrf_aa.cc +++ b/src/hetrf_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t hetrf_aa( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -131,14 +127,9 @@ int64_t hetrf_aa( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/hetrf_rk.cc b/src/hetrf_rk.cc index 144fb32f..49394a4a 100644 --- a/src/hetrf_rk.cc +++ b/src/hetrf_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,14 +26,9 @@ int64_t hetrf_rk( std::complex* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -241,14 +237,9 @@ int64_t hetrf_rk( std::complex* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/hetrf_rook.cc b/src/hetrf_rook.cc index c6608888..de3a9a1e 100644 --- a/src/hetrf_rook.cc +++ b/src/hetrf_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t hetrf_rook( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -82,14 +78,9 @@ int64_t hetrf_rook( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/hetri.cc b/src/hetri.cc index ab732fb7..b3b2c418 100644 --- a/src/hetri.cc +++ b/src/hetri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t hetri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -106,14 +102,9 @@ int64_t hetri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hetri2.cc b/src/hetri2.cc index eef18ddb..b1cebded 100644 --- a/src/hetri2.cc +++ b/src/hetri2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t hetri2( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -123,14 +119,9 @@ int64_t hetri2( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hetri_rk.cc b/src/hetri_rk.cc index af95cc65..8e481626 100644 --- a/src/hetri_rk.cc +++ b/src/hetri_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,14 +26,9 @@ int64_t hetri_rk( std::complex const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -168,14 +164,9 @@ int64_t hetri_rk( std::complex const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hetrs.cc b/src/hetrs.cc index 63e0b47e..25e0b5db 100644 --- a/src/hetrs.cc +++ b/src/hetrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t hetrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -41,7 +35,7 @@ int64_t hetrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chetrs( @@ -111,17 +105,10 @@ int64_t hetrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -129,7 +116,7 @@ int64_t hetrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhetrs( diff --git a/src/hetrs2.cc b/src/hetrs2.cc index 6d6e6abd..bf567929 100644 --- a/src/hetrs2.cc +++ b/src/hetrs2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t hetrs2( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,7 +37,7 @@ int64_t hetrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -117,17 +111,10 @@ int64_t hetrs2( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -135,7 +122,7 @@ int64_t hetrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hetrs_aa.cc b/src/hetrs_aa.cc index 068372ed..07ec36e3 100644 --- a/src/hetrs_aa.cc +++ b/src/hetrs_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t hetrs_aa( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,8 +37,8 @@ int64_t hetrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace @@ -114,17 +108,10 @@ int64_t hetrs_aa( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -132,8 +119,8 @@ int64_t hetrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hetrs_rk.cc b/src/hetrs_rk.cc index 7525ffed..681fcd6c 100644 --- a/src/hetrs_rk.cc +++ b/src/hetrs_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,17 +27,10 @@ int64_t hetrs_rk( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -44,7 +38,7 @@ int64_t hetrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chetrs_3( @@ -158,17 +152,10 @@ int64_t hetrs_rk( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -176,7 +163,7 @@ int64_t hetrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhetrs_3( diff --git a/src/hetrs_rook.cc b/src/hetrs_rook.cc index 83baacf3..f120e21f 100644 --- a/src/hetrs_rook.cc +++ b/src/hetrs_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t hetrs_rook( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,7 +37,7 @@ int64_t hetrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chetrs_rook( @@ -68,17 +62,10 @@ int64_t hetrs_rook( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -86,7 +73,7 @@ int64_t hetrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhetrs_rook( diff --git a/src/hfrk.cc b/src/hfrk.cc index 0ed31e3a..9dd2b4f4 100644 --- a/src/hfrk.cc +++ b/src/hfrk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,12 @@ void hfrk( std::complex const* A, int64_t lda, float beta, std::complex* C ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_chfrk( &transr_, &uplo_, &trans_, &n_, &k_, &alpha, @@ -46,18 +41,12 @@ void hfrk( std::complex const* A, int64_t lda, double beta, std::complex* C ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_zhfrk( &transr_, &uplo_, &trans_, &n_, &k_, &alpha, diff --git a/src/hgeqz.cc b/src/hgeqz.cc index f027a2ac..72124437 100644 --- a/src/hgeqz.cc +++ b/src/hgeqz.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,26 +26,16 @@ int64_t hgeqz( float* Q, int64_t ldq, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // split-complex representation @@ -104,26 +95,16 @@ int64_t hgeqz( double* Q, int64_t ldq, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // split-complex representation @@ -183,26 +164,16 @@ int64_t hgeqz( std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -256,26 +227,16 @@ int64_t hgeqz( std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compq_ = to_char_comp( compq ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hpcon.cc b/src/hpcon.cc index 1943c290..36751926 100644 --- a/src/hpcon.cc +++ b/src/hpcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,12 +23,8 @@ int64_t hpcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -59,12 +56,8 @@ int64_t hpcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hpev.cc b/src/hpev.cc index 82ee4919..e78c32c9 100644 --- a/src/hpev.cc +++ b/src/hpev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t hpev( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -58,15 +54,10 @@ int64_t hpev( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hpevd.cc b/src/hpevd.cc index ac315197..2c8efcfa 100644 --- a/src/hpevd.cc +++ b/src/hpevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t hpevd( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -81,15 +77,10 @@ int64_t hpevd( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hpevx.cc b/src/hpevx.cc index 839ca370..99c42027 100644 --- a/src/hpevx.cc +++ b/src/hpevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -19,26 +20,19 @@ using blas::real; int64_t hpevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* AP, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -55,7 +49,7 @@ int64_t hpevx( LAPACK_chpevx( &jobz_, &range_, &uplo_, &n_, - (lapack_complex_float*) AP, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) AP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], @@ -66,10 +60,10 @@ int64_t hpevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -79,26 +73,19 @@ int64_t hpevx( int64_t hpevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* AP, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -115,7 +102,7 @@ int64_t hpevx( LAPACK_zhpevx( &jobz_, &range_, &uplo_, &n_, - (lapack_complex_double*) AP, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) AP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], @@ -126,10 +113,10 @@ int64_t hpevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/hpgst.cc b/src/hpgst.cc index 62506949..f43819fb 100644 --- a/src/hpgst.cc +++ b/src/hpgst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t hpgst( std::complex* AP, std::complex const* BP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_chpgst( @@ -47,14 +43,9 @@ int64_t hpgst( std::complex* AP, std::complex const* BP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zhpgst( diff --git a/src/hpgv.cc b/src/hpgv.cc index 03426a48..f5d69053 100644 --- a/src/hpgv.cc +++ b/src/hpgv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,11 @@ int64_t hpgv( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -63,17 +58,11 @@ int64_t hpgv( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hpgvd.cc b/src/hpgvd.cc index 80baae37..aee0741c 100644 --- a/src/hpgvd.cc +++ b/src/hpgvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,11 @@ int64_t hpgvd( float* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -87,17 +82,11 @@ int64_t hpgvd( double* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/hpgvx.cc b/src/hpgvx.cc index 366c4f89..19a1e5cc 100644 --- a/src/hpgvx.cc +++ b/src/hpgvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,28 +21,20 @@ int64_t hpgvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* AP, std::complex* BP, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -59,7 +52,7 @@ int64_t hpgvx( LAPACK_chpgvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_float*) AP, - (lapack_complex_float*) BP, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_float*) BP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, (lapack_complex_float*) &work[0], @@ -70,10 +63,10 @@ int64_t hpgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -84,28 +77,20 @@ int64_t hpgvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, std::complex* AP, std::complex* BP, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -123,7 +108,7 @@ int64_t hpgvx( LAPACK_zhpgvx( &itype_, &jobz_, &range_, &uplo_, &n_, (lapack_complex_double*) AP, - (lapack_complex_double*) BP, &vl, &vu, &il_, &iu_, &abstol, &m_, + (lapack_complex_double*) BP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, (lapack_complex_double*) &work[0], @@ -134,10 +119,10 @@ int64_t hpgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/hprfs.cc b/src/hprfs.cc index a120d5cd..5641bc0b 100644 --- a/src/hprfs.cc +++ b/src/hprfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,16 +27,9 @@ int64_t hprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,8 +37,8 @@ int64_t hprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -80,16 +74,9 @@ int64_t hprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -97,8 +84,8 @@ int64_t hprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hpsv.cc b/src/hpsv.cc index 55b26ed1..70f813a3 100644 --- a/src/hpsv.cc +++ b/src/hpsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t hpsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -38,7 +33,7 @@ int64_t hpsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chpsv( @@ -63,15 +58,9 @@ int64_t hpsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -79,7 +68,7 @@ int64_t hpsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhpsv( diff --git a/src/hpsvx.cc b/src/hpsvx.cc index a3aeac80..60e74949 100644 --- a/src/hpsvx.cc +++ b/src/hpsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,17 +28,10 @@ int64_t hpsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -45,8 +39,8 @@ int64_t hpsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -86,17 +80,10 @@ int64_t hpsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -104,8 +91,8 @@ int64_t hpsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/hptrd.cc b/src/hptrd.cc index a33d2c7a..9a16de76 100644 --- a/src/hptrd.cc +++ b/src/hptrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,12 +23,8 @@ int64_t hptrd( float* E, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_chptrd( @@ -51,12 +48,8 @@ int64_t hptrd( double* E, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zhptrd( diff --git a/src/hptrf.cc b/src/hptrf.cc index 19acd563..1c7a8f33 100644 --- a/src/hptrf.cc +++ b/src/hptrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,12 +22,8 @@ int64_t hptrf( std::complex* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -56,12 +53,8 @@ int64_t hptrf( std::complex* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/hptri.cc b/src/hptri.cc index 8439c81c..eda82c1f 100644 --- a/src/hptri.cc +++ b/src/hptri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,12 +22,8 @@ int64_t hptri( std::complex* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -57,12 +54,8 @@ int64_t hptri( std::complex* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/hptrs.cc b/src/hptrs.cc index 7670a1f6..b9ba43c2 100644 --- a/src/hptrs.cc +++ b/src/hptrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t hptrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -38,7 +33,7 @@ int64_t hptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_chptrs( @@ -60,15 +55,9 @@ int64_t hptrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -76,7 +65,7 @@ int64_t hptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zhptrs( diff --git a/src/hseqr.cc b/src/hseqr.cc index 1010ebf2..01fdf284 100644 --- a/src/hseqr.cc +++ b/src/hseqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,13 @@ int64_t hseqr( std::complex* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // split-complex representation @@ -89,21 +82,13 @@ int64_t hseqr( std::complex* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // split-complex representation @@ -155,21 +140,13 @@ int64_t hseqr( std::complex* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -338,21 +315,13 @@ int64_t hseqr( std::complex* W, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldh) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobschur_ = to_char( jobschur ); char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int ldh_ = (lapack_int) ldh; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int ldh_ = to_lapack_int( ldh ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/lacgv.cc b/src/lacgv.cc index b1af2e9b..30e19f16 100644 --- a/src/lacgv.cc +++ b/src/lacgv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,13 +21,8 @@ void lacgv( int64_t n, std::complex* x, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_clacgv( &n_, @@ -57,13 +53,8 @@ void lacgv( int64_t n, std::complex* x, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_zlacgv( &n_, diff --git a/src/lacp2.cc b/src/lacp2.cc index 2b2654ea..b6a51b38 100644 --- a/src/lacp2.cc +++ b/src/lacp2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,11 @@ void lacp2( float const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_clacp2( &uplo_, &m_, &n_, @@ -46,18 +40,11 @@ void lacp2( double const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_zlacp2( &uplo_, &m_, &n_, diff --git a/src/lacpy.cc b/src/lacpy.cc index 5ed1f9ad..49332e9d 100644 --- a/src/lacpy.cc +++ b/src/lacpy.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,18 +22,11 @@ void lacpy( float const* A, int64_t lda, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_slacpy( &matrixtype_, &m_, &n_, @@ -48,18 +42,11 @@ void lacpy( double const* A, int64_t lda, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_dlacpy( &matrixtype_, &m_, &n_, @@ -75,18 +62,11 @@ void lacpy( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_clacpy( &matrixtype_, &m_, &n_, @@ -136,18 +116,11 @@ void lacpy( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_zlacpy( &matrixtype_, &m_, &n_, diff --git a/src/laed4.cc b/src/laed4.cc index 5094ba62..e3dbee45 100644 --- a/src/laed4.cc +++ b/src/laed4.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,13 +24,8 @@ int64_t laed4( float* delta, float rho, float* lambda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int i_ = (lapack_int) i + 1; // change to 1-based + lapack_int n_ = to_lapack_int( n ); + lapack_int i_ = to_lapack_int( i ) + 1; // change to 1-based lapack_int info_ = 0; LAPACK_slaed4( @@ -104,13 +100,8 @@ int64_t laed4( double* delta, double rho, double* lambda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int i_ = (lapack_int) i + 1; // change to 1-based + lapack_int n_ = to_lapack_int( n ); + lapack_int i_ = to_lapack_int( i ) + 1; // change to 1-based lapack_int info_ = 0; LAPACK_dlaed4( diff --git a/src/lag2c.cc b/src/lag2c.cc index 3f30d39c..c6202412 100644 --- a/src/lag2c.cc +++ b/src/lag2c.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,17 +21,10 @@ int64_t lag2c( std::complex const* A, int64_t lda, std::complex* SA, int64_t ldsa ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldsa) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldsa_ = (lapack_int) ldsa; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldsa_ = to_lapack_int( ldsa ); lapack_int info_ = 0; LAPACK_zlag2c( diff --git a/src/lag2d.cc b/src/lag2d.cc index c3c25589..1893883c 100644 --- a/src/lag2d.cc +++ b/src/lag2d.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,17 +21,10 @@ int64_t lag2d( float const* SA, int64_t ldsa, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldsa) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldsa_ = (lapack_int) ldsa; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldsa_ = to_lapack_int( ldsa ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_slag2d( diff --git a/src/lag2s.cc b/src/lag2s.cc index 7027a3de..1ef3c673 100644 --- a/src/lag2s.cc +++ b/src/lag2s.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,17 +21,10 @@ int64_t lag2s( double const* A, int64_t lda, float* SA, int64_t ldsa ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldsa) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldsa_ = (lapack_int) ldsa; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldsa_ = to_lapack_int( ldsa ); lapack_int info_ = 0; LAPACK_dlag2s( diff --git a/src/lag2z.cc b/src/lag2z.cc index 876850f2..bb3e8ce4 100644 --- a/src/lag2z.cc +++ b/src/lag2z.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,17 +21,10 @@ int64_t lag2z( std::complex const* SA, int64_t ldsa, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldsa) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldsa_ = (lapack_int) ldsa; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldsa_ = to_lapack_int( ldsa ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_clag2z( diff --git a/src/lagge.cc b/src/lagge.cc index 86f0aec1..2aaadd3a 100644 --- a/src/lagge.cc +++ b/src/lagge.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,11 @@ int64_t lagge( float* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -71,19 +64,11 @@ int64_t lagge( double* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -118,19 +103,11 @@ int64_t lagge( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -165,19 +142,11 @@ int64_t lagge( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); diff --git a/src/laghe.cc b/src/laghe.cc index a8313988..0d05bef4 100644 --- a/src/laghe.cc +++ b/src/laghe.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,9 @@ int64_t laghe( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -67,15 +62,9 @@ int64_t laghe( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); diff --git a/src/lagsy.cc b/src/lagsy.cc index 50ca4363..5518f202 100644 --- a/src/lagsy.cc +++ b/src/lagsy.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,9 @@ int64_t lagsy( float* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -67,15 +62,9 @@ int64_t lagsy( double* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -110,15 +99,9 @@ int64_t lagsy( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -153,15 +136,9 @@ int64_t lagsy( std::complex* A, int64_t lda, int64_t* iseed ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); diff --git a/src/lamch.cc b/src/lamch.cc deleted file mode 100644 index 9bd7e71d..00000000 --- a/src/lamch.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2017-2023, University of Tennessee. All rights reserved. -// SPDX-License-Identifier: BSD-3-Clause -// This program is free software: you can redistribute it and/or modify it under -// the terms of the BSD 3-Clause license. See the accompanying LICENSE file. - -#include "lapack.hh" -#include "lapack/fortran.h" - -#include - -namespace lapack { - -using blas::max; -using blas::min; -using blas::real; - -} // namespace lapack diff --git a/src/langb.cc b/src/langb.cc index ce048f69..658c73cd 100644 --- a/src/langb.cc +++ b/src/langb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,18 +22,11 @@ float langb( lapack::Norm norm, int64_t n, int64_t kl, int64_t ku, float const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -53,18 +47,11 @@ double langb( lapack::Norm norm, int64_t n, int64_t kl, int64_t ku, double const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -85,18 +72,11 @@ float langb( lapack::Norm norm, int64_t n, int64_t kl, int64_t ku, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -151,18 +131,11 @@ double langb( lapack::Norm norm, int64_t n, int64_t kl, int64_t ku, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); diff --git a/src/lange.cc b/src/lange.cc index 1d7f56cb..c25285a7 100644 --- a/src/lange.cc +++ b/src/lange.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,16 +22,10 @@ float lange( lapack::Norm norm, int64_t m, int64_t n, float const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -51,16 +46,10 @@ double lange( lapack::Norm norm, int64_t m, int64_t n, double const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -81,16 +70,10 @@ float lange( lapack::Norm norm, int64_t m, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -138,16 +121,10 @@ double lange( lapack::Norm norm, int64_t m, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); diff --git a/src/langt.cc b/src/langt.cc index c2282f51..23ec61f7 100644 --- a/src/langt.cc +++ b/src/langt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,12 +23,8 @@ float langt( float const* D, float const* DU ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_slangt( &norm_, &n_, @@ -45,12 +42,8 @@ double langt( double const* D, double const* DU ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_dlangt( &norm_, &n_, @@ -68,12 +61,8 @@ float langt( std::complex const* D, std::complex const* DU ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_clangt( &norm_, &n_, @@ -121,12 +110,8 @@ double langt( std::complex const* D, std::complex const* DU ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_zlangt( &norm_, &n_, diff --git a/src/lanhb.cc b/src/lanhb.cc index eff98b1c..187ed681 100644 --- a/src/lanhb.cc +++ b/src/lanhb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,17 +22,11 @@ float lanhb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -95,17 +90,11 @@ double lanhb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lanhe.cc b/src/lanhe.cc index c9ee2800..51789aa8 100644 --- a/src/lanhe.cc +++ b/src/lanhe.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,15 +22,10 @@ float lanhe( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -95,15 +91,10 @@ double lanhe( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lanhp.cc b/src/lanhp.cc index 1cb80155..1e89959d 100644 --- a/src/lanhp.cc +++ b/src/lanhp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,13 +22,9 @@ float lanhp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -84,13 +81,9 @@ double lanhp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lanhs.cc b/src/lanhs.cc index 2f9555e2..060b884f 100644 --- a/src/lanhs.cc +++ b/src/lanhs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,14 +22,9 @@ float lanhs( lapack::Norm norm, int64_t n, float const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -49,14 +45,9 @@ double lanhs( lapack::Norm norm, int64_t n, double const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -77,14 +68,9 @@ float lanhs( lapack::Norm norm, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -131,14 +117,9 @@ double lanhs( lapack::Norm norm, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); diff --git a/src/lanht.cc b/src/lanht.cc index 70273f3e..a6899b0e 100644 --- a/src/lanht.cc +++ b/src/lanht.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,12 +22,8 @@ float lanht( float const* D, std::complex const* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_clanht( &norm_, &n_, @@ -70,12 +67,8 @@ double lanht( double const* D, std::complex const* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_zlanht( &norm_, &n_, diff --git a/src/lansb.cc b/src/lansb.cc index e6df9025..affdfd90 100644 --- a/src/lansb.cc +++ b/src/lansb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,17 +22,11 @@ float lansb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, float const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -52,17 +47,11 @@ double lansb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, double const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -83,17 +72,11 @@ float lansb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -155,17 +138,11 @@ double lansb( lapack::Norm norm, lapack::Uplo uplo, int64_t n, int64_t kd, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lansp.cc b/src/lansp.cc index 20c62d9e..eccc6793 100644 --- a/src/lansp.cc +++ b/src/lansp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,13 +22,9 @@ float lansp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, float const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -48,13 +45,9 @@ double lansp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, double const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -75,13 +68,9 @@ float lansp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -136,13 +125,9 @@ double lansp( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lanst.cc b/src/lanst.cc index 2653f88b..bb04c454 100644 --- a/src/lanst.cc +++ b/src/lanst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,12 +22,8 @@ float lanst( float const* D, float const* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_slanst( &norm_, &n_, D, E ); @@ -67,12 +64,8 @@ double lanst( double const* D, double const* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); return LAPACK_dlanst( &norm_, &n_, D, E ); diff --git a/src/lansy.cc b/src/lansy.cc index fcef067a..4a26d63e 100644 --- a/src/lansy.cc +++ b/src/lansy.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,15 +22,10 @@ float lansy( lapack::Norm norm, lapack::Uplo uplo, int64_t n, float const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -50,15 +46,10 @@ double lansy( lapack::Norm norm, lapack::Uplo uplo, int64_t n, double const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -79,15 +70,10 @@ float lansy( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); @@ -150,15 +136,10 @@ double lansy( lapack::Norm norm, lapack::Uplo uplo, int64_t n, std::complex const* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf || norm == Norm::One ? n : 1); diff --git a/src/lantb.cc b/src/lantb.cc index abbdeba8..d0e6ec47 100644 --- a/src/lantb.cc +++ b/src/lantb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,18 +22,12 @@ float lantb( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, int64_t k, float const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -53,18 +48,12 @@ double lantb( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, int64_t k, double const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -85,18 +74,12 @@ float lantb( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, int64_t k, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -164,18 +147,12 @@ double lantb( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, int64_t k, std::complex const* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldab_ = to_lapack_int( ldab ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); diff --git a/src/lantp.cc b/src/lantp.cc index 469b6b79..8891689f 100644 --- a/src/lantp.cc +++ b/src/lantp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,14 +22,10 @@ float lantp( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, float const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -49,14 +46,10 @@ double lantp( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, double const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -77,14 +70,10 @@ float lantp( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); @@ -144,14 +133,10 @@ double lantp( lapack::Norm norm, lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex const* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); // from docs int64_t lwork = (norm == Norm::Inf ? n : 1); diff --git a/src/lantr.cc b/src/lantr.cc index df78e2c1..d61c0112 100644 --- a/src/lantr.cc +++ b/src/lantr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,18 +30,12 @@ float lantr( else m = min( m, n ); - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -69,18 +64,12 @@ double lantr( else m = min( m, n ); - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -109,18 +98,12 @@ float lantr( else m = min( m, n ); - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); @@ -206,18 +189,12 @@ double lantr( else m = min( m, n ); - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); // from docs int64_t lwork = (norm == Norm::Inf ? m : 1); diff --git a/src/lapack_internal.hh b/src/lapack_internal.hh new file mode 100644 index 00000000..700232d3 --- /dev/null +++ b/src/lapack_internal.hh @@ -0,0 +1,36 @@ +// Copyright (c) 2017-2023, University of Tennessee. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// This program is free software: you can redistribute it and/or modify it under +// the terms of the BSD 3-Clause license. See the accompanying LICENSE file. + +#ifndef LAPACK_INTERNAL_HH +#define LAPACK_INTERNAL_HH + +#include "lapack/util.hh" + +namespace lapack { + +//------------------------------------------------------------------------------ +/// @see to_lapack_int +/// +inline lapack_int to_lapack_int_( int64_t x, const char* x_str ) +{ + if constexpr (sizeof(int64_t) > sizeof(lapack_int)) { + lapack_error_if_msg( x > std::numeric_limits::max(), "%s", x_str ); + } + return lapack_int( x ); +} + +//---------------------------------------- +/// Convert int64_t to lapack_int. +/// If lapack_int is 64-bit, this does nothing. +/// If lapack_int is 32-bit, throws if x > INT_MAX, so conversion would overflow. +/// +/// Note this is in src/lapack_internal.hh, so this macro won't pollute +/// the namespace when apps #include . +/// +#define to_lapack_int( x ) lapack::to_lapack_int_( x, #x ) + +} // namespace lapack + +#endif // LAPACK_INTERNAL_HH diff --git a/src/lapmr.cc b/src/lapmr.cc index 322fe996..46731473 100644 --- a/src/lapmr.cc +++ b/src/lapmr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,16 +24,10 @@ void lapmr( float* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(m)] ); @@ -56,16 +51,10 @@ void lapmr( double* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(m)] ); @@ -89,16 +78,10 @@ void lapmr( std::complex* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(m)] ); @@ -122,16 +105,10 @@ void lapmr( std::complex* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(m)] ); diff --git a/src/lapmt.cc b/src/lapmt.cc index ed3d0679..70e34bb8 100644 --- a/src/lapmt.cc +++ b/src/lapmt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,16 +22,10 @@ void lapmt( float* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(n)] ); @@ -54,16 +49,10 @@ void lapmt( double* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(n)] ); @@ -87,16 +76,10 @@ void lapmt( std::complex* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(n)] ); @@ -120,16 +103,10 @@ void lapmt( std::complex* X, int64_t ldx, int64_t* K ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int forwrd_ = (lapack_int) forwrd; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int forwrd_ = to_lapack_int( forwrd ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldx_ = to_lapack_int( ldx ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > K_( &K[0], &K[(n)] ); diff --git a/src/larf.cc b/src/larf.cc index 38734213..3ea3581a 100644 --- a/src/larf.cc +++ b/src/larf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,18 +23,11 @@ void larf( float const* v, int64_t incv, float tau, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -56,18 +50,11 @@ void larf( double const* v, int64_t incv, double tau, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -90,18 +77,11 @@ void larf( std::complex const* v, int64_t incv, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -169,18 +149,11 @@ void larf( std::complex const* v, int64_t incv, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); diff --git a/src/larfb.cc b/src/larfb.cc index c86189d9..4f71e1ba 100644 --- a/src/larfb.cc +++ b/src/larfb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,25 +26,16 @@ void larfb( float const* T, int64_t ldt, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs lapack_int ldwork_ = (side == Side::Left ? n : m); @@ -69,25 +61,16 @@ void larfb( double const* T, int64_t ldt, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs lapack_int ldwork_ = (side == Side::Left ? n : m); @@ -114,25 +97,16 @@ void larfb( std::complex const* T, int64_t ldt, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs lapack_int ldwork_ = (side == Side::Left ? n : m); @@ -255,25 +229,16 @@ void larfb( std::complex const* T, int64_t ldt, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs lapack_int ldwork_ = (side == Side::Left ? n : m); diff --git a/src/larfg.cc b/src/larfg.cc index 7f0d58b2..1a5b7fbc 100644 --- a/src/larfg.cc +++ b/src/larfg.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,13 +23,8 @@ void larfg( float* X, int64_t incx, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_slarfg( &n_, alpha, @@ -43,13 +39,8 @@ void larfg( double* X, int64_t incx, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_dlarfg( &n_, alpha, @@ -64,13 +55,8 @@ void larfg( std::complex* X, int64_t incx, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_clarfg( &n_, (lapack_complex_float*) alpha, @@ -141,13 +127,8 @@ void larfg( std::complex* X, int64_t incx, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_zlarfg( &n_, (lapack_complex_double*) alpha, diff --git a/src/larfgp.cc b/src/larfgp.cc index 288112c1..212cc855 100644 --- a/src/larfgp.cc +++ b/src/larfgp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30202 // >= 3.2.2 @@ -24,13 +25,8 @@ void larfgp( float* X, int64_t incx, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_slarfgp( &n_, alpha, @@ -45,13 +41,8 @@ void larfgp( double* X, int64_t incx, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_dlarfgp( &n_, alpha, @@ -66,13 +57,8 @@ void larfgp( std::complex* X, int64_t incx, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_clarfgp( &n_, (lapack_complex_float*) alpha, @@ -143,13 +129,8 @@ void larfgp( std::complex* X, int64_t incx, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_zlarfgp( &n_, (lapack_complex_double*) alpha, diff --git a/src/larft.cc b/src/larft.cc index 8d9c1bd7..dbe28aac 100644 --- a/src/larft.cc +++ b/src/larft.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,19 +24,12 @@ void larft( float const* tau, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); LAPACK_slarft( &direction_, &storev_, &n_, &k_, @@ -54,19 +48,12 @@ void larft( double const* tau, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); LAPACK_dlarft( &direction_, &storev_, &n_, &k_, @@ -85,19 +72,12 @@ void larft( std::complex const* tau, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); LAPACK_clarft( &direction_, &storev_, &n_, &k_, @@ -208,19 +188,12 @@ void larft( std::complex const* tau, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); LAPACK_zlarft( &direction_, &storev_, &n_, &k_, diff --git a/src/larfx.cc b/src/larfx.cc index 9282de7b..afedc87f 100644 --- a/src/larfx.cc +++ b/src/larfx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,16 +23,10 @@ void larfx( float const* v, float tau, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -54,16 +49,10 @@ void larfx( double const* v, double tau, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -86,16 +75,10 @@ void larfx( std::complex const* v, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); @@ -159,16 +142,10 @@ void larfx( std::complex const* v, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); // from docs int64_t lwork = (side == Side::Left ? n : m); diff --git a/src/larfy.cc b/src/larfy.cc index 54d4b78b..d7a0cd4e 100644 --- a/src/larfy.cc +++ b/src/larfy.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,16 +25,10 @@ void larfy( float const* V, int64_t incv, float tau, float* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // allocate workspace lapack::vector< float > work( (n) ); @@ -53,16 +48,10 @@ void larfy( double const* V, int64_t incv, double tau, double* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // allocate workspace lapack::vector< double > work( (n) ); @@ -82,16 +71,10 @@ void larfy( std::complex const* V, int64_t incv, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // allocate workspace lapack::vector< std::complex > work( (n) ); @@ -154,16 +137,10 @@ void larfy( std::complex const* V, int64_t incv, std::complex tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int incv_ = (lapack_int) incv; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int n_ = to_lapack_int( n ); + lapack_int incv_ = to_lapack_int( incv ); + lapack_int ldc_ = to_lapack_int( ldc ); // allocate workspace lapack::vector< std::complex > work( (n) ); diff --git a/src/larnv.cc b/src/larnv.cc index 41c85a75..b76dce05 100644 --- a/src/larnv.cc +++ b/src/larnv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,12 +22,7 @@ void larnv( int64_t* iseed, int64_t n, float* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(idist) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int idist_ = (lapack_int) idist; + lapack_int idist_ = to_lapack_int( idist ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -34,7 +30,7 @@ void larnv( #else lapack_int* iseed_ptr = iseed; #endif - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); LAPACK_slarnv( &idist_, @@ -52,12 +48,7 @@ void larnv( int64_t* iseed, int64_t n, double* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(idist) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int idist_ = (lapack_int) idist; + lapack_int idist_ = to_lapack_int( idist ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -65,7 +56,7 @@ void larnv( #else lapack_int* iseed_ptr = iseed; #endif - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); LAPACK_dlarnv( &idist_, @@ -83,12 +74,7 @@ void larnv( int64_t* iseed, int64_t n, std::complex* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(idist) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int idist_ = (lapack_int) idist; + lapack_int idist_ = to_lapack_int( idist ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -96,7 +82,7 @@ void larnv( #else lapack_int* iseed_ptr = iseed; #endif - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); LAPACK_clarnv( &idist_, @@ -150,12 +136,7 @@ void larnv( int64_t* iseed, int64_t n, std::complex* X ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(idist) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int idist_ = (lapack_int) idist; + lapack_int idist_ = to_lapack_int( idist ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iseed_( &iseed[0], &iseed[(4)] ); @@ -163,7 +144,7 @@ void larnv( #else lapack_int* iseed_ptr = iseed; #endif - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); LAPACK_zlarnv( &idist_, diff --git a/src/lascl.cc b/src/lascl.cc index 539e89ec..9b02e3cd 100644 --- a/src/lascl.cc +++ b/src/lascl.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,20 +21,12 @@ int64_t lascl( lapack::MatrixType matrixtype, int64_t kl, int64_t ku, float cfrom, float cto, int64_t m, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_slascl( @@ -52,20 +45,12 @@ int64_t lascl( lapack::MatrixType matrixtype, int64_t kl, int64_t ku, double cfrom, double cto, int64_t m, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dlascl( @@ -84,20 +69,12 @@ int64_t lascl( lapack::MatrixType matrixtype, int64_t kl, int64_t ku, float cfrom, float cto, int64_t m, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_clascl( @@ -189,20 +166,12 @@ int64_t lascl( lapack::MatrixType matrixtype, int64_t kl, int64_t ku, double cfrom, double cto, int64_t m, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(kl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ku) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int kl_ = (lapack_int) kl; - lapack_int ku_ = (lapack_int) ku; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int kl_ = to_lapack_int( kl ); + lapack_int ku_ = to_lapack_int( ku ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zlascl( diff --git a/src/laset.cc b/src/laset.cc index f2eac69b..ddf1b3f4 100644 --- a/src/laset.cc +++ b/src/laset.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,16 +21,10 @@ void laset( lapack::MatrixType matrixtype, int64_t m, int64_t n, float offdiag, float diag, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_slaset( &matrixtype_, &m_, &n_, &offdiag, &diag, @@ -43,16 +38,10 @@ void laset( lapack::MatrixType matrixtype, int64_t m, int64_t n, double offdiag, double diag, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_dlaset( &matrixtype_, &m_, &n_, &offdiag, &diag, @@ -66,16 +55,10 @@ void laset( lapack::MatrixType matrixtype, int64_t m, int64_t n, std::complex offdiag, std::complex diag, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_claset( &matrixtype_, &m_, &n_, (lapack_complex_float*) &offdiag, (lapack_complex_float*) &diag, @@ -128,16 +111,10 @@ void laset( lapack::MatrixType matrixtype, int64_t m, int64_t n, std::complex offdiag, std::complex diag, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char matrixtype_ = to_char( matrixtype ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_zlaset( &matrixtype_, &m_, &n_, (lapack_complex_double*) &offdiag, (lapack_complex_double*) &diag, diff --git a/src/lassq.cc b/src/lassq.cc index 5ca217ae..6f3688de 100644 --- a/src/lassq.cc +++ b/src/lassq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,13 +23,8 @@ void lassq( float* scale, float* sumsq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_slassq( &n_, @@ -43,13 +39,8 @@ void lassq( double* scale, double* sumsq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_dlassq( &n_, @@ -64,13 +55,8 @@ void lassq( float* scale, float* sumsq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_classq( &n_, @@ -126,13 +112,8 @@ void lassq( double* scale, double* sumsq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int incx_ = to_lapack_int( incx ); LAPACK_zlassq( &n_, diff --git a/src/laswp.cc b/src/laswp.cc index 0bd2c089..898a1e0d 100644 --- a/src/laswp.cc +++ b/src/laswp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,18 +23,10 @@ void laswp( float* A, int64_t lda, int64_t k1, int64_t k2, int64_t const* ipiv, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int k1_ = (lapack_int) k1; - lapack_int k2_ = (lapack_int) k2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int k1_ = to_lapack_int( k1 ); + lapack_int k2_ = to_lapack_int( k2 ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(k1+(k2-k1)*std::abs(incx))] ); @@ -41,7 +34,7 @@ void laswp( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int incx_ = (lapack_int) incx; + lapack_int incx_ = to_lapack_int( incx ); LAPACK_slaswp( &n_, @@ -56,18 +49,10 @@ void laswp( double* A, int64_t lda, int64_t k1, int64_t k2, int64_t const* ipiv, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int k1_ = (lapack_int) k1; - lapack_int k2_ = (lapack_int) k2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int k1_ = to_lapack_int( k1 ); + lapack_int k2_ = to_lapack_int( k2 ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(k1+(k2-k1)*std::abs(incx))] ); @@ -75,7 +60,7 @@ void laswp( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int incx_ = (lapack_int) incx; + lapack_int incx_ = to_lapack_int( incx ); LAPACK_dlaswp( &n_, @@ -90,18 +75,10 @@ void laswp( std::complex* A, int64_t lda, int64_t k1, int64_t k2, int64_t const* ipiv, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int k1_ = (lapack_int) k1; - lapack_int k2_ = (lapack_int) k2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int k1_ = to_lapack_int( k1 ); + lapack_int k2_ = to_lapack_int( k2 ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(k1+(k2-k1)*std::abs(incx))] ); @@ -109,7 +86,7 @@ void laswp( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int incx_ = (lapack_int) incx; + lapack_int incx_ = to_lapack_int( incx ); LAPACK_claswp( &n_, @@ -162,18 +139,10 @@ void laswp( std::complex* A, int64_t lda, int64_t k1, int64_t k2, int64_t const* ipiv, int64_t incx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int k1_ = (lapack_int) k1; - lapack_int k2_ = (lapack_int) k2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int k1_ = to_lapack_int( k1 ); + lapack_int k2_ = to_lapack_int( k2 ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(k1+(k2-k1)*std::abs(incx))] ); @@ -181,7 +150,7 @@ void laswp( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int incx_ = (lapack_int) incx; + lapack_int incx_ = to_lapack_int( incx ); LAPACK_zlaswp( &n_, diff --git a/src/lauum.cc b/src/lauum.cc index eee51eb3..dfc88946 100644 --- a/src/lauum.cc +++ b/src/lauum.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t lauum( lapack::Uplo uplo, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_slauum( @@ -46,14 +42,9 @@ int64_t lauum( lapack::Uplo uplo, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dlauum( @@ -72,14 +63,9 @@ int64_t lauum( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_clauum( @@ -136,14 +122,9 @@ int64_t lauum( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zlauum( diff --git a/src/opgtr.cc b/src/opgtr.cc index 54931795..0078cf3a 100644 --- a/src/opgtr.cc +++ b/src/opgtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t opgtr( float const* tau, float* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t opgtr( double const* tau, double* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace diff --git a/src/opmtr.cc b/src/opmtr.cc index 8f76c28c..15e44047 100644 --- a/src/opmtr.cc +++ b/src/opmtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,18 +27,12 @@ int64_t opmtr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // from docs @@ -70,18 +65,12 @@ int64_t opmtr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // from docs diff --git a/src/orcsd2by1.cc b/src/orcsd2by1.cc index 9eac35a6..c7db175d 100644 --- a/src/orcsd2by1.cc +++ b/src/orcsd2by1.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,28 +28,17 @@ int64_t orcsd2by1( float* U2, int64_t ldu2, float* V1T, int64_t ldv1t ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx11) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx21) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldx11_ = (lapack_int) ldx11; - lapack_int ldx21_ = (lapack_int) ldx21; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldx11_ = to_lapack_int( ldx11 ); + lapack_int ldx21_ = to_lapack_int( ldx21 ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); lapack_int info_ = 0; // query for workspace size @@ -102,28 +92,17 @@ int64_t orcsd2by1( double* U2, int64_t ldu2, double* V1T, int64_t ldv1t ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(q) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx11) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx21) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu2) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv1t) > std::numeric_limits::max() ); - } char jobu1_ = to_char_csd( jobu1 ); char jobu2_ = to_char_csd( jobu2 ); char jobv1t_ = to_char_csd( jobv1t ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int q_ = (lapack_int) q; - lapack_int ldx11_ = (lapack_int) ldx11; - lapack_int ldx21_ = (lapack_int) ldx21; - lapack_int ldu1_ = (lapack_int) ldu1; - lapack_int ldu2_ = (lapack_int) ldu2; - lapack_int ldv1t_ = (lapack_int) ldv1t; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int q_ = to_lapack_int( q ); + lapack_int ldx11_ = to_lapack_int( ldx11 ); + lapack_int ldx21_ = to_lapack_int( ldx21 ); + lapack_int ldu1_ = to_lapack_int( ldu1 ); + lapack_int ldu2_ = to_lapack_int( ldu2 ); + lapack_int ldv1t_ = to_lapack_int( ldv1t ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orgbr.cc b/src/orgbr.cc index b15ad482..a99ebee5 100644 --- a/src/orgbr.cc +++ b/src/orgbr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,18 +23,11 @@ int64_t orgbr( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -73,18 +67,11 @@ int64_t orgbr( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orghr.cc b/src/orghr.cc index 66f796ef..53b5a0fa 100644 --- a/src/orghr.cc +++ b/src/orghr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,17 +22,10 @@ int64_t orghr( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -67,17 +61,10 @@ int64_t orghr( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orglq.cc b/src/orglq.cc index ebc35bdd..b861ef39 100644 --- a/src/orglq.cc +++ b/src/orglq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t orglq( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -70,17 +64,10 @@ int64_t orglq( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orgql.cc b/src/orgql.cc index 674374a4..bf4dc991 100644 --- a/src/orgql.cc +++ b/src/orgql.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t orgql( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -70,17 +64,10 @@ int64_t orgql( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orgqr.cc b/src/orgqr.cc index ff48401c..de9f6c45 100644 --- a/src/orgqr.cc +++ b/src/orgqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t orgqr( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -70,17 +64,10 @@ int64_t orgqr( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orgrq.cc b/src/orgrq.cc index 2bfac23f..1216b672 100644 --- a/src/orgrq.cc +++ b/src/orgrq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t orgrq( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -70,17 +64,10 @@ int64_t orgrq( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orgtr.cc b/src/orgtr.cc index b50aef07..1e61d0cf 100644 --- a/src/orgtr.cc +++ b/src/orgtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t orgtr( float* A, int64_t lda, float const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -69,14 +65,9 @@ int64_t orgtr( double* A, int64_t lda, double const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/orhr_col.cc b/src/orhr_col.cc index 5f6e2a92..7eae11c8 100644 --- a/src/orhr_col.cc +++ b/src/orhr_col.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30900 // >= 3.9.0 @@ -24,20 +25,12 @@ int64_t orhr_col( float* T, int64_t ldt, float* D ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } lapack_error_if(m < n); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // Work around bug in LAPACK <= 3.12. See https://github.com/Reference-LAPACK/lapack/pull/1018 @@ -147,19 +140,11 @@ int64_t orhr_col( double* T, int64_t ldt, double* D ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // Work around bug in LAPACK <= 3.12. See https://github.com/Reference-LAPACK/lapack/pull/1018 diff --git a/src/ormbr.cc b/src/ormbr.cc index 56b4bb7f..611bc406 100644 --- a/src/ormbr.cc +++ b/src/ormbr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,22 +28,14 @@ int64_t ormbr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -89,22 +82,14 @@ int64_t ormbr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormhr.cc b/src/ormhr.cc index f4a66e15..cb624b7d 100644 --- a/src/ormhr.cc +++ b/src/ormhr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,23 +27,14 @@ int64_t ormhr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -87,23 +79,14 @@ int64_t ormhr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormlq.cc b/src/ormlq.cc index ad8ac624..7607f2b7 100644 --- a/src/ormlq.cc +++ b/src/ormlq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,21 +28,13 @@ int64_t ormlq( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -88,21 +81,13 @@ int64_t ormlq( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormql.cc b/src/ormql.cc index fcf391df..dcaaf5d3 100644 --- a/src/ormql.cc +++ b/src/ormql.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,21 +28,13 @@ int64_t ormql( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -88,21 +81,13 @@ int64_t ormql( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormqr.cc b/src/ormqr.cc index ec8fd6e7..13fd1fef 100644 --- a/src/ormqr.cc +++ b/src/ormqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,21 +28,13 @@ int64_t ormqr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -88,21 +81,13 @@ int64_t ormqr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormrq.cc b/src/ormrq.cc index 7046a64a..15f7b952 100644 --- a/src/ormrq.cc +++ b/src/ormrq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,21 +28,13 @@ int64_t ormrq( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -88,21 +81,13 @@ int64_t ormrq( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormrz.cc b/src/ormrz.cc index 676bfbc9..aac14f89 100644 --- a/src/ormrz.cc +++ b/src/ormrz.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,23 +27,14 @@ int64_t ormrz( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -87,23 +79,14 @@ int64_t ormrz( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ormtr.cc b/src/ormtr.cc index baa71b53..159893bd 100644 --- a/src/ormtr.cc +++ b/src/ormtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,20 +28,13 @@ int64_t ormtr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -87,20 +81,13 @@ int64_t ormtr( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/pbcon.cc b/src/pbcon.cc index 035bffcb..df5e58e6 100644 --- a/src/pbcon.cc +++ b/src/pbcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,16 +23,10 @@ int64_t pbcon( float const* AB, int64_t ldab, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -57,16 +52,10 @@ int64_t pbcon( double const* AB, int64_t ldab, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -92,16 +81,10 @@ int64_t pbcon( std::complex const* AB, int64_t ldab, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -172,16 +155,10 @@ int64_t pbcon( std::complex const* AB, int64_t ldab, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pbequ.cc b/src/pbequ.cc index 63ab4d00..abba50e1 100644 --- a/src/pbequ.cc +++ b/src/pbequ.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,16 +24,10 @@ int64_t pbequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_spbequ( @@ -55,16 +50,10 @@ int64_t pbequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_dpbequ( @@ -87,16 +76,10 @@ int64_t pbequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_cpbequ( @@ -171,16 +154,10 @@ int64_t pbequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_zpbequ( diff --git a/src/pbrfs.cc b/src/pbrfs.cc index de822414..9b3208fa 100644 --- a/src/pbrfs.cc +++ b/src/pbrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,24 +27,14 @@ int64_t pbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -78,24 +69,14 @@ int64_t pbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -130,24 +111,14 @@ int64_t pbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -260,24 +231,14 @@ int64_t pbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pbstf.cc b/src/pbstf.cc index c3aeeb4f..0e9143e2 100644 --- a/src/pbstf.cc +++ b/src/pbstf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,16 +21,10 @@ int64_t pbstf( lapack::Uplo uplo, int64_t n, int64_t kd, float* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_spbstf( @@ -48,16 +43,10 @@ int64_t pbstf( lapack::Uplo uplo, int64_t n, int64_t kd, double* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_dpbstf( @@ -76,16 +65,10 @@ int64_t pbstf( lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_cpbstf( @@ -200,16 +183,10 @@ int64_t pbstf( lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_zpbstf( diff --git a/src/pbsv.cc b/src/pbsv.cc index c50df07f..b252e90c 100644 --- a/src/pbsv.cc +++ b/src/pbsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,20 +22,12 @@ int64_t pbsv( float* AB, int64_t ldab, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spbsv( @@ -55,20 +48,12 @@ int64_t pbsv( double* AB, int64_t ldab, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpbsv( @@ -89,20 +74,12 @@ int64_t pbsv( std::complex* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpbsv( @@ -211,20 +188,12 @@ int64_t pbsv( std::complex* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpbsv( diff --git a/src/pbsvx.cc b/src/pbsvx.cc index a6358601..947c0bb4 100644 --- a/src/pbsvx.cc +++ b/src/pbsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,26 +30,16 @@ int64_t pbsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -89,26 +80,16 @@ int64_t pbsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -149,26 +130,16 @@ int64_t pbsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -407,26 +378,16 @@ int64_t pbsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldafb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldafb_ = (lapack_int) ldafb; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldafb_ = to_lapack_int( ldafb ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pbtrf.cc b/src/pbtrf.cc index 289c5b5c..d866788b 100644 --- a/src/pbtrf.cc +++ b/src/pbtrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,16 +21,10 @@ int64_t pbtrf( lapack::Uplo uplo, int64_t n, int64_t kd, float* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_spbtrf( @@ -48,16 +43,10 @@ int64_t pbtrf( lapack::Uplo uplo, int64_t n, int64_t kd, double* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_dpbtrf( @@ -76,16 +65,10 @@ int64_t pbtrf( lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_cpbtrf( @@ -170,16 +153,10 @@ int64_t pbtrf( lapack::Uplo uplo, int64_t n, int64_t kd, std::complex* AB, int64_t ldab ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; LAPACK_zpbtrf( diff --git a/src/pbtrs.cc b/src/pbtrs.cc index 1da4a577..ebe73655 100644 --- a/src/pbtrs.cc +++ b/src/pbtrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,20 +22,12 @@ int64_t pbtrs( float const* AB, int64_t ldab, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spbtrs( @@ -55,20 +48,12 @@ int64_t pbtrs( double const* AB, int64_t ldab, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpbtrs( @@ -89,20 +74,12 @@ int64_t pbtrs( std::complex const* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpbtrs( @@ -168,20 +145,12 @@ int64_t pbtrs( std::complex const* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpbtrs( diff --git a/src/pftrf.cc b/src/pftrf.cc index 455bdb52..366dca75 100644 --- a/src/pftrf.cc +++ b/src/pftrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -19,13 +20,9 @@ int64_t pftrf( lapack::Op transr, lapack::Uplo uplo, int64_t n, float* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_spftrf( @@ -43,13 +40,9 @@ int64_t pftrf( lapack::Op transr, lapack::Uplo uplo, int64_t n, double* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dpftrf( @@ -67,13 +60,9 @@ int64_t pftrf( lapack::Op transr, lapack::Uplo uplo, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cpftrf( @@ -91,13 +80,9 @@ int64_t pftrf( lapack::Op transr, lapack::Uplo uplo, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zpftrf( diff --git a/src/pftri.cc b/src/pftri.cc index 5f4e5639..6223aa78 100644 --- a/src/pftri.cc +++ b/src/pftri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -19,13 +20,9 @@ int64_t pftri( lapack::Op transr, lapack::Uplo uplo, int64_t n, float* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_spftri( @@ -43,13 +40,9 @@ int64_t pftri( lapack::Op transr, lapack::Uplo uplo, int64_t n, double* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dpftri( @@ -67,13 +60,9 @@ int64_t pftri( lapack::Op transr, lapack::Uplo uplo, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cpftri( @@ -91,13 +80,9 @@ int64_t pftri( lapack::Op transr, lapack::Uplo uplo, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zpftri( diff --git a/src/pftrs.cc b/src/pftrs.cc index 5cba470d..4b8f1b7b 100644 --- a/src/pftrs.cc +++ b/src/pftrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,17 +21,11 @@ int64_t pftrs( float const* A, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spftrs( @@ -50,17 +45,11 @@ int64_t pftrs( double const* A, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpftrs( @@ -80,17 +69,11 @@ int64_t pftrs( std::complex const* A, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpftrs( @@ -110,17 +93,11 @@ int64_t pftrs( std::complex const* A, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpftrs( diff --git a/src/pocon.cc b/src/pocon.cc index 49da8342..e3195a3d 100644 --- a/src/pocon.cc +++ b/src/pocon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t pocon( float const* A, int64_t lda, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t pocon( double const* A, int64_t lda, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -88,14 +79,9 @@ int64_t pocon( std::complex const* A, int64_t lda, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -156,14 +142,9 @@ int64_t pocon( std::complex const* A, int64_t lda, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/poequ.cc b/src/poequ.cc index 4113c7c1..a0e9ee6b 100644 --- a/src/poequ.cc +++ b/src/poequ.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,13 +24,8 @@ int64_t poequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spoequ( @@ -51,13 +47,8 @@ int64_t poequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpoequ( @@ -79,13 +70,8 @@ int64_t poequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpoequ( @@ -148,13 +134,8 @@ int64_t poequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpoequ( diff --git a/src/poequb.cc b/src/poequb.cc index 54aa2944..6437f91c 100644 --- a/src/poequb.cc +++ b/src/poequb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,13 +24,8 @@ int64_t poequb( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spoequb( @@ -51,13 +47,8 @@ int64_t poequb( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpoequb( @@ -79,13 +70,8 @@ int64_t poequb( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpoequb( @@ -154,13 +140,8 @@ int64_t poequb( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpoequb( diff --git a/src/porfs.cc b/src/porfs.cc index ae191c90..573511c6 100644 --- a/src/porfs.cc +++ b/src/porfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,22 +27,13 @@ int64_t porfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -76,22 +68,13 @@ int64_t porfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -126,22 +109,13 @@ int64_t porfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -253,22 +227,13 @@ int64_t porfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/porfsx.cc b/src/porfsx.cc index 64177f88..bd9d589d 100644 --- a/src/porfsx.cc +++ b/src/porfsx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -32,27 +33,16 @@ int64_t porfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -94,27 +84,16 @@ int64_t porfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -156,27 +135,16 @@ int64_t porfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -478,27 +446,16 @@ int64_t porfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace diff --git a/src/posv.cc b/src/posv.cc index d9343e65..de28a3e5 100644 --- a/src/posv.cc +++ b/src/posv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,18 +23,11 @@ int64_t posv( float* A, int64_t lda, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sposv( @@ -54,18 +48,11 @@ int64_t posv( double* A, int64_t lda, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dposv( @@ -86,18 +73,11 @@ int64_t posv( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cposv( @@ -177,18 +157,11 @@ int64_t posv( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zposv( @@ -210,21 +183,13 @@ int64_t posv( double* X, int64_t ldx, int64_t* iter ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int iter_ = (lapack_int) *iter; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int iter_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -254,21 +219,13 @@ int64_t posv( std::complex* X, int64_t ldx, int64_t* iter ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int iter_ = (lapack_int) *iter; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int iter_ = 0; // out lapack_int info_ = 0; // allocate workspace diff --git a/src/posvx.cc b/src/posvx.cc index 80d10f6f..3ed50056 100644 --- a/src/posvx.cc +++ b/src/posvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,24 +30,15 @@ int64_t posvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -87,24 +79,15 @@ int64_t posvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -145,24 +128,15 @@ int64_t posvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -372,24 +346,15 @@ int64_t posvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/potf2.cc b/src/potf2.cc index 8f08e9b3..3eeee3cf 100644 --- a/src/potf2.cc +++ b/src/potf2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t potf2( lapack::Uplo uplo, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spotf2( @@ -46,14 +42,9 @@ int64_t potf2( lapack::Uplo uplo, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpotf2( @@ -72,14 +63,9 @@ int64_t potf2( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpotf2( @@ -143,14 +129,9 @@ int64_t potf2( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpotf2( diff --git a/src/potrf.cc b/src/potrf.cc index e7422fa9..8feb1ea8 100644 --- a/src/potrf.cc +++ b/src/potrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t potrf( lapack::Uplo uplo, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spotrf( @@ -46,14 +42,9 @@ int64_t potrf( lapack::Uplo uplo, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpotrf( @@ -72,14 +63,9 @@ int64_t potrf( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpotrf( @@ -143,14 +129,9 @@ int64_t potrf( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpotrf( diff --git a/src/potrf2.cc b/src/potrf2.cc index 8f49ba70..33712ac2 100644 --- a/src/potrf2.cc +++ b/src/potrf2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30600 // >= v3.6 @@ -22,14 +23,9 @@ int64_t potrf2( lapack::Uplo uplo, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spotrf2( @@ -48,14 +44,9 @@ int64_t potrf2( lapack::Uplo uplo, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpotrf2( @@ -74,14 +65,9 @@ int64_t potrf2( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpotrf2( @@ -157,14 +143,9 @@ int64_t potrf2( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpotrf2( diff --git a/src/potri.cc b/src/potri.cc index 71231aec..d72e5c37 100644 --- a/src/potri.cc +++ b/src/potri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t potri( lapack::Uplo uplo, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_spotri( @@ -46,14 +42,9 @@ int64_t potri( lapack::Uplo uplo, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dpotri( @@ -72,14 +63,9 @@ int64_t potri( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_cpotri( @@ -127,14 +113,9 @@ int64_t potri( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_zpotri( diff --git a/src/potrs.cc b/src/potrs.cc index d259323c..a1240180 100644 --- a/src/potrs.cc +++ b/src/potrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,18 +22,11 @@ int64_t potrs( float const* A, int64_t lda, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spotrs( @@ -53,18 +47,11 @@ int64_t potrs( double const* A, int64_t lda, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpotrs( @@ -85,18 +72,11 @@ int64_t potrs( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpotrs( @@ -153,18 +133,11 @@ int64_t potrs( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpotrs( diff --git a/src/ppcon.cc b/src/ppcon.cc index 6eb105f5..5b3fafcc 100644 --- a/src/ppcon.cc +++ b/src/ppcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,12 +23,8 @@ int64_t ppcon( float const* AP, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -53,12 +50,8 @@ int64_t ppcon( double const* AP, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -84,12 +77,8 @@ int64_t ppcon( std::complex const* AP, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -152,12 +141,8 @@ int64_t ppcon( std::complex const* AP, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace diff --git a/src/ppequ.cc b/src/ppequ.cc index 62661641..abc72c80 100644 --- a/src/ppequ.cc +++ b/src/ppequ.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -23,12 +24,8 @@ int64_t ppequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_sppequ( @@ -51,12 +48,8 @@ int64_t ppequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dppequ( @@ -79,12 +72,8 @@ int64_t ppequ( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cppequ( @@ -151,12 +140,8 @@ int64_t ppequ( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zppequ( diff --git a/src/pprfs.cc b/src/pprfs.cc index 1f81d388..ce3e034d 100644 --- a/src/pprfs.cc +++ b/src/pprfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,18 +27,11 @@ int64_t pprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -72,18 +66,11 @@ int64_t pprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -118,18 +105,11 @@ int64_t pprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -232,18 +212,11 @@ int64_t pprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/ppsv.cc b/src/ppsv.cc index bd66cb3f..8583f664 100644 --- a/src/ppsv.cc +++ b/src/ppsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,16 +22,10 @@ int64_t ppsv( float* AP, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sppsv( @@ -51,16 +46,10 @@ int64_t ppsv( double* AP, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dppsv( @@ -81,16 +70,10 @@ int64_t ppsv( std::complex* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cppsv( @@ -184,16 +167,10 @@ int64_t ppsv( std::complex* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zppsv( diff --git a/src/ppsvx.cc b/src/ppsvx.cc index dbdf0f29..638b85cf 100644 --- a/src/ppsvx.cc +++ b/src/ppsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,20 +30,13 @@ int64_t ppsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -83,20 +77,13 @@ int64_t ppsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -137,20 +124,13 @@ int64_t ppsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -368,20 +348,13 @@ int64_t ppsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); char equed_ = to_char( *equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pptrf.cc b/src/pptrf.cc index a53fbd82..74eecfe0 100644 --- a/src/pptrf.cc +++ b/src/pptrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,12 +21,8 @@ int64_t pptrf( lapack::Uplo uplo, int64_t n, float* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_spptrf( @@ -44,12 +41,8 @@ int64_t pptrf( lapack::Uplo uplo, int64_t n, double* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dpptrf( @@ -68,12 +61,8 @@ int64_t pptrf( lapack::Uplo uplo, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cpptrf( @@ -146,12 +135,8 @@ int64_t pptrf( lapack::Uplo uplo, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zpptrf( diff --git a/src/pptri.cc b/src/pptri.cc index a224ac24..33c2416f 100644 --- a/src/pptri.cc +++ b/src/pptri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,12 +21,8 @@ int64_t pptri( lapack::Uplo uplo, int64_t n, float* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_spptri( @@ -44,12 +41,8 @@ int64_t pptri( lapack::Uplo uplo, int64_t n, double* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dpptri( @@ -68,12 +61,8 @@ int64_t pptri( lapack::Uplo uplo, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cpptri( @@ -122,12 +111,8 @@ int64_t pptri( lapack::Uplo uplo, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zpptri( diff --git a/src/pptrs.cc b/src/pptrs.cc index 64f09633..4e21507f 100644 --- a/src/pptrs.cc +++ b/src/pptrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,16 +22,10 @@ int64_t pptrs( float const* AP, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spptrs( @@ -51,16 +46,10 @@ int64_t pptrs( double const* AP, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpptrs( @@ -81,16 +70,10 @@ int64_t pptrs( std::complex const* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpptrs( @@ -148,16 +131,10 @@ int64_t pptrs( std::complex const* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpptrs( diff --git a/src/pstrf.cc b/src/pstrf.cc index 28ddc858..b61eedea 100644 --- a/src/pstrf.cc +++ b/src/pstrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t pstrf( int64_t* piv, int64_t* rank, float tol ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > piv_( (n) ); @@ -37,7 +33,7 @@ int64_t pstrf( #else lapack_int* piv_ptr = piv; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -66,14 +62,9 @@ int64_t pstrf( int64_t* piv, int64_t* rank, double tol ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > piv_( (n) ); @@ -81,7 +72,7 @@ int64_t pstrf( #else lapack_int* piv_ptr = piv; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -110,14 +101,9 @@ int64_t pstrf( int64_t* piv, int64_t* rank, float tol ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > piv_( (n) ); @@ -125,7 +111,7 @@ int64_t pstrf( #else lapack_int* piv_ptr = piv; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -154,14 +140,9 @@ int64_t pstrf( int64_t* piv, int64_t* rank, double tol ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > piv_( (n) ); @@ -169,7 +150,7 @@ int64_t pstrf( #else lapack_int* piv_ptr = piv; #endif - lapack_int rank_ = (lapack_int) *rank; + lapack_int rank_ = 0; // out lapack_int info_ = 0; // allocate workspace diff --git a/src/ptcon.cc b/src/ptcon.cc index 497712fe..3e0a2996 100644 --- a/src/ptcon.cc +++ b/src/ptcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,11 +24,7 @@ int64_t ptcon( float const* E, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -52,11 +49,7 @@ int64_t ptcon( double const* E, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -81,11 +74,7 @@ int64_t ptcon( std::complex const* E, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -154,11 +143,7 @@ int64_t ptcon( std::complex const* E, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pteqr.cc b/src/pteqr.cc index 0cf8bfd7..a53caf49 100644 --- a/src/pteqr.cc +++ b/src/pteqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t pteqr( float* E, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t pteqr( double* E, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -88,14 +79,9 @@ int64_t pteqr( float* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -121,14 +107,9 @@ int64_t pteqr( double* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/ptrfs.cc b/src/ptrfs.cc index 8cde0b49..83903668 100644 --- a/src/ptrfs.cc +++ b/src/ptrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -28,17 +29,10 @@ int64_t ptrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -74,17 +68,10 @@ int64_t ptrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -120,18 +107,11 @@ int64_t ptrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -246,18 +226,11 @@ int64_t ptrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/ptsv.cc b/src/ptsv.cc index c67ee114..325bd61b 100644 --- a/src/ptsv.cc +++ b/src/ptsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,15 +23,9 @@ int64_t ptsv( float* E, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sptsv( @@ -52,15 +47,9 @@ int64_t ptsv( double* E, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dptsv( @@ -82,15 +71,9 @@ int64_t ptsv( std::complex* E, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cptsv( @@ -157,15 +140,9 @@ int64_t ptsv( std::complex* E, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zptsv( diff --git a/src/ptsvx.cc b/src/ptsvx.cc index 51061c91..3e6cf7d1 100644 --- a/src/ptsvx.cc +++ b/src/ptsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -29,18 +30,11 @@ int64_t ptsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -78,18 +72,11 @@ int64_t ptsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -127,18 +114,11 @@ int64_t ptsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -281,18 +261,11 @@ int64_t ptsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/pttrf.cc b/src/pttrf.cc index 07f4376d..3403337e 100644 --- a/src/pttrf.cc +++ b/src/pttrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -21,11 +22,7 @@ int64_t pttrf( float* D, float* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_spttrf( @@ -45,11 +42,7 @@ int64_t pttrf( double* D, double* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dpttrf( @@ -69,11 +62,7 @@ int64_t pttrf( float* D, std::complex* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_cpttrf( @@ -123,11 +112,7 @@ int64_t pttrf( double* D, std::complex* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_zpttrf( diff --git a/src/pttrs.cc b/src/pttrs.cc index 7602240c..9498b402 100644 --- a/src/pttrs.cc +++ b/src/pttrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,15 +23,9 @@ int64_t pttrs( float const* E, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_spttrs( @@ -52,15 +47,9 @@ int64_t pttrs( double const* E, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dpttrs( @@ -82,16 +71,10 @@ int64_t pttrs( std::complex const* E, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cpttrs( @@ -164,16 +147,10 @@ int64_t pttrs( std::complex const* E, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zpttrs( diff --git a/src/sbev.cc b/src/sbev.cc index 1f64f9cc..2bc4d59b 100644 --- a/src/sbev.cc +++ b/src/sbev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t sbev( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -60,19 +54,12 @@ int64_t sbev( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sbev_2stage.cc b/src/sbev_2stage.cc index 9f37a490..564f82de 100644 --- a/src/sbev_2stage.cc +++ b/src/sbev_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t sbev_2stage( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -77,19 +71,12 @@ int64_t sbev_2stage( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sbevd.cc b/src/sbevd.cc index 9921604b..6bbef9f4 100644 --- a/src/sbevd.cc +++ b/src/sbevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t sbevd( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -80,19 +74,12 @@ int64_t sbevd( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sbevd_2stage.cc b/src/sbevd_2stage.cc index 25b95ed7..36d6c2f0 100644 --- a/src/sbevd_2stage.cc +++ b/src/sbevd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t sbevd_2stage( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -82,19 +76,12 @@ int64_t sbevd_2stage( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sbevx.cc b/src/sbevx.cc index 4a630a3f..9c050594 100644 --- a/src/sbevx.cc +++ b/src/sbevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,32 +21,22 @@ int64_t sbevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, float* AB, int64_t ldab, float* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -62,7 +53,7 @@ int64_t sbevx( LAPACK_ssbevx( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -72,10 +63,10 @@ int64_t sbevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -86,32 +77,22 @@ int64_t sbevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, double* AB, int64_t ldab, double* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -128,7 +109,7 @@ int64_t sbevx( LAPACK_dsbevx( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -138,10 +119,10 @@ int64_t sbevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/sbevx_2stage.cc b/src/sbevx_2stage.cc index d94e086f..83c8ad45 100644 --- a/src/sbevx_2stage.cc +++ b/src/sbevx_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,32 +23,22 @@ int64_t sbevx_2stage( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, float* AB, int64_t ldab, float* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -64,7 +55,7 @@ int64_t sbevx_2stage( LAPACK_ssbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, qry_work, &ineg_one, @@ -83,7 +74,7 @@ int64_t sbevx_2stage( LAPACK_ssbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], &lwork_, @@ -93,10 +84,10 @@ int64_t sbevx_2stage( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -107,32 +98,22 @@ int64_t sbevx_2stage( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, int64_t kd, double* AB, int64_t ldab, double* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -149,7 +130,7 @@ int64_t sbevx_2stage( LAPACK_dsbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, qry_work, &ineg_one, @@ -168,7 +149,7 @@ int64_t sbevx_2stage( LAPACK_dsbevx_2stage( &jobz_, &range_, &uplo_, &n_, &kd_, AB, &ldab_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], &lwork_, @@ -178,10 +159,10 @@ int64_t sbevx_2stage( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/sbgst.cc b/src/sbgst.cc index 23abd1b3..7125f3d2 100644 --- a/src/sbgst.cc +++ b/src/sbgst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,23 +23,14 @@ int64_t sbgst( float const* BB, int64_t ldbb, float* X, int64_t ldx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -64,23 +56,14 @@ int64_t sbgst( double const* BB, int64_t ldbb, double* X, int64_t ldx ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sbgv.cc b/src/sbgv.cc index 2615defd..a6a39107 100644 --- a/src/sbgv.cc +++ b/src/sbgv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,23 +24,14 @@ int64_t sbgv( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -67,23 +59,14 @@ int64_t sbgv( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sbgvd.cc b/src/sbgvd.cc index 990af216..22c34c2a 100644 --- a/src/sbgvd.cc +++ b/src/sbgvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,23 +24,14 @@ int64_t sbgvd( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -91,23 +83,14 @@ int64_t sbgvd( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sbgvx.cc b/src/sbgvx.cc index f1a324aa..3c5b5649 100644 --- a/src/sbgvx.cc +++ b/src/sbgvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,39 +22,27 @@ int64_t sbgvx( float* AB, int64_t ldab, float* BB, int64_t ldbb, float* Q, int64_t ldq, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > ifail_( n ); // was m; n >= m + lapack::vector< lapack_int > ifail_( n ); // was nfound; n >= nfound lapack_int* ifail_ptr = &ifail_[0]; #else lapack_int* ifail_ptr = ifail; @@ -68,7 +57,7 @@ int64_t sbgvx( &jobz_, &range_, &uplo_, &n_, &ka_, &kb_, AB, &ldab_, BB, &ldbb_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -78,10 +67,10 @@ int64_t sbgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -93,39 +82,27 @@ int64_t sbgvx( double* AB, int64_t ldab, double* BB, int64_t ldbb, double* Q, int64_t ldq, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ka) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldbb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ka_ = (lapack_int) ka; - lapack_int kb_ = (lapack_int) kb; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldbb_ = (lapack_int) ldbb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ka_ = to_lapack_int( ka ); + lapack_int kb_ = to_lapack_int( kb ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldbb_ = to_lapack_int( ldbb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > ifail_( n ); // was m; n >= m + lapack::vector< lapack_int > ifail_( n ); // was nfound; n >= nfound lapack_int* ifail_ptr = &ifail_[0]; #else lapack_int* ifail_ptr = ifail; @@ -140,7 +117,7 @@ int64_t sbgvx( &jobz_, &range_, &uplo_, &n_, &ka_, &kb_, AB, &ldab_, BB, &ldbb_, - Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &m_, + Q, &ldq_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -150,10 +127,10 @@ int64_t sbgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/sbtrd.cc b/src/sbtrd.cc index d2937184..4d6abc39 100644 --- a/src/sbtrd.cc +++ b/src/sbtrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,19 +24,12 @@ int64_t sbtrd( float* E, float* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace @@ -63,19 +57,12 @@ int64_t sbtrd( double* E, double* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sfrk.cc b/src/sfrk.cc index 812b25c7..646ee0ef 100644 --- a/src/sfrk.cc +++ b/src/sfrk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,12 @@ void sfrk( float const* A, int64_t lda, float beta, float* C ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_ssfrk( &transr_, &uplo_, &trans_, &n_, &k_, &alpha, @@ -46,18 +41,12 @@ void sfrk( double const* A, int64_t lda, double beta, double* C ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); LAPACK_dsfrk( &transr_, &uplo_, &trans_, &n_, &k_, &alpha, diff --git a/src/spcon.cc b/src/spcon.cc index c8353a18..8c7a11bd 100644 --- a/src/spcon.cc +++ b/src/spcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,12 +23,8 @@ int64_t spcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -61,12 +58,8 @@ int64_t spcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -100,12 +93,8 @@ int64_t spcon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -137,12 +126,8 @@ int64_t spcon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/spev.cc b/src/spev.cc index 14da1f7a..0bdbc67d 100644 --- a/src/spev.cc +++ b/src/spev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t spev( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -56,15 +52,10 @@ int64_t spev( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/spevd.cc b/src/spevd.cc index 46c6e03c..953d6256 100644 --- a/src/spevd.cc +++ b/src/spevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t spevd( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -76,15 +72,10 @@ int64_t spevd( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/spevx.cc b/src/spevx.cc index 0ed47035..2e6daafc 100644 --- a/src/spevx.cc +++ b/src/spevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -19,26 +20,19 @@ using blas::real; int64_t spevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, float* AP, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -54,7 +48,7 @@ int64_t spevx( LAPACK_sspevx( &jobz_, &range_, &uplo_, &n_, - AP, &vl, &vu, &il_, &iu_, &abstol, &m_, + AP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -64,10 +58,10 @@ int64_t spevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -77,26 +71,19 @@ int64_t spevx( int64_t spevx( lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, double* AP, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -112,7 +99,7 @@ int64_t spevx( LAPACK_dspevx( &jobz_, &range_, &uplo_, &n_, - AP, &vl, &vu, &il_, &iu_, &abstol, &m_, + AP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -122,10 +109,10 @@ int64_t spevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/spgst.cc b/src/spgst.cc index 33639963..b9ed7d13 100644 --- a/src/spgst.cc +++ b/src/spgst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t spgst( float* AP, float const* BP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_sspgst( @@ -47,14 +43,9 @@ int64_t spgst( double* AP, double const* BP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dspgst( diff --git a/src/spgv.cc b/src/spgv.cc index 837a3af4..d70be140 100644 --- a/src/spgv.cc +++ b/src/spgv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,11 @@ int64_t spgv( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -61,17 +56,11 @@ int64_t spgv( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/spgvd.cc b/src/spgvd.cc index 4b37f0d0..7e47a2ff 100644 --- a/src/spgvd.cc +++ b/src/spgvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,11 @@ int64_t spgvd( float* W, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -82,17 +77,11 @@ int64_t spgvd( double* W, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/spgvx.cc b/src/spgvx.cc index c6cff691..a2d152a9 100644 --- a/src/spgvx.cc +++ b/src/spgvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,28 +21,20 @@ int64_t spgvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, float* AP, float* BP, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -58,7 +51,7 @@ int64_t spgvx( LAPACK_sspgvx( &itype_, &jobz_, &range_, &uplo_, &n_, AP, - BP, &vl, &vu, &il_, &iu_, &abstol, &m_, + BP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -68,10 +61,10 @@ int64_t spgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -82,28 +75,20 @@ int64_t spgvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, double* AP, double* BP, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -120,7 +105,7 @@ int64_t spgvx( LAPACK_dspgvx( &itype_, &jobz_, &range_, &uplo_, &n_, AP, - BP, &vl, &vu, &il_, &iu_, &abstol, &m_, + BP, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -130,10 +115,10 @@ int64_t spgvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/sprfs.cc b/src/sprfs.cc index 4217e299..5cf43e4c 100644 --- a/src/sprfs.cc +++ b/src/sprfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,16 +27,9 @@ int64_t sprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,8 +37,8 @@ int64_t sprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -80,16 +74,9 @@ int64_t sprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -97,8 +84,8 @@ int64_t sprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -134,16 +121,9 @@ int64_t sprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -151,8 +131,8 @@ int64_t sprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -188,16 +168,9 @@ int64_t sprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -205,8 +178,8 @@ int64_t sprfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/spsv.cc b/src/spsv.cc index 6ded3d76..309bf5b5 100644 --- a/src/spsv.cc +++ b/src/spsv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t spsv( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -38,7 +33,7 @@ int64_t spsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_sspsv( @@ -63,15 +58,9 @@ int64_t spsv( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -79,7 +68,7 @@ int64_t spsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dspsv( @@ -104,15 +93,9 @@ int64_t spsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -120,7 +103,7 @@ int64_t spsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_cspsv( @@ -145,15 +128,9 @@ int64_t spsv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -161,7 +138,7 @@ int64_t spsv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zspsv( diff --git a/src/spsvx.cc b/src/spsvx.cc index d0c4b97c..0563e976 100644 --- a/src/spsvx.cc +++ b/src/spsvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,17 +28,10 @@ int64_t spsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -45,8 +39,8 @@ int64_t spsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -86,17 +80,10 @@ int64_t spsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -104,8 +91,8 @@ int64_t spsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -145,17 +132,10 @@ int64_t spsvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -163,8 +143,8 @@ int64_t spsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -204,17 +184,10 @@ int64_t spsvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -222,8 +195,8 @@ int64_t spsvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sptrd.cc b/src/sptrd.cc index 36d4a94a..6ffcb141 100644 --- a/src/sptrd.cc +++ b/src/sptrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -22,12 +23,8 @@ int64_t sptrd( float* E, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ssptrd( @@ -51,12 +48,8 @@ int64_t sptrd( double* E, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dsptrd( diff --git a/src/sptrf.cc b/src/sptrf.cc index 5377c868..f5c45274 100644 --- a/src/sptrf.cc +++ b/src/sptrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,12 +22,8 @@ int64_t sptrf( float* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -56,12 +53,8 @@ int64_t sptrf( double* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -91,12 +84,8 @@ int64_t sptrf( std::complex* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -126,12 +115,8 @@ int64_t sptrf( std::complex* AP, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/sptri.cc b/src/sptri.cc index be8330a8..5eb4ff17 100644 --- a/src/sptri.cc +++ b/src/sptri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,12 +22,8 @@ int64_t sptri( float* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -57,12 +54,8 @@ int64_t sptri( double* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -93,12 +86,8 @@ int64_t sptri( std::complex* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -129,12 +118,8 @@ int64_t sptri( std::complex* AP, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/sptrs.cc b/src/sptrs.cc index d4048efa..0d5d9325 100644 --- a/src/sptrs.cc +++ b/src/sptrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,9 @@ int64_t sptrs( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -38,7 +33,7 @@ int64_t sptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ssptrs( @@ -60,15 +55,9 @@ int64_t sptrs( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -76,7 +65,7 @@ int64_t sptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dsptrs( @@ -98,15 +87,9 @@ int64_t sptrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -114,7 +97,7 @@ int64_t sptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_csptrs( @@ -136,15 +119,9 @@ int64_t sptrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -152,7 +129,7 @@ int64_t sptrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zsptrs( diff --git a/src/stedc.cc b/src/stedc.cc index c796fa98..c8bfbf1c 100644 --- a/src/stedc.cc +++ b/src/stedc.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t stedc( float* E, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -75,14 +71,9 @@ int64_t stedc( double* E, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -128,14 +119,9 @@ int64_t stedc( float* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -186,14 +172,9 @@ int64_t stedc( double* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/stegr.cc b/src/stegr.cc index 8b737689..3ddb6b3e 100644 --- a/src/stegr.cc +++ b/src/stegr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,28 +21,21 @@ int64_t stegr( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -55,7 +49,7 @@ int64_t stegr( LAPACK_sstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -75,7 +69,7 @@ int64_t stegr( LAPACK_sstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -85,9 +79,9 @@ int64_t stegr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); // was begin to end #endif return info_; } @@ -97,28 +91,21 @@ int64_t stegr( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = to_lapack_int( *nfound ); + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -132,7 +119,7 @@ int64_t stegr( LAPACK_dstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -152,7 +139,7 @@ int64_t stegr( LAPACK_dstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -162,9 +149,9 @@ int64_t stegr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); // was begin to end #endif return info_; } @@ -174,28 +161,21 @@ int64_t stegr( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -209,7 +189,7 @@ int64_t stegr( LAPACK_cstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, isuppz_ptr, @@ -229,7 +209,7 @@ int64_t stegr( LAPACK_cstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_float*) Z, &ldz_, isuppz_ptr, @@ -239,9 +219,9 @@ int64_t stegr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); // was begin to end #endif return info_; } @@ -251,28 +231,21 @@ int64_t stegr( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -286,7 +259,7 @@ int64_t stegr( LAPACK_zstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, isuppz_ptr, @@ -306,7 +279,7 @@ int64_t stegr( LAPACK_zstegr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, (lapack_complex_double*) Z, &ldz_, isuppz_ptr, @@ -316,9 +289,9 @@ int64_t stegr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); // was begin to end #endif return info_; } diff --git a/src/stein.cc b/src/stein.cc index dbbbdc0d..520d19e6 100644 --- a/src/stein.cc +++ b/src/stein.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,14 +27,8 @@ int64_t stein( float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iblock_( &iblock[0], &iblock[(n)] ); @@ -48,7 +43,7 @@ int64_t stein( #else lapack_int const* isplit_ptr = isplit; #endif - lapack_int ldz_ = (lapack_int) ldz; + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (m) ); @@ -93,14 +88,8 @@ int64_t stein( double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iblock_( &iblock[0], &iblock[(n)] ); @@ -115,7 +104,7 @@ int64_t stein( #else lapack_int const* isplit_ptr = isplit; #endif - lapack_int ldz_ = (lapack_int) ldz; + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (m) ); @@ -160,14 +149,8 @@ int64_t stein( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iblock_( &iblock[0], &iblock[(n)] ); @@ -182,7 +165,7 @@ int64_t stein( #else lapack_int const* isplit_ptr = isplit; #endif - lapack_int ldz_ = (lapack_int) ldz; + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (m) ); @@ -227,14 +210,8 @@ int64_t stein( std::complex* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int m_ = (lapack_int) m; + lapack_int n_ = to_lapack_int( n ); + lapack_int m_ = to_lapack_int( m ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > iblock_( &iblock[0], &iblock[(n)] ); @@ -249,7 +226,7 @@ int64_t stein( #else lapack_int const* isplit_ptr = isplit; #endif - lapack_int ldz_ = (lapack_int) ldz; + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (m) ); diff --git a/src/stemr.cc b/src/stemr.cc index d809e7b9..ad4f2433 100644 --- a/src/stemr.cc +++ b/src/stemr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,36 +21,28 @@ int64_t stemr( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t nzc, int64_t* isuppz, bool* tryrac ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nzc) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int nzc_ = (lapack_int) nzc; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int nzc_ = to_lapack_int( nzc ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; #endif - lapack_int tryrac_ = (lapack_int) *tryrac; + lapack_int tryrac_ = to_lapack_int( *tryrac ); lapack_int info_ = 0; // query for workspace size @@ -59,7 +52,7 @@ int64_t stemr( LAPACK_sstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -79,7 +72,7 @@ int64_t stemr( LAPACK_sstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -89,9 +82,9 @@ int64_t stemr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); #endif *tryrac = tryrac_; return info_; @@ -102,36 +95,28 @@ int64_t stemr( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t nzc, int64_t* isuppz, bool* tryrac ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nzc) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int nzc_ = (lapack_int) nzc; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int nzc_ = to_lapack_int( nzc ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; #endif - lapack_int tryrac_ = (lapack_int) *tryrac; + lapack_int tryrac_ = to_lapack_int( *tryrac ); lapack_int info_ = 0; // query for workspace size @@ -141,7 +126,7 @@ int64_t stemr( LAPACK_dstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -161,7 +146,7 @@ int64_t stemr( LAPACK_dstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -171,9 +156,9 @@ int64_t stemr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); #endif *tryrac = tryrac_; return info_; @@ -184,36 +169,28 @@ int64_t stemr( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, - int64_t* m, + int64_t* nfound, float* W, std::complex* Z, int64_t ldz, int64_t nzc, int64_t* isuppz, bool* tryrac ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nzc) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int nzc_ = (lapack_int) nzc; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int nzc_ = to_lapack_int( nzc ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; #endif - lapack_int tryrac_ = (lapack_int) *tryrac; + lapack_int tryrac_ = to_lapack_int( *tryrac ); lapack_int info_ = 0; // query for workspace size @@ -223,7 +200,7 @@ int64_t stemr( LAPACK_cstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, (lapack_complex_float*) Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -243,7 +220,7 @@ int64_t stemr( LAPACK_cstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, (lapack_complex_float*) Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -253,9 +230,9 @@ int64_t stemr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); #endif *tryrac = tryrac_; return info_; @@ -266,36 +243,28 @@ int64_t stemr( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, - int64_t* m, + int64_t* nfound, double* W, std::complex* Z, int64_t ldz, int64_t nzc, int64_t* isuppz, bool* tryrac ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nzc) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int nzc_ = (lapack_int) nzc; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int nzc_ = to_lapack_int( nzc ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound; n >= nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; #endif - lapack_int tryrac_ = (lapack_int) *tryrac; + lapack_int tryrac_ = to_lapack_int( *tryrac ); lapack_int info_ = 0; // query for workspace size @@ -305,7 +274,7 @@ int64_t stemr( LAPACK_zstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, (lapack_complex_double*) Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -325,7 +294,7 @@ int64_t stemr( LAPACK_zstemr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &m_, + E, &vl, &vu, &il_, &iu_, &nfound_, W, (lapack_complex_double*) Z, &ldz_, &nzc_, isuppz_ptr, &tryrac_, @@ -335,9 +304,9 @@ int64_t stemr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + std::copy( &isuppz_[0], &isuppz_[ nfound_ ], isuppz ); #endif *tryrac = tryrac_; return info_; diff --git a/src/steqr.cc b/src/steqr.cc index 98d84f61..f870fd47 100644 --- a/src/steqr.cc +++ b/src/steqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t steqr( float* E, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t steqr( double* E, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -88,14 +79,9 @@ int64_t steqr( float* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -121,14 +107,9 @@ int64_t steqr( double* E, std::complex* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char compz_ = to_char_comp( compz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sterf.cc b/src/sterf.cc index 3726e268..7ac39676 100644 --- a/src/sterf.cc +++ b/src/sterf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,11 +21,7 @@ int64_t sterf( float* D, float* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ssterf( @@ -43,11 +40,7 @@ int64_t sterf( double* D, double* E ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dsterf( diff --git a/src/stev.cc b/src/stev.cc index f1b9bf1b..a73469ee 100644 --- a/src/stev.cc +++ b/src/stev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t stev( float* E, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t stev( double* E, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // allocate workspace diff --git a/src/stevd.cc b/src/stevd.cc index 4895ff66..39e65130 100644 --- a/src/stevd.cc +++ b/src/stevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t stevd( float* E, float* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size @@ -75,14 +71,9 @@ int64_t stevd( double* E, double* Z, int64_t ldz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); - lapack_int n_ = (lapack_int) n; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldz_ = to_lapack_int( ldz ); lapack_int info_ = 0; // query for workspace size diff --git a/src/stevr.cc b/src/stevr.cc index a0dc138f..8854c4fa 100644 --- a/src/stevr.cc +++ b/src/stevr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,28 +21,21 @@ int64_t stevr( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -55,7 +49,7 @@ int64_t stevr( LAPACK_sstevr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -75,7 +69,7 @@ int64_t stevr( LAPACK_sstevr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -85,9 +79,10 @@ int64_t stevr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + // was begin to end + std::copy( &isuppz_[ 0 ], &isuppz_[ nfound_ ], isuppz ); #endif return info_; } @@ -97,28 +92,21 @@ int64_t stevr( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy - lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was m; n >= m + lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was nfound lapack_int* isuppz_ptr = &isuppz_[0]; #else lapack_int* isuppz_ptr = isuppz; @@ -132,7 +120,7 @@ int64_t stevr( LAPACK_dstevr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -152,7 +140,7 @@ int64_t stevr( LAPACK_dstevr( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, isuppz_ptr, @@ -162,9 +150,10 @@ int64_t stevr( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 - std::copy( &isuppz_[0], &isuppz_[m_], isuppz ); // was begin to end + // was begin to end + std::copy( &isuppz_[ 0 ], &isuppz_[ nfound_ ], isuppz ); #endif return info_; } diff --git a/src/stevx.cc b/src/stevx.cc index ffa2cd57..bad330fc 100644 --- a/src/stevx.cc +++ b/src/stevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,25 +21,18 @@ int64_t stevx( lapack::Job jobz, lapack::Range range, int64_t n, float* D, float* E, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -55,7 +49,7 @@ int64_t stevx( LAPACK_sstevx( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -65,10 +59,10 @@ int64_t stevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -79,25 +73,18 @@ int64_t stevx( lapack::Job jobz, lapack::Range range, int64_t n, double* D, double* E, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); - lapack_int n_ = (lapack_int) n; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -114,7 +101,7 @@ int64_t stevx( LAPACK_dstevx( &jobz_, &range_, &n_, D, - E, &vl, &vu, &il_, &iu_, &abstol, &m_, + E, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], @@ -124,10 +111,10 @@ int64_t stevx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/sycon.cc b/src/sycon.cc index bab76168..910b1c37 100644 --- a/src/sycon.cc +++ b/src/sycon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,14 +24,9 @@ int64_t sycon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -65,14 +61,9 @@ int64_t sycon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -107,14 +98,9 @@ int64_t sycon( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -191,14 +177,9 @@ int64_t sycon( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/sycon_rk.cc b/src/sycon_rk.cc index 9f368fb2..8cf068b2 100644 --- a/src/sycon_rk.cc +++ b/src/sycon_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,14 +27,9 @@ int64_t sycon_rk( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -70,14 +66,9 @@ int64_t sycon_rk( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -114,14 +105,9 @@ int64_t sycon_rk( int64_t const* ipiv, float anorm, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -233,14 +219,9 @@ int64_t sycon_rk( int64_t const* ipiv, double anorm, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/syequb.cc b/src/syequb.cc index 9e6681fd..c8b4a949 100644 --- a/src/syequb.cc +++ b/src/syequb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t syequb( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -58,14 +54,9 @@ int64_t syequb( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -92,14 +83,9 @@ int64_t syequb( float* scond, float* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -171,14 +157,9 @@ int64_t syequb( double* scond, double* amax ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/syev.cc b/src/syev.cc index 37d4b2d8..91623db2 100644 --- a/src/syev.cc +++ b/src/syev.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t syev( float* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -70,15 +66,10 @@ int64_t syev( double* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/syev_2stage.cc b/src/syev_2stage.cc index 7e81de3c..2e172568 100644 --- a/src/syev_2stage.cc +++ b/src/syev_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,10 @@ int64_t syev_2stage( float* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -72,15 +68,10 @@ int64_t syev_2stage( double* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/syevd.cc b/src/syevd.cc index 4eef637b..50be70c6 100644 --- a/src/syevd.cc +++ b/src/syevd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,15 +23,10 @@ int64_t syevd( float* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -75,15 +71,10 @@ int64_t syevd( double* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/syevd_2stage.cc b/src/syevd_2stage.cc index dad49c29..59b4d7d2 100644 --- a/src/syevd_2stage.cc +++ b/src/syevd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,15 +25,10 @@ int64_t syevd_2stage( float* A, int64_t lda, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -77,15 +73,10 @@ int64_t syevd_2stage( double* A, int64_t lda, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/syevr.cc b/src/syevr.cc index 912e200e..1a502301 100644 --- a/src/syevr.cc +++ b/src/syevr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,15 @@ int64_t syevr( float* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,m), n >= m @@ -104,23 +97,15 @@ int64_t syevr( double* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,m), n >= m diff --git a/src/syevr_2stage.cc b/src/syevr_2stage.cc index 2edb3682..3d148076 100644 --- a/src/syevr_2stage.cc +++ b/src/syevr_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,23 +28,15 @@ int64_t syevr_2stage( float* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,m), n >= m @@ -106,23 +99,15 @@ int64_t syevr_2stage( double* Z, int64_t ldz, int64_t* isuppz ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > isuppz_( (2*max( 1, n )) ); // was max(1,m), n >= m diff --git a/src/syevx.cc b/src/syevx.cc index e171fb68..6e752722 100644 --- a/src/syevx.cc +++ b/src/syevx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,15 @@ int64_t syevx( float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -105,23 +98,15 @@ int64_t syevx( double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_ = (lapack_int) *nfound; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); diff --git a/src/syevx_2stage.cc b/src/syevx_2stage.cc index 9f391d63..f31ccfa1 100644 --- a/src/syevx_2stage.cc +++ b/src/syevx_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,23 +28,15 @@ int64_t syevx_2stage( float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -107,23 +100,15 @@ int64_t syevx_2stage( double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int nfound_; // output - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); diff --git a/src/sygst.cc b/src/sygst.cc index ce74259e..746115f6 100644 --- a/src/sygst.cc +++ b/src/sygst.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,11 @@ int64_t sygst( float* A, int64_t lda, float const* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ssygst( @@ -51,18 +45,11 @@ int64_t sygst( double* A, int64_t lda, double const* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dsygst( diff --git a/src/sygv.cc b/src/sygv.cc index f4a5d1d4..febcf2e9 100644 --- a/src/sygv.cc +++ b/src/sygv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t sygv( float* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -75,19 +69,12 @@ int64_t sygv( double* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sygv_2stage.cc b/src/sygv_2stage.cc index bb04f51d..308c09e6 100644 --- a/src/sygv_2stage.cc +++ b/src/sygv_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,19 +25,12 @@ int64_t sygv_2stage( float* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -77,19 +71,12 @@ int64_t sygv_2stage( double* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sygvd.cc b/src/sygvd.cc index 5a02f8ab..d7987a6a 100644 --- a/src/sygvd.cc +++ b/src/sygvd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,19 +23,12 @@ int64_t sygvd( float* B, int64_t ldb, float* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -80,19 +74,12 @@ int64_t sygvd( double* B, int64_t ldb, double* W ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sygvx.cc b/src/sygvx.cc index 00afd769..96eee2ac 100644 --- a/src/sygvx.cc +++ b/src/sygvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -20,32 +21,22 @@ int64_t sygvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, float* A, int64_t lda, float* B, int64_t ldb, float vl, float vu, int64_t il, int64_t iu, float abstol, - int64_t* m, + int64_t* nfound, float* W, float* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -62,7 +53,7 @@ int64_t sygvx( LAPACK_ssygvx( &itype_, &jobz_, &range_, &uplo_, &n_, A, &lda_, - B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, qry_work, &ineg_one, @@ -81,7 +72,7 @@ int64_t sygvx( LAPACK_ssygvx( &itype_, &jobz_, &range_, &uplo_, &n_, A, &lda_, - B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], &lwork_, @@ -91,10 +82,10 @@ int64_t sygvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; @@ -105,32 +96,22 @@ int64_t sygvx( int64_t itype, lapack::Job jobz, lapack::Range range, lapack::Uplo uplo, int64_t n, double* A, int64_t lda, double* B, int64_t ldb, double vl, double vu, int64_t il, int64_t iu, double abstol, - int64_t* m, + int64_t* nfound, double* W, double* Z, int64_t ldz, int64_t* ifail ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(itype) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(il) > std::numeric_limits::max() ); - lapack_error_if( std::abs(iu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int itype_ = (lapack_int) itype; + lapack_int itype_ = to_lapack_int( itype ); char jobz_ = to_char( jobz ); char range_ = to_char( range ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int il_ = (lapack_int) il; - lapack_int iu_ = (lapack_int) iu; - lapack_int m_ = (lapack_int) *m; - lapack_int ldz_ = (lapack_int) ldz; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int il_ = to_lapack_int( il ); + lapack_int iu_ = to_lapack_int( iu ); + lapack_int nfound_ = 0; // out + lapack_int ldz_ = to_lapack_int( ldz ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ifail_( (n) ); @@ -147,7 +128,7 @@ int64_t sygvx( LAPACK_dsygvx( &itype_, &jobz_, &range_, &uplo_, &n_, A, &lda_, - B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, qry_work, &ineg_one, @@ -166,7 +147,7 @@ int64_t sygvx( LAPACK_dsygvx( &itype_, &jobz_, &range_, &uplo_, &n_, A, &lda_, - B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &m_, + B, &ldb_, &vl, &vu, &il_, &iu_, &abstol, &nfound_, W, Z, &ldz_, &work[0], &lwork_, @@ -176,10 +157,10 @@ int64_t sygvx( if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; #ifndef LAPACK_ILP64 if (jobz != Job::NoVec) { - std::copy( &ifail_[ 0 ], &ifail_[ m_ ], ifail ); + std::copy( &ifail_[ 0 ], &ifail_[ nfound_ ], ifail ); } #endif return info_; diff --git a/src/symv.cc b/src/symv.cc index 9ab759a1..fd5dc0d3 100644 --- a/src/symv.cc +++ b/src/symv.cc @@ -8,6 +8,7 @@ #include "lapack/fortran.h" #include "lapack.hh" +#include "lapack_internal.hh" #include @@ -38,18 +39,10 @@ void symv( lapack_error_if( incx == 0 ); lapack_error_if( incy == 0 ); - // check for overflow in native BLAS integer type, if smaller than int64_t - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( n > std::numeric_limits::max() ); - lapack_error_if( lda > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incy) > std::numeric_limits::max() ); - } - - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int incx_ = (lapack_int) incx; - lapack_int incy_ = (lapack_int) incy; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int incx_ = to_lapack_int( incx ); + lapack_int incy_ = to_lapack_int( incy ); if (layout == Layout::RowMajor) { // swap lower <=> upper @@ -88,18 +81,10 @@ void symv( lapack_error_if( incx == 0 ); lapack_error_if( incy == 0 ); - // check for overflow in native BLAS integer type, if smaller than int64_t - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( n > std::numeric_limits::max() ); - lapack_error_if( lda > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(incy) > std::numeric_limits::max() ); - } - - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int incx_ = (lapack_int) incx; - lapack_int incy_ = (lapack_int) incy; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int incx_ = to_lapack_int( incx ); + lapack_int incy_ = to_lapack_int( incy ); if (layout == Layout::RowMajor) { // swap lower <=> upper diff --git a/src/syr.cc b/src/syr.cc index b4cdab62..d43f41bd 100644 --- a/src/syr.cc +++ b/src/syr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" // while [cz]syr are in LAPACK, [sd]syr are in BLAS, @@ -33,16 +34,9 @@ void syr( lapack_error_if( lda < n ); lapack_error_if( incx == 0 ); - // check for overflow in native BLAS integer type, if smaller than int64_t - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( n > std::numeric_limits::max() ); - lapack_error_if( lda > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int incx_ = to_lapack_int( incx ); if (layout == Layout::RowMajor) { // swap lower <=> upper @@ -76,16 +70,9 @@ void syr( lapack_error_if( lda < n ); lapack_error_if( incx == 0 ); - // check for overflow in native BLAS integer type, if smaller than int64_t - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( n > std::numeric_limits::max() ); - lapack_error_if( lda > std::numeric_limits::max() ); - lapack_error_if( std::abs(incx) > std::numeric_limits::max() ); - } - - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int incx_ = (lapack_int) incx; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int incx_ = to_lapack_int( incx ); if (layout == Layout::RowMajor) { // swap lower <=> upper diff --git a/src/syrfs.cc b/src/syrfs.cc index 7297d182..ccd51f4e 100644 --- a/src/syrfs.cc +++ b/src/syrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,20 +28,11 @@ int64_t syrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -48,8 +40,8 @@ int64_t syrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -86,20 +78,11 @@ int64_t syrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -107,8 +90,8 @@ int64_t syrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -145,20 +128,11 @@ int64_t syrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -166,8 +140,8 @@ int64_t syrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -288,20 +262,11 @@ int64_t syrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -309,8 +274,8 @@ int64_t syrfs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/syrfsx.cc b/src/syrfsx.cc index 65243e2e..726addcd 100644 --- a/src/syrfsx.cc +++ b/src/syrfsx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -33,23 +34,12 @@ int64_t syrfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -57,10 +47,10 @@ int64_t syrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -104,23 +94,12 @@ int64_t syrfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -128,10 +107,10 @@ int64_t syrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -175,23 +154,12 @@ int64_t syrfsx( float* err_bnds_comp, int64_t nparams, float* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -199,10 +167,10 @@ int64_t syrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace @@ -518,23 +486,12 @@ int64_t syrfsx( double* err_bnds_comp, int64_t nparams, double* params ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n_err_bnds) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nparams) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char equed_ = to_char( equed ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -542,10 +499,10 @@ int64_t syrfsx( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; - lapack_int n_err_bnds_ = (lapack_int) n_err_bnds; - lapack_int nparams_ = (lapack_int) nparams; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); + lapack_int n_err_bnds_ = to_lapack_int( n_err_bnds ); + lapack_int nparams_ = to_lapack_int( nparams ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sysv.cc b/src/sysv.cc index d7ef00ee..4d5d5a10 100644 --- a/src/sysv.cc +++ b/src/sysv.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t sysv( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -41,7 +35,7 @@ int64_t sysv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -86,17 +80,10 @@ int64_t sysv( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -104,7 +91,7 @@ int64_t sysv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -149,17 +136,10 @@ int64_t sysv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -167,7 +147,7 @@ int64_t sysv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -291,17 +271,10 @@ int64_t sysv( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -309,7 +282,7 @@ int64_t sysv( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sysv_aa.cc b/src/sysv_aa.cc index 109518ac..e5de8893 100644 --- a/src/sysv_aa.cc +++ b/src/sysv_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t sysv_aa( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -43,7 +37,7 @@ int64_t sysv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -114,17 +108,10 @@ int64_t sysv_aa( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -132,7 +119,7 @@ int64_t sysv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -204,17 +191,10 @@ int64_t sysv_aa( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -222,7 +202,7 @@ int64_t sysv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -362,17 +342,10 @@ int64_t sysv_aa( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -380,7 +353,7 @@ int64_t sysv_aa( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sysv_rk.cc b/src/sysv_rk.cc index 5d54da62..adf0585e 100644 --- a/src/sysv_rk.cc +++ b/src/sysv_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,17 +27,10 @@ int64_t sysv_rk( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -44,7 +38,7 @@ int64_t sysv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -92,17 +86,10 @@ int64_t sysv_rk( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -110,7 +97,7 @@ int64_t sysv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -158,17 +145,10 @@ int64_t sysv_rk( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -176,7 +156,7 @@ int64_t sysv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -337,17 +317,10 @@ int64_t sysv_rk( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -355,7 +328,7 @@ int64_t sysv_rk( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sysv_rook.cc b/src/sysv_rook.cc index 6451586b..5c8641cb 100644 --- a/src/sysv_rook.cc +++ b/src/sysv_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t sysv_rook( int64_t* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -43,7 +37,7 @@ int64_t sysv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -88,17 +82,10 @@ int64_t sysv_rook( int64_t* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -106,7 +93,7 @@ int64_t sysv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -151,17 +138,10 @@ int64_t sysv_rook( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -169,7 +149,7 @@ int64_t sysv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size @@ -216,17 +196,10 @@ int64_t sysv_rook( int64_t* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -234,7 +207,7 @@ int64_t sysv_rook( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sysvx.cc b/src/sysvx.cc index d03f8d6f..afe3fba5 100644 --- a/src/sysvx.cc +++ b/src/sysvx.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -28,21 +29,12 @@ int64_t sysvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -50,8 +42,8 @@ int64_t sysvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size @@ -113,21 +105,12 @@ int64_t sysvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -135,8 +118,8 @@ int64_t sysvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size @@ -198,21 +181,12 @@ int64_t sysvx( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -220,8 +194,8 @@ int64_t sysvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size @@ -418,21 +392,12 @@ int64_t sysvx( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldaf) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char fact_ = to_char( fact ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldaf_ = (lapack_int) ldaf; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldaf_ = to_lapack_int( ldaf ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -440,8 +405,8 @@ int64_t sysvx( #else lapack_int* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // query for workspace size diff --git a/src/syswapr.cc b/src/syswapr.cc index 6794e4bc..6b2a9c36 100644 --- a/src/syswapr.cc +++ b/src/syswapr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30300 // >= 3.3 @@ -22,18 +23,11 @@ void syswapr( lapack::Uplo uplo, int64_t n, float* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_ssyswapr( &uplo_, &n_, @@ -47,18 +41,11 @@ void syswapr( lapack::Uplo uplo, int64_t n, double* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_dsyswapr( &uplo_, &n_, @@ -72,18 +59,11 @@ void syswapr( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_csyswapr( &uplo_, &n_, @@ -127,18 +107,11 @@ void syswapr( lapack::Uplo uplo, int64_t n, std::complex* A, int64_t lda, int64_t i1, int64_t i2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i1) > std::numeric_limits::max() ); - lapack_error_if( std::abs(i2) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int i1_ = (lapack_int) i1; - lapack_int i2_ = (lapack_int) i2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int i1_ = to_lapack_int( i1 ); + lapack_int i2_ = to_lapack_int( i2 ); LAPACK_zsyswapr( &uplo_, &n_, diff --git a/src/sytrd.cc b/src/sytrd.cc index 47957fd9..b700eedd 100644 --- a/src/sytrd.cc +++ b/src/sytrd.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t sytrd( float* E, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -77,14 +73,9 @@ int64_t sytrd( double* E, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sytrd_2stage.cc b/src/sytrd_2stage.cc index b6fa2d42..2bc03655 100644 --- a/src/sytrd_2stage.cc +++ b/src/sytrd_2stage.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,17 +28,11 @@ int64_t sytrd_2stage( float* tau, float* hous2, int64_t lhous2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lhous2) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int lhous2_ = (lapack_int) lhous2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int lhous2_ = to_lapack_int( lhous2 ); lapack_int info_ = 0; // query for workspace size @@ -86,17 +81,11 @@ int64_t sytrd_2stage( double* tau, double* hous2, int64_t lhous2 ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lhous2) > std::numeric_limits::max() ); - } char jobz_ = to_char( jobz ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int lhous2_ = (lapack_int) lhous2; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int lhous2_ = to_lapack_int( lhous2 ); lapack_int info_ = 0; // query for workspace size diff --git a/src/sytrf.cc b/src/sytrf.cc index e5b61b93..57a3ea60 100644 --- a/src/sytrf.cc +++ b/src/sytrf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t sytrf( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -78,14 +74,9 @@ int64_t sytrf( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -134,14 +125,9 @@ int64_t sytrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -299,14 +285,9 @@ int64_t sytrf( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/sytrf_aa.cc b/src/sytrf_aa.cc index 8a094d85..755d6276 100644 --- a/src/sytrf_aa.cc +++ b/src/sytrf_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t sytrf_aa( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -80,14 +76,9 @@ int64_t sytrf_aa( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -136,14 +127,9 @@ int64_t sytrf_aa( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -243,14 +229,9 @@ int64_t sytrf_aa( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/sytrf_rk.cc b/src/sytrf_rk.cc index ce17adc4..cbcd2342 100644 --- a/src/sytrf_rk.cc +++ b/src/sytrf_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,14 +26,9 @@ int64_t sytrf_rk( float* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -84,14 +80,9 @@ int64_t sytrf_rk( double* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -143,14 +134,9 @@ int64_t sytrf_rk( std::complex* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -359,14 +345,9 @@ int64_t sytrf_rk( std::complex* E, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/sytrf_rook.cc b/src/sytrf_rook.cc index c77319bd..45a4ea84 100644 --- a/src/sytrf_rook.cc +++ b/src/sytrf_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t sytrf_rook( float* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -80,14 +76,9 @@ int64_t sytrf_rook( double* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -136,14 +127,9 @@ int64_t sytrf_rook( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); @@ -194,14 +180,9 @@ int64_t sytrf_rook( std::complex* A, int64_t lda, int64_t* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy lapack::vector< lapack_int > ipiv_( (n) ); diff --git a/src/sytri.cc b/src/sytri.cc index 77854a7b..4c7f522d 100644 --- a/src/sytri.cc +++ b/src/sytri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t sytri( float* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -61,14 +57,9 @@ int64_t sytri( double* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -100,14 +91,9 @@ int64_t sytri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -184,14 +170,9 @@ int64_t sytri( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/sytri2.cc b/src/sytri2.cc index 3ffd95e5..60e32f25 100644 --- a/src/sytri2.cc +++ b/src/sytri2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,14 +25,9 @@ int64_t sytri2( float* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -77,14 +73,9 @@ int64_t sytri2( double* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -129,14 +120,9 @@ int64_t sytri2( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -228,14 +214,9 @@ int64_t sytri2( std::complex* A, int64_t lda, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/sytri_rk.cc b/src/sytri_rk.cc index d3fbeeb4..593cfe7f 100644 --- a/src/sytri_rk.cc +++ b/src/sytri_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,14 +26,9 @@ int64_t sytri_rk( float const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -81,14 +77,9 @@ int64_t sytri_rk( double const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -137,14 +128,9 @@ int64_t sytri_rk( std::complex const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -279,14 +265,9 @@ int64_t sytri_rk( std::complex const* E, int64_t const* ipiv ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); diff --git a/src/sytrs.cc b/src/sytrs.cc index c176cd63..4a009c3c 100644 --- a/src/sytrs.cc +++ b/src/sytrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,17 +24,10 @@ int64_t sytrs( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -41,7 +35,7 @@ int64_t sytrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ssytrs( @@ -64,17 +58,10 @@ int64_t sytrs( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -82,7 +69,7 @@ int64_t sytrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dsytrs( @@ -105,17 +92,10 @@ int64_t sytrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -123,7 +103,7 @@ int64_t sytrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_csytrs( @@ -193,17 +173,10 @@ int64_t sytrs( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -211,7 +184,7 @@ int64_t sytrs( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zsytrs( diff --git a/src/sytrs2.cc b/src/sytrs2.cc index ead061b5..6bca2cae 100644 --- a/src/sytrs2.cc +++ b/src/sytrs2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t sytrs2( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,7 +37,7 @@ int64_t sytrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -70,17 +64,10 @@ int64_t sytrs2( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -88,7 +75,7 @@ int64_t sytrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -115,17 +102,10 @@ int64_t sytrs2( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -133,7 +113,7 @@ int64_t sytrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -212,17 +192,10 @@ int64_t sytrs2( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -230,7 +203,7 @@ int64_t sytrs2( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sytrs_aa.cc b/src/sytrs_aa.cc index 595fed22..aa13b404 100644 --- a/src/sytrs_aa.cc +++ b/src/sytrs_aa.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t sytrs_aa( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,8 +37,8 @@ int64_t sytrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace @@ -71,17 +65,10 @@ int64_t sytrs_aa( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -89,8 +76,8 @@ int64_t sytrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace @@ -117,17 +104,10 @@ int64_t sytrs_aa( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -135,8 +115,8 @@ int64_t sytrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace @@ -206,17 +186,10 @@ int64_t sytrs_aa( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -224,8 +197,8 @@ int64_t sytrs_aa( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; - lapack_int lwork_ = (lapack_int) max( 1, 3*n-2 ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int lwork_ = max( 1, 3*n-2 ); lapack_int info_ = 0; // allocate workspace diff --git a/src/sytrs_rk.cc b/src/sytrs_rk.cc index 31cfb4c6..77b615a4 100644 --- a/src/sytrs_rk.cc +++ b/src/sytrs_rk.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,17 +27,10 @@ int64_t sytrs_rk( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -44,7 +38,7 @@ int64_t sytrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ssytrs_3( @@ -69,17 +63,10 @@ int64_t sytrs_rk( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -87,7 +74,7 @@ int64_t sytrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dsytrs_3( @@ -112,17 +99,10 @@ int64_t sytrs_rk( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -130,7 +110,7 @@ int64_t sytrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_csytrs_3( @@ -239,17 +219,10 @@ int64_t sytrs_rk( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -257,7 +230,7 @@ int64_t sytrs_rk( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zsytrs_3( diff --git a/src/sytrs_rook.cc b/src/sytrs_rook.cc index 191e87ef..de7791c6 100644 --- a/src/sytrs_rook.cc +++ b/src/sytrs_rook.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,17 +26,10 @@ int64_t sytrs_rook( int64_t const* ipiv, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -43,7 +37,7 @@ int64_t sytrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ssytrs_rook( @@ -66,17 +60,10 @@ int64_t sytrs_rook( int64_t const* ipiv, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -84,7 +71,7 @@ int64_t sytrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dsytrs_rook( @@ -107,17 +94,10 @@ int64_t sytrs_rook( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -125,7 +105,7 @@ int64_t sytrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_csytrs_rook( @@ -150,17 +130,10 @@ int64_t sytrs_rook( int64_t const* ipiv, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); #ifndef LAPACK_ILP64 // 32-bit copy std::vector< lapack_int > ipiv_( &ipiv[0], &ipiv[(n)] ); @@ -168,7 +141,7 @@ int64_t sytrs_rook( #else lapack_int const* ipiv_ptr = ipiv; #endif - lapack_int ldb_ = (lapack_int) ldb; + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_zsytrs_rook( diff --git a/src/tbcon.cc b/src/tbcon.cc index f53e4f1a..77bcc56d 100644 --- a/src/tbcon.cc +++ b/src/tbcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,18 +22,12 @@ int64_t tbcon( float const* AB, int64_t ldab, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -57,18 +52,12 @@ int64_t tbcon( double const* AB, int64_t ldab, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -93,18 +82,12 @@ int64_t tbcon( std::complex const* AB, int64_t ldab, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace @@ -129,18 +112,12 @@ int64_t tbcon( std::complex const* AB, int64_t ldab, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int ldab_ = (lapack_int) ldab; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int ldab_ = to_lapack_int( ldab ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tbrfs.cc b/src/tbrfs.cc index af678bff..579e27ba 100644 --- a/src/tbrfs.cc +++ b/src/tbrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,24 +25,15 @@ int64_t tbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -73,24 +65,15 @@ int64_t tbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -122,24 +105,15 @@ int64_t tbrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -171,24 +145,15 @@ int64_t tbrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tbtrs.cc b/src/tbtrs.cc index 8d91053d..03850058 100644 --- a/src/tbtrs.cc +++ b/src/tbtrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,22 +21,14 @@ int64_t tbtrs( float const* AB, int64_t ldab, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_stbtrs( @@ -55,22 +48,14 @@ int64_t tbtrs( double const* AB, int64_t ldab, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dtbtrs( @@ -90,22 +75,14 @@ int64_t tbtrs( std::complex const* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ctbtrs( @@ -125,22 +102,14 @@ int64_t tbtrs( std::complex const* AB, int64_t ldab, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(kd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldab) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int kd_ = (lapack_int) kd; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldab_ = (lapack_int) ldab; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int kd_ = to_lapack_int( kd ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldab_ = to_lapack_int( ldab ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ztbtrs( diff --git a/src/tfsm.cc b/src/tfsm.cc index e1493587..14deefeb 100644 --- a/src/tfsm.cc +++ b/src/tfsm.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,20 +21,14 @@ void tfsm( float const* A, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_stfsm( &transr_, &side_, &uplo_, &trans_, &diag_, &m_, &n_, &alpha, @@ -48,20 +43,14 @@ void tfsm( double const* A, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_dtfsm( &transr_, &side_, &uplo_, &trans_, &diag_, &m_, &n_, &alpha, @@ -76,20 +65,14 @@ void tfsm( std::complex const* A, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_ctfsm( &transr_, &side_, &uplo_, &trans_, &diag_, &m_, &n_, @@ -105,20 +88,14 @@ void tfsm( std::complex const* A, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldb_ = to_lapack_int( ldb ); LAPACK_ztfsm( &transr_, &side_, &uplo_, &trans_, &diag_, &m_, &n_, diff --git a/src/tftri.cc b/src/tftri.cc index 27253fcd..7cbe2723 100644 --- a/src/tftri.cc +++ b/src/tftri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -19,14 +20,10 @@ int64_t tftri( lapack::Op transr, lapack::Uplo uplo, lapack::Diag diag, int64_t n, float* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_stftri( @@ -44,14 +41,10 @@ int64_t tftri( lapack::Op transr, lapack::Uplo uplo, lapack::Diag diag, int64_t n, double* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dtftri( @@ -69,14 +62,10 @@ int64_t tftri( lapack::Op transr, lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ctftri( @@ -94,14 +83,10 @@ int64_t tftri( lapack::Op transr, lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* A ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ztftri( diff --git a/src/tfttp.cc b/src/tfttp.cc index 4b4991e2..efaae185 100644 --- a/src/tfttp.cc +++ b/src/tfttp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,13 +21,9 @@ int64_t tfttp( float const* ARF, float* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_stfttp( @@ -46,13 +43,9 @@ int64_t tfttp( double const* ARF, double* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dtfttp( @@ -72,13 +65,9 @@ int64_t tfttp( std::complex const* ARF, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ctfttp( @@ -98,13 +87,9 @@ int64_t tfttp( std::complex const* ARF, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ztfttp( diff --git a/src/tfttr.cc b/src/tfttr.cc index f101f63b..ef0a74da 100644 --- a/src/tfttr.cc +++ b/src/tfttr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,15 +21,10 @@ int64_t tfttr( float const* ARF, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_stfttr( @@ -48,15 +44,10 @@ int64_t tfttr( double const* ARF, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dtfttr( @@ -76,15 +67,10 @@ int64_t tfttr( std::complex const* ARF, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ctfttr( @@ -104,15 +90,10 @@ int64_t tfttr( std::complex const* ARF, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ztfttr( diff --git a/src/tgexc.cc b/src/tgexc.cc index 0ba2006b..5c99ffe5 100644 --- a/src/tgexc.cc +++ b/src/tgexc.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -117,23 +118,15 @@ int64_t tgexc( scalar_t* Z, int64_t ldz, int64_t* ifst, int64_t* ilst ) { - // convert arguments - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int wantq_ = (lapack_int) wantq; - lapack_int wantz_ = (lapack_int) wantz; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int ifst_ = (lapack_int) *ifst; - lapack_int ilst_ = (lapack_int) *ilst; + lapack_int wantq_ = to_lapack_int( wantq ); + lapack_int wantz_ = to_lapack_int( wantz ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int ifst_ = to_lapack_int( *ifst ); // in,out + lapack_int ilst_ = to_lapack_int( *ilst ); // in,out lapack_int info_ = 0; if constexpr (! is_complex::value) { diff --git a/src/tgsen.cc b/src/tgsen.cc index 5c019a4f..c9607b59 100644 --- a/src/tgsen.cc +++ b/src/tgsen.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -30,7 +31,7 @@ inline void tgsen( float* beta, float* Q, lapack_int ldq, float* Z, lapack_int ldz, - lapack_int* sdim, float* pl, float* pr, float* dif, + lapack_int* nfound, float* pl, float* pr, float* dif, float* work, lapack_int lwork, lapack_int* iwork, lapack_int liwork, lapack_int* info ) @@ -38,7 +39,7 @@ inline void tgsen( LAPACK_stgsen( &ijob, &wantq, &wantz, select, &n, A, &lda, B, &ldb, alphar, alphai, beta, - Q, &ldq, Z, &ldz, sdim, pl, pr, dif, + Q, &ldq, Z, &ldz, nfound, pl, pr, dif, work, &lwork, iwork, &liwork, info ); } @@ -54,7 +55,7 @@ inline void tgsen( double* beta, double* Q, lapack_int ldq, double* Z, lapack_int ldz, - lapack_int* sdim, double* pl, double* pr, double* dif, + lapack_int* nfound, double* pl, double* pr, double* dif, double* work, lapack_int lwork, lapack_int* iwork, lapack_int liwork, lapack_int* info ) @@ -62,7 +63,7 @@ inline void tgsen( LAPACK_dtgsen( &ijob, &wantq, &wantz, select, &n, A, &lda, B, &ldb, alphar, alphai, beta, - Q, &ldq, Z, &ldz, sdim, pl, pr, dif, + Q, &ldq, Z, &ldz, nfound, pl, pr, dif, work, &lwork, iwork, &liwork, info ); } @@ -78,7 +79,7 @@ inline void tgsen( std::complex* beta, std::complex* Q, lapack_int ldq, std::complex* Z, lapack_int ldz, - lapack_int* sdim, float* pl, float* pr, float* dif, + lapack_int* nfound, float* pl, float* pr, float* dif, std::complex* work, lapack_int lwork, lapack_int* iwork, lapack_int liwork, lapack_int* info ) @@ -91,7 +92,7 @@ inline void tgsen( (lapack_complex_float*) alpha, (lapack_complex_float*) beta, (lapack_complex_float*) Q, &ldq, - (lapack_complex_float*) Z, &ldz, sdim, pl, pr, dif, + (lapack_complex_float*) Z, &ldz, nfound, pl, pr, dif, (lapack_complex_float*) work, &lwork, iwork, &liwork, info ); } @@ -108,7 +109,7 @@ inline void tgsen( std::complex* beta, std::complex* Q, lapack_int ldq, std::complex* Z, lapack_int ldz, - lapack_int* sdim, + lapack_int* nfound, double* pl, double* pr, double* dif, std::complex* work, lapack_int lwork, @@ -122,7 +123,7 @@ inline void tgsen( (lapack_complex_double*) alpha, (lapack_complex_double*) beta, (lapack_complex_double*) Q, &ldq, - (lapack_complex_double*) Z, &ldz, sdim, pl, pr, dif, + (lapack_complex_double*) Z, &ldz, nfound, pl, pr, dif, (lapack_complex_double*) work, &lwork, iwork, &liwork, info ); } @@ -147,28 +148,19 @@ int64_t tgsen( scalar_t* beta, scalar_t* Q, int64_t ldq, scalar_t* Z, int64_t ldz, - int64_t* sdim, + int64_t* nfound, real_type* pl, real_type* pr, real_type* dif ) { - // convert arguments - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(ijob) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldz) > std::numeric_limits::max() ); - } - lapack_int ijob_ = (lapack_int) ijob; - lapack_int wantq_ = (lapack_int) wantq; - lapack_int wantz_ = (lapack_int) wantz; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ldz_ = (lapack_int) ldz; - lapack_int sdim_ = (lapack_int) *sdim; + lapack_int ijob_ = to_lapack_int( ijob ); + lapack_int wantq_ = to_lapack_int( wantq ); + lapack_int wantz_ = to_lapack_int( wantz ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ldz_ = to_lapack_int( ldz ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // For real, create vectors for split-complex representation. @@ -189,14 +181,14 @@ int64_t tgsen( internal::tgsen( ijob_, wantq_, wantz_, select, n_, A, lda_, B, ldb_, &alphar[ 0 ], &alphai[ 0 ], beta, - Q, ldq_, Z, ldz_, &sdim_, pl, pr, dif, + Q, ldq_, Z, ldz_, &nfound_, pl, pr, dif, qry_work, ineg_one, qry_iwork, ineg_one, &info_ ); } else { internal::tgsen( ijob_, wantq_, wantz_, select, n_, A, lda_, B, ldb_, alpha, beta, - Q, ldq_, Z, ldz_, &sdim_, pl, pr, dif, + Q, ldq_, Z, ldz_, &nfound_, pl, pr, dif, qry_work, ineg_one, qry_iwork, ineg_one, &info_ ); } if (info_ < 0) { @@ -216,7 +208,7 @@ int64_t tgsen( internal::tgsen( ijob_, wantq_, wantz_, select, n_, A, lda_, B, ldb_, &alphar[0], &alphai[0], beta, - Q, ldq_, Z, ldz_, &sdim_, pl, pr, dif, + Q, ldq_, Z, ldz_, &nfound_, pl, pr, dif, &work[0], lwork_, &iwork[0], liwork_, &info_ ); // Merge split-complex representation. for (int64_t i = 0; i < n; ++i) { @@ -227,13 +219,13 @@ int64_t tgsen( internal::tgsen( ijob_, wantq_, wantz_, select, n_, A, lda_, B, ldb_, alpha, beta, - Q, ldq_, Z, ldz_, &sdim_, pl, pr, dif, + Q, ldq_, Z, ldz_, &nfound_, pl, pr, dif, &work[0], lwork_, &iwork[0], liwork_, &info_ ); } if (info_ < 0) { throw Error(); } - *sdim = sdim_; + *nfound = nfound_; return info_; } @@ -335,7 +327,7 @@ int64_t tgsen( /// The n-by-n matrix Q, stored in an ldq-by-n array. /// On entry, if wantq = true, Q is an n-by-n matrix. /// On exit, Q has been postmultiplied by the left unitary -/// transformation matrix which reorder (A, B); The leading sdim +/// transformation matrix which reorder (A, B); The leading nfound /// columns of Q form orthonormal bases for the specified pair of /// left eigenspaces (deflating subspaces). /// If wantq = false, Q is not referenced. @@ -348,7 +340,7 @@ int64_t tgsen( /// The n-by-n matrix Z, stored in an ldz-by-n array. /// On entry, if wantz = true, Z is an n-by-n matrix. /// On exit, Z has been postmultiplied by the left unitary -/// transformation matrix which reorder (A, B); The leading sdim +/// transformation matrix which reorder (A, B); The leading nfound /// columns of Z form orthonormal bases for the specified pair of /// left eigenspaces (deflating subspaces). /// If wantz = false, Z is not referenced. @@ -357,9 +349,9 @@ int64_t tgsen( /// The leading dimension of the array Z. ldz >= 1. /// If wantz = true, ldz >= n. /// -/// @param[out] sdim +/// @param[out] nfound /// The dimension of the specified pair of left and right -/// eigenspaces (deflating subspaces) 0 <= sdim <= n. +/// eigenspaces (deflating subspaces) 0 <= nfound <= n. /// (Called `m` in LAPACK.) /// /// @param[out] pl @@ -368,7 +360,7 @@ int64_t tgsen( /// reciprocal of the norm of "projections" onto left and right /// eigenspace with respect to the selected cluster. /// 0 < pl, pr <= 1. -/// * If sdim = 0 or sdim = n, then pl = pr = 1. +/// * If nfound = 0 or nfound = n, then pl = pr = 1. /// * If ijob = 0, 2 or 3, then pl, pr are not referenced. /// /// @param[out] dif @@ -379,7 +371,7 @@ int64_t tgsen( /// * If ijob = 3 or 5, dif(1:2) are 1-norm-based /// estimates of Difu and Difl, computed using reversed /// communication with `lapack::lacn2`. -/// * If sdim = 0 or n, dif(1:2) = F-norm([A, B]). +/// * If nfound = 0 or n, dif(1:2) = F-norm([A, B]). /// * If ijob = 0 or 1, dif is not referenced. /// /// @return @@ -504,14 +496,14 @@ int64_t tgsen( float* beta, float* Q, int64_t ldq, float* Z, int64_t ldz, - int64_t* sdim, + int64_t* nfound, float* pl, float* pr, float* dif ) { return impl::tgsen( ijob, wantq, wantz, select, n, A, lda, B, ldb, alpha, beta, - Q, ldq, Z, ldz, sdim, pl, pr, dif ); + Q, ldq, Z, ldz, nfound, pl, pr, dif ); } //------------------------------------------------------------------------------ @@ -526,14 +518,14 @@ int64_t tgsen( double* beta, double* Q, int64_t ldq, double* Z, int64_t ldz, - int64_t* sdim, + int64_t* nfound, double* pl, double* pr, double* dif ) { return impl::tgsen( ijob, wantq, wantz, select, n, A, lda, B, ldb, alpha, beta, - Q, ldq, Z, ldz, sdim, pl, pr, dif ); + Q, ldq, Z, ldz, nfound, pl, pr, dif ); } //------------------------------------------------------------------------------ @@ -548,14 +540,14 @@ int64_t tgsen( std::complex* beta, std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz, - int64_t* sdim, + int64_t* nfound, float* pl, float* pr, float* dif ) { return impl::tgsen( ijob, wantq, wantz, select, n, A, lda, B, ldb, alpha, beta, - Q, ldq, Z, ldz, sdim, pl, pr, dif ); + Q, ldq, Z, ldz, nfound, pl, pr, dif ); } //------------------------------------------------------------------------------ @@ -570,14 +562,14 @@ int64_t tgsen( std::complex* beta, std::complex* Q, int64_t ldq, std::complex* Z, int64_t ldz, - int64_t* sdim, + int64_t* nfound, double* pl, double* pr, double* dif ) { return impl::tgsen( ijob, wantq, wantz, select, n, A, lda, B, ldb, alpha, beta, - Q, ldq, Z, ldz, sdim, pl, pr, dif ); + Q, ldq, Z, ldz, nfound, pl, pr, dif ); } } // namespace lapack diff --git a/src/tgsja.cc b/src/tgsja.cc index 087dd802..ce9bae12 100644 --- a/src/tgsja.cc +++ b/src/tgsja.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,33 +28,20 @@ int64_t tgsja( float* Q, int64_t ldq, int64_t* ncycle ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_compu( jobu ); char jobv_ = to_char_comp( jobv ); char jobq_ = to_char_compq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ncycle_ = (lapack_int) *ncycle; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ncycle_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -89,33 +77,20 @@ int64_t tgsja( double* Q, int64_t ldq, int64_t* ncycle ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_compu( jobu ); char jobv_ = to_char_comp( jobv ); char jobq_ = to_char_compq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ncycle_ = (lapack_int) *ncycle; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ncycle_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -151,33 +126,20 @@ int64_t tgsja( std::complex* Q, int64_t ldq, int64_t* ncycle ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_compu( jobu ); char jobv_ = to_char_comp( jobv ); char jobq_ = to_char_compq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ncycle_ = (lapack_int) *ncycle; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ncycle_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -213,33 +175,20 @@ int64_t tgsja( std::complex* Q, int64_t ldq, int64_t* ncycle ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(p) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldu) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char jobu_ = to_char_compu( jobu ); char jobv_ = to_char_comp( jobv ); char jobq_ = to_char_compq( jobq ); - lapack_int m_ = (lapack_int) m; - lapack_int p_ = (lapack_int) p; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldu_ = (lapack_int) ldu; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ncycle_ = (lapack_int) *ncycle; + lapack_int m_ = to_lapack_int( m ); + lapack_int p_ = to_lapack_int( p ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldu_ = to_lapack_int( ldu ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ncycle_ = 0; // out lapack_int info_ = 0; // allocate workspace diff --git a/src/tgsyl.cc b/src/tgsyl.cc index 990f7d95..d5ae3169 100644 --- a/src/tgsyl.cc +++ b/src/tgsyl.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -27,28 +28,16 @@ int64_t tgsyl( float* dif, float* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(ijob) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lde) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldf) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int ijob_ = (lapack_int) ijob; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldc_ = (lapack_int) ldc; - lapack_int ldd_ = (lapack_int) ldd; - lapack_int lde_ = (lapack_int) lde; - lapack_int ldf_ = (lapack_int) ldf; + lapack_int ijob_ = to_lapack_int( ijob ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldc_ = to_lapack_int( ldc ); + lapack_int ldd_ = to_lapack_int( ldd ); + lapack_int lde_ = to_lapack_int( lde ); + lapack_int ldf_ = to_lapack_int( ldf ); lapack_int info_ = 0; // query for workspace size @@ -104,28 +93,16 @@ int64_t tgsyl( double* dif, double* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(ijob) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lde) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldf) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int ijob_ = (lapack_int) ijob; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldc_ = (lapack_int) ldc; - lapack_int ldd_ = (lapack_int) ldd; - lapack_int lde_ = (lapack_int) lde; - lapack_int ldf_ = (lapack_int) ldf; + lapack_int ijob_ = to_lapack_int( ijob ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldc_ = to_lapack_int( ldc ); + lapack_int ldd_ = to_lapack_int( ldd ); + lapack_int lde_ = to_lapack_int( lde ); + lapack_int ldf_ = to_lapack_int( ldf ); lapack_int info_ = 0; // query for workspace size @@ -181,28 +158,16 @@ int64_t tgsyl( float* dif, float* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(ijob) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lde) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldf) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int ijob_ = (lapack_int) ijob; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldc_ = (lapack_int) ldc; - lapack_int ldd_ = (lapack_int) ldd; - lapack_int lde_ = (lapack_int) lde; - lapack_int ldf_ = (lapack_int) ldf; + lapack_int ijob_ = to_lapack_int( ijob ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldc_ = to_lapack_int( ldc ); + lapack_int ldd_ = to_lapack_int( ldd ); + lapack_int lde_ = to_lapack_int( lde ); + lapack_int ldf_ = to_lapack_int( ldf ); lapack_int info_ = 0; // query for workspace size @@ -258,28 +223,16 @@ int64_t tgsyl( double* dif, double* scale ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(ijob) > std::numeric_limits::max() ); - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldd) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lde) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldf) > std::numeric_limits::max() ); - } char trans_ = to_char( trans ); - lapack_int ijob_ = (lapack_int) ijob; - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldc_ = (lapack_int) ldc; - lapack_int ldd_ = (lapack_int) ldd; - lapack_int lde_ = (lapack_int) lde; - lapack_int ldf_ = (lapack_int) ldf; + lapack_int ijob_ = to_lapack_int( ijob ); + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldc_ = to_lapack_int( ldc ); + lapack_int ldd_ = to_lapack_int( ldd ); + lapack_int lde_ = to_lapack_int( lde ); + lapack_int ldf_ = to_lapack_int( ldf ); lapack_int info_ = 0; // query for workspace size diff --git a/src/tpcon.cc b/src/tpcon.cc index 9c894ca6..0f5ecc8b 100644 --- a/src/tpcon.cc +++ b/src/tpcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,14 +22,10 @@ int64_t tpcon( float const* AP, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -53,14 +50,10 @@ int64_t tpcon( double const* AP, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -85,14 +78,10 @@ int64_t tpcon( std::complex const* AP, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace @@ -117,14 +106,10 @@ int64_t tpcon( std::complex const* AP, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tplqt.cc b/src/tplqt.cc index 9b585044..3e81715e 100644 --- a/src/tplqt.cc +++ b/src/tplqt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,13 @@ int64_t tplqt( float* B, int64_t ldb, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -67,23 +58,13 @@ int64_t tplqt( double* B, int64_t ldb, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -109,23 +90,13 @@ int64_t tplqt( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -247,23 +218,13 @@ int64_t tplqt( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tplqt2.cc b/src/tplqt2.cc index f80e5fdd..d0362be0 100644 --- a/src/tplqt2.cc +++ b/src/tplqt2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30700 // >= 3.7.0 @@ -24,21 +25,12 @@ int64_t tplqt2( float* B, int64_t ldb, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_stplqt2( @@ -60,21 +52,12 @@ int64_t tplqt2( double* B, int64_t ldb, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_dtplqt2( @@ -96,21 +79,12 @@ int64_t tplqt2( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_ctplqt2( @@ -221,21 +195,12 @@ int64_t tplqt2( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_ztplqt2( diff --git a/src/tpmlqt.cc b/src/tpmlqt.cc index 61d9e5a7..6313bbfb 100644 --- a/src/tpmlqt.cc +++ b/src/tpmlqt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -30,29 +31,17 @@ int64_t tpmlqt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -86,29 +75,17 @@ int64_t tpmlqt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -138,29 +115,17 @@ int64_t tpmlqt( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -305,29 +270,17 @@ int64_t tpmlqt( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int mb_ = (lapack_int) mb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int mb_ = to_lapack_int( mb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tpmqrt.cc b/src/tpmqrt.cc index e4935b8c..72383951 100644 --- a/src/tpmqrt.cc +++ b/src/tpmqrt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -30,29 +31,17 @@ int64_t tpmqrt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -86,29 +75,17 @@ int64_t tpmqrt( if (trans == Op::ConjTrans) trans = Op::Trans; - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -138,29 +115,17 @@ int64_t tpmqrt( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace @@ -308,29 +273,17 @@ int64_t tpmqrt( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tpqrt.cc b/src/tpqrt.cc index fba3e23c..a6d8613b 100644 --- a/src/tpqrt.cc +++ b/src/tpqrt.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -25,23 +26,13 @@ int64_t tpqrt( float* B, int64_t ldb, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -67,23 +58,13 @@ int64_t tpqrt( double* B, int64_t ldb, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -109,23 +90,13 @@ int64_t tpqrt( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace @@ -151,23 +122,13 @@ int64_t tpqrt( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tpqrt2.cc b/src/tpqrt2.cc index 0e3d90a8..ba32e754 100644 --- a/src/tpqrt2.cc +++ b/src/tpqrt2.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30400 // >= 3.4 @@ -24,21 +25,12 @@ int64_t tpqrt2( float* B, int64_t ldb, float* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_stpqrt2( @@ -60,21 +52,12 @@ int64_t tpqrt2( double* B, int64_t ldb, double* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_dtpqrt2( @@ -96,21 +79,12 @@ int64_t tpqrt2( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_ctpqrt2( @@ -132,21 +106,12 @@ int64_t tpqrt2( std::complex* B, int64_t ldb, std::complex* T, int64_t ldt ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; LAPACK_ztpqrt2( diff --git a/src/tprfb.cc b/src/tprfb.cc index 340acd14..3de57792 100644 --- a/src/tprfb.cc +++ b/src/tprfb.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -28,29 +29,18 @@ void tprfb( float* A, int64_t lda, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int ldwork_ = (side == Side::Left ? k : m); // allocate workspace @@ -78,29 +68,18 @@ void tprfb( double* A, int64_t lda, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int ldwork_ = (side == Side::Left ? k : m); // allocate workspace @@ -128,29 +107,18 @@ void tprfb( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int ldwork_ = (side == Side::Left ? k : m); // allocate workspace @@ -344,29 +312,18 @@ void tprfb( std::complex* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldv) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); char direction_ = to_char( direction ); char storev_ = to_char( storev ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int ldv_ = (lapack_int) ldv; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int ldv_ = to_lapack_int( ldv ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int ldwork_ = (side == Side::Left ? k : m); // allocate workspace diff --git a/src/tprfs.cc b/src/tprfs.cc index c94f44bb..dcce519f 100644 --- a/src/tprfs.cc +++ b/src/tprfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,20 +25,13 @@ int64_t tprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -69,20 +63,13 @@ int64_t tprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -114,20 +101,13 @@ int64_t tprfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -159,20 +139,13 @@ int64_t tprfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/tptri.cc b/src/tptri.cc index a823d70e..7fcb3750 100644 --- a/src/tptri.cc +++ b/src/tptri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -19,13 +20,9 @@ int64_t tptri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, float* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_stptri( @@ -43,13 +40,9 @@ int64_t tptri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, double* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dtptri( @@ -67,13 +60,9 @@ int64_t tptri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ctptri( @@ -91,13 +80,9 @@ int64_t tptri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ztptri( diff --git a/src/tptrs.cc b/src/tptrs.cc index bc2974a6..0767e15d 100644 --- a/src/tptrs.cc +++ b/src/tptrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,18 +21,12 @@ int64_t tptrs( float const* AP, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_stptrs( @@ -51,18 +46,12 @@ int64_t tptrs( double const* AP, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dtptrs( @@ -82,18 +71,12 @@ int64_t tptrs( std::complex const* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ctptrs( @@ -113,18 +96,12 @@ int64_t tptrs( std::complex const* AP, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ztptrs( diff --git a/src/tpttf.cc b/src/tpttf.cc index bd953670..16afd8af 100644 --- a/src/tpttf.cc +++ b/src/tpttf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,13 +21,9 @@ int64_t tpttf( float const* AP, float* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_stpttf( @@ -46,13 +43,9 @@ int64_t tpttf( double const* AP, double* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_dtpttf( @@ -72,13 +65,9 @@ int64_t tpttf( std::complex const* AP, std::complex* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ctpttf( @@ -98,13 +87,9 @@ int64_t tpttf( std::complex const* AP, std::complex* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; + lapack_int n_ = to_lapack_int( n ); lapack_int info_ = 0; LAPACK_ztpttf( diff --git a/src/tpttr.cc b/src/tpttr.cc index 1b5354bf..e75a8369 100644 --- a/src/tpttr.cc +++ b/src/tpttr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t tpttr( float const* AP, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_stpttr( @@ -47,14 +43,9 @@ int64_t tpttr( double const* AP, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dtpttr( @@ -74,14 +65,9 @@ int64_t tpttr( std::complex const* AP, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ctpttr( @@ -101,14 +87,9 @@ int64_t tpttr( std::complex const* AP, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ztpttr( diff --git a/src/trcon.cc b/src/trcon.cc index a4562707..f45841dc 100644 --- a/src/trcon.cc +++ b/src/trcon.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,16 +22,11 @@ int64_t trcon( float const* A, int64_t lda, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -55,16 +51,11 @@ int64_t trcon( double const* A, int64_t lda, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -89,16 +80,11 @@ int64_t trcon( std::complex const* A, int64_t lda, float* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace @@ -123,16 +109,11 @@ int64_t trcon( std::complex const* A, int64_t lda, double* rcond ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char norm_ = to_char( norm ); char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // allocate workspace diff --git a/src/trevc.cc b/src/trevc.cc index 03543939..1c733d62 100644 --- a/src/trevc.cc +++ b/src/trevc.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,16 +24,8 @@ int64_t trevc( float const* T, int64_t ldt, float* VL, int64_t ldvl, float* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -40,12 +33,12 @@ int64_t trevc( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -56,7 +49,7 @@ int64_t trevc( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, &work[0], &info_ ); if (info_ < 0) { @@ -64,7 +57,7 @@ int64_t trevc( } // [sd]trevc update select std::copy( select_.begin(), select_.end(), select ); - *m = m_; + *nfound = nfound_; return info_; } @@ -76,16 +69,8 @@ int64_t trevc( double const* T, int64_t ldt, double* VL, int64_t ldvl, double* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -93,12 +78,12 @@ int64_t trevc( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -109,7 +94,7 @@ int64_t trevc( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, &work[0], &info_ ); if (info_ < 0) { @@ -117,7 +102,7 @@ int64_t trevc( } // [sd]trevc update select std::copy( select_.begin(), select_.end(), select ); - *m = m_; + *nfound = nfound_; return info_; } @@ -129,16 +114,8 @@ int64_t trevc( std::complex* T, int64_t ldt, std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -146,12 +123,12 @@ int64_t trevc( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -163,14 +140,14 @@ int64_t trevc( select_ptr, &n_, (lapack_complex_float*) T, &ldt_, (lapack_complex_float*) VL, &ldvl_, - (lapack_complex_float*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_float*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_float*) &work[0], &rwork[0], &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } @@ -276,12 +253,12 @@ int64_t trevc( /// ldvr >= 1, and if side = Right or Both, ldvr >= n. /// /// @param[in] mm -/// The number of columns in the arrays VL and/or VR. mm >= m. +/// The number of columns in the arrays VL and/or VR. mm >= nfound. /// -/// @param[out] m +/// @param[out] nfound /// The number of columns in the arrays VL and/or VR actually /// used to store the eigenvectors. -/// If howmany = All or Backtransform, m is set to n. +/// If howmany = All or Backtransform, nfound is set to n. /// Each selected eigenvector occupies one column. /// /// @return = 0: successful exit @@ -304,16 +281,8 @@ int64_t trevc( std::complex* T, int64_t ldt, std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -321,12 +290,12 @@ int64_t trevc( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // allocate workspace @@ -338,14 +307,14 @@ int64_t trevc( select_ptr, &n_, (lapack_complex_double*) T, &ldt_, (lapack_complex_double*) VL, &ldvl_, - (lapack_complex_double*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_double*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_double*) &work[0], &rwork[0], &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } diff --git a/src/trevc3.cc b/src/trevc3.cc index 4955f6fd..ed7a2440 100644 --- a/src/trevc3.cc +++ b/src/trevc3.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -26,16 +27,8 @@ int64_t trevc3( float const* T, int64_t ldt, float* VL, int64_t ldvl, float* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -43,12 +36,12 @@ int64_t trevc3( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -59,7 +52,7 @@ int64_t trevc3( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, qry_work, &ineg_one, &info_ ); if (info_ < 0) { @@ -75,7 +68,7 @@ int64_t trevc3( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, &work[0], &lwork_, &info_ ); if (info_ < 0) { @@ -83,7 +76,7 @@ int64_t trevc3( } // [sd]trevc update select std::copy( select_.begin(), select_.end(), select ); - *m = m_; + *nfound = nfound_; return info_; } @@ -95,16 +88,8 @@ int64_t trevc3( double const* T, int64_t ldt, double* VL, int64_t ldvl, double* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -112,12 +97,12 @@ int64_t trevc3( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -128,7 +113,7 @@ int64_t trevc3( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, qry_work, &ineg_one, &info_ ); if (info_ < 0) { @@ -144,7 +129,7 @@ int64_t trevc3( select_ptr, &n_, T, &ldt_, VL, &ldvl_, - VR, &ldvr_, &mm_, &m_, + VR, &ldvr_, &mm_, &nfound_, &work[0], &lwork_, &info_ ); if (info_ < 0) { @@ -152,7 +137,7 @@ int64_t trevc3( } // [sd]trevc update select std::copy( select_.begin(), select_.end(), select ); - *m = m_; + *nfound = nfound_; return info_; } @@ -164,16 +149,8 @@ int64_t trevc3( std::complex* T, int64_t ldt, std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -181,12 +158,12 @@ int64_t trevc3( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -198,7 +175,7 @@ int64_t trevc3( select_ptr, &n_, (lapack_complex_float*) T, &ldt_, (lapack_complex_float*) VL, &ldvl_, - (lapack_complex_float*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_float*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_float*) qry_work, &ineg_one, qry_rwork, &ineg_one, &info_ ); @@ -217,14 +194,14 @@ int64_t trevc3( select_ptr, &n_, (lapack_complex_float*) T, &ldt_, (lapack_complex_float*) VL, &ldvl_, - (lapack_complex_float*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_float*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_float*) &work[0], &lwork_, &rwork[0], &lrwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } @@ -332,12 +309,12 @@ int64_t trevc3( /// ldvr >= 1, and if side = Right or Both, ldvr >= n. /// /// @param[in] mm -/// The number of columns in the arrays VL and/or VR. mm >= m. +/// The number of columns in the arrays VL and/or VR. mm >= nfound. /// -/// @param[out] m +/// @param[out] nfound /// The number of columns in the arrays VL and/or VR actually /// used to store the eigenvectors. -/// If howmany = All or Backtransform, m is set to n. +/// If howmany = All or Backtransform, nfound is set to n. /// Each selected eigenvector occupies one column. /// /// @return = 0: successful exit @@ -360,16 +337,8 @@ int64_t trevc3( std::complex* T, int64_t ldt, std::complex* VL, int64_t ldvl, std::complex* VR, int64_t ldvr, int64_t mm, - int64_t* m ) + int64_t* nfound ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvl) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldvr) > std::numeric_limits::max() ); - lapack_error_if( std::abs(mm) > std::numeric_limits::max() ); - } char sides_ = to_char( sides ); char howmany_ = to_char( howmany ); @@ -377,12 +346,12 @@ int64_t trevc3( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldvl_ = (lapack_int) ldvl; - lapack_int ldvr_ = (lapack_int) ldvr; - lapack_int mm_ = (lapack_int) mm; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldvl_ = to_lapack_int( ldvl ); + lapack_int ldvr_ = to_lapack_int( ldvr ); + lapack_int mm_ = to_lapack_int( mm ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -394,7 +363,7 @@ int64_t trevc3( select_ptr, &n_, (lapack_complex_double*) T, &ldt_, (lapack_complex_double*) VL, &ldvl_, - (lapack_complex_double*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_double*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_double*) qry_work, &ineg_one, qry_rwork, &ineg_one, &info_ ); @@ -413,14 +382,14 @@ int64_t trevc3( select_ptr, &n_, (lapack_complex_double*) T, &ldt_, (lapack_complex_double*) VL, &ldvl_, - (lapack_complex_double*) VR, &ldvr_, &mm_, &m_, + (lapack_complex_double*) VR, &ldvr_, &mm_, &nfound_, (lapack_complex_double*) &work[0], &lwork_, &rwork[0], &lrwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } diff --git a/src/trexc.cc b/src/trexc.cc index 8fe991c1..6839e0b1 100644 --- a/src/trexc.cc +++ b/src/trexc.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,18 +24,12 @@ int64_t trexc( int64_t* ifst, int64_t* ilst ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ifst_ = (lapack_int) *ifst; - lapack_int ilst_ = (lapack_int) *ilst; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ifst_ = to_lapack_int( *ifst ); // in,out + lapack_int ilst_ = to_lapack_int( *ilst ); // in,out lapack_int info_ = 0; // allocate workspace @@ -62,18 +57,12 @@ int64_t trexc( int64_t* ifst, int64_t* ilst ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ifst_ = (lapack_int) *ifst; - lapack_int ilst_ = (lapack_int) *ilst; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int ifst_ = to_lapack_int( *ifst ); // in,out + lapack_int ilst_ = to_lapack_int( *ilst ); // in,out lapack_int info_ = 0; // allocate workspace @@ -99,20 +88,13 @@ int64_t trexc( std::complex* T, int64_t ldt, std::complex* Q, int64_t ldq, int64_t ifst, int64_t ilst ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ifst) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilst) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ifst_ = (lapack_int) ifst; - lapack_int ilst_ = (lapack_int) ilst; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + // In complex, ifst, ilst are only `in`, not `in,out`. + lapack_int ifst_ = to_lapack_int( ifst ); + lapack_int ilst_ = to_lapack_int( ilst ); lapack_int info_ = 0; LAPACK_ctrexc( @@ -132,20 +114,13 @@ int64_t trexc( std::complex* T, int64_t ldt, std::complex* Q, int64_t ldq, int64_t ifst, int64_t ilst ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ifst) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilst) > std::numeric_limits::max() ); - } char compq_ = to_char_comp( compq ); - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int ifst_ = (lapack_int) ifst; - lapack_int ilst_ = (lapack_int) ilst; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + // In complex, ifst, ilst are only `in`, not `in,out`. + lapack_int ifst_ = to_lapack_int( ifst ); + lapack_int ilst_ = to_lapack_int( ilst ); lapack_int info_ = 0; LAPACK_ztrexc( diff --git a/src/trrfs.cc b/src/trrfs.cc index 6bb3a7d5..9df6cd01 100644 --- a/src/trrfs.cc +++ b/src/trrfs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -24,22 +25,14 @@ int64_t trrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -71,22 +64,14 @@ int64_t trrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -118,22 +103,14 @@ int64_t trrfs( float* ferr, float* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace @@ -165,22 +142,14 @@ int64_t trrfs( double* ferr, double* berr ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldx) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; - lapack_int ldx_ = (lapack_int) ldx; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); + lapack_int ldx_ = to_lapack_int( ldx ); lapack_int info_ = 0; // allocate workspace diff --git a/src/trsen.cc b/src/trsen.cc index ce7cf3ce..26af018d 100644 --- a/src/trsen.cc +++ b/src/trsen.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,16 +23,10 @@ int64_t trsen( float* T, int64_t ldt, float* Q, int64_t ldq, std::complex* W, - int64_t* m, + int64_t* nfound, float* s, float* sep ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char sense_ = to_char( sense ); char compq_ = to_char_comp( compq ); @@ -39,10 +34,10 @@ int64_t trsen( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // split-complex representation @@ -60,7 +55,7 @@ int64_t trsen( Q, &ldq_, &WR[0], &WI[0], - &m_, s, sep, + &nfound_, s, sep, qry_work, &ineg_one, qry_iwork, &ineg_one, &info_ ); @@ -81,14 +76,14 @@ int64_t trsen( Q, &ldq_, &WR[0], &WI[0], - &m_, s, sep, + &nfound_, s, sep, &work[0], &lwork_, &iwork[0], &liwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; // merge split-complex representation for (int64_t i = 0; i < n; ++i) { W[i] = std::complex( WR[i], WI[i] ); @@ -103,16 +98,10 @@ int64_t trsen( double* T, int64_t ldt, double* Q, int64_t ldq, std::complex* W, - int64_t* m, + int64_t* nfound, double* s, double* sep ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char sense_ = to_char( sense ); char compq_ = to_char_comp( compq ); @@ -120,10 +109,10 @@ int64_t trsen( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // split-complex representation @@ -141,7 +130,7 @@ int64_t trsen( Q, &ldq_, &WR[0], &WI[0], - &m_, s, sep, + &nfound_, s, sep, qry_work, &ineg_one, qry_iwork, &ineg_one, &info_ ); @@ -162,14 +151,14 @@ int64_t trsen( Q, &ldq_, &WR[0], &WI[0], - &m_, s, sep, + &nfound_, s, sep, &work[0], &lwork_, &iwork[0], &liwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; // merge split-complex representation for (int64_t i = 0; i < n; ++i) { W[i] = std::complex( WR[i], WI[i] ); @@ -184,16 +173,10 @@ int64_t trsen( std::complex* T, int64_t ldt, std::complex* Q, int64_t ldq, std::complex* W, - int64_t* m, + int64_t* nfound, float* s, float* sep ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char sense_ = to_char( sense ); char compq_ = to_char_comp( compq ); @@ -201,10 +184,10 @@ int64_t trsen( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -215,7 +198,7 @@ int64_t trsen( select_ptr, &n_, (lapack_complex_float*) T, &ldt_, (lapack_complex_float*) Q, &ldq_, - (lapack_complex_float*) W, &m_, s, sep, + (lapack_complex_float*) W, &nfound_, s, sep, (lapack_complex_float*) qry_work, &ineg_one, &info_ ); if (info_ < 0) { @@ -231,13 +214,13 @@ int64_t trsen( select_ptr, &n_, (lapack_complex_float*) T, &ldt_, (lapack_complex_float*) Q, &ldq_, - (lapack_complex_float*) W, &m_, s, sep, + (lapack_complex_float*) W, &nfound_, s, sep, (lapack_complex_float*) &work[0], &lwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } @@ -248,16 +231,10 @@ int64_t trsen( std::complex* T, int64_t ldt, std::complex* Q, int64_t ldq, std::complex* W, - int64_t* m, + int64_t* nfound, double* s, double* sep ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char sense_ = to_char( sense ); char compq_ = to_char_comp( compq ); @@ -265,10 +242,10 @@ int64_t trsen( std::vector< lapack_logical > select_( &select[0], &select[(n)] ); lapack_logical const* select_ptr = &select_[0]; - lapack_int n_ = (lapack_int) n; - lapack_int ldt_ = (lapack_int) ldt; - lapack_int ldq_ = (lapack_int) ldq; - lapack_int m_ = (lapack_int) *m; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldt_ = to_lapack_int( ldt ); + lapack_int ldq_ = to_lapack_int( ldq ); + lapack_int nfound_ = 0; // out lapack_int info_ = 0; // query for workspace size @@ -279,7 +256,7 @@ int64_t trsen( select_ptr, &n_, (lapack_complex_double*) T, &ldt_, (lapack_complex_double*) Q, &ldq_, - (lapack_complex_double*) W, &m_, s, sep, + (lapack_complex_double*) W, &nfound_, s, sep, (lapack_complex_double*) qry_work, &ineg_one, &info_ ); if (info_ < 0) { @@ -295,13 +272,13 @@ int64_t trsen( select_ptr, &n_, (lapack_complex_double*) T, &ldt_, (lapack_complex_double*) Q, &ldq_, - (lapack_complex_double*) W, &m_, s, sep, + (lapack_complex_double*) W, &nfound_, s, sep, (lapack_complex_double*) &work[0], &lwork_, &info_ ); if (info_ < 0) { throw Error(); } - *m = m_; + *nfound = nfound_; return info_; } diff --git a/src/trtri.cc b/src/trtri.cc index 2039efad..bf346efb 100644 --- a/src/trtri.cc +++ b/src/trtri.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -19,15 +20,10 @@ int64_t trtri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, float* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_strtri( @@ -45,15 +41,10 @@ int64_t trtri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, double* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dtrtri( @@ -71,15 +62,10 @@ int64_t trtri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ctrtri( @@ -97,15 +83,10 @@ int64_t trtri( lapack::Uplo uplo, lapack::Diag diag, int64_t n, std::complex* A, int64_t lda ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ztrtri( diff --git a/src/trtrs.cc b/src/trtrs.cc index 99e7430c..9aedaed4 100644 --- a/src/trtrs.cc +++ b/src/trtrs.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,20 +21,13 @@ int64_t trtrs( float const* A, int64_t lda, float* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_strtrs( @@ -53,20 +47,13 @@ int64_t trtrs( double const* A, int64_t lda, double* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_dtrtrs( @@ -86,20 +73,13 @@ int64_t trtrs( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ctrtrs( @@ -119,20 +99,13 @@ int64_t trtrs( std::complex const* A, int64_t lda, std::complex* B, int64_t ldb ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nrhs) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldb) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); char diag_ = to_char( diag ); - lapack_int n_ = (lapack_int) n; - lapack_int nrhs_ = (lapack_int) nrhs; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldb_ = (lapack_int) ldb; + lapack_int n_ = to_lapack_int( n ); + lapack_int nrhs_ = to_lapack_int( nrhs ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldb_ = to_lapack_int( ldb ); lapack_int info_ = 0; LAPACK_ztrtrs( diff --git a/src/trttf.cc b/src/trttf.cc index 8dc373b5..65999292 100644 --- a/src/trttf.cc +++ b/src/trttf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,15 +21,10 @@ int64_t trttf( float const* A, int64_t lda, float* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_strttf( @@ -48,15 +44,10 @@ int64_t trttf( double const* A, int64_t lda, double* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dtrttf( @@ -76,15 +67,10 @@ int64_t trttf( std::complex const* A, int64_t lda, std::complex* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ctrttf( @@ -104,15 +90,10 @@ int64_t trttf( std::complex const* A, int64_t lda, std::complex* ARF ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char transr_ = to_char( transr ); char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ztrttf( diff --git a/src/trttp.cc b/src/trttp.cc index 9306f1ad..b7fb457e 100644 --- a/src/trttp.cc +++ b/src/trttp.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include @@ -20,14 +21,9 @@ int64_t trttp( float const* A, int64_t lda, float* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_strttp( @@ -47,14 +43,9 @@ int64_t trttp( double const* A, int64_t lda, double* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_dtrttp( @@ -74,14 +65,9 @@ int64_t trttp( std::complex const* A, int64_t lda, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ctrttp( @@ -101,14 +87,9 @@ int64_t trttp( std::complex const* A, int64_t lda, std::complex* AP ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; LAPACK_ztrttp( diff --git a/src/tzrzf.cc b/src/tzrzf.cc index 074b96b8..fc44af33 100644 --- a/src/tzrzf.cc +++ b/src/tzrzf.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -21,15 +22,9 @@ int64_t tzrzf( float* A, int64_t lda, float* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -65,15 +60,9 @@ int64_t tzrzf( double* A, int64_t lda, double* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -109,15 +98,9 @@ int64_t tzrzf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -153,15 +136,9 @@ int64_t tzrzf( std::complex* A, int64_t lda, std::complex* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ungbr.cc b/src/ungbr.cc index 05525feb..8c1e82ee 100644 --- a/src/ungbr.cc +++ b/src/ungbr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,18 +23,11 @@ int64_t ungbr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -136,18 +130,11 @@ int64_t ungbr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unghr.cc b/src/unghr.cc index 7b2ec16e..bd2b36b2 100644 --- a/src/unghr.cc +++ b/src/unghr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t unghr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -108,17 +102,10 @@ int64_t unghr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unglq.cc b/src/unglq.cc index b9f70afb..015dc810 100644 --- a/src/unglq.cc +++ b/src/unglq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t unglq( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -107,17 +101,10 @@ int64_t unglq( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ungql.cc b/src/ungql.cc index 1e2baf9b..dd7022d1 100644 --- a/src/ungql.cc +++ b/src/ungql.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t ungql( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -108,17 +102,10 @@ int64_t ungql( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ungqr.cc b/src/ungqr.cc index a6f05655..3e1d4615 100644 --- a/src/ungqr.cc +++ b/src/ungqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t ungqr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -108,17 +102,10 @@ int64_t ungqr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ungrq.cc b/src/ungrq.cc index 929cffaa..db1e2cb0 100644 --- a/src/ungrq.cc +++ b/src/ungrq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,17 +23,10 @@ int64_t ungrq( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -107,17 +101,10 @@ int64_t ungrq( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/ungtr.cc b/src/ungtr.cc index 1f891b36..20c4305c 100644 --- a/src/ungtr.cc +++ b/src/ungtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t ungtr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size @@ -104,14 +100,9 @@ int64_t ungtr( std::complex* A, int64_t lda, std::complex const* tau ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unhr_col.cc b/src/unhr_col.cc index caca900c..643d0f57 100644 --- a/src/unhr_col.cc +++ b/src/unhr_col.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #if LAPACK_VERSION >= 30900 // >= 3.9.0 @@ -24,20 +25,12 @@ int64_t unhr_col( std::complex* T, int64_t ldt, std::complex* D ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } lapack_error_if(m < n); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // Work around bug in LAPACK <= 3.12. See https://github.com/Reference-LAPACK/lapack/pull/1018 @@ -147,19 +140,11 @@ int64_t unhr_col( std::complex* T, int64_t ldt, std::complex* D ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(nb) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldt) > std::numeric_limits::max() ); - } - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int nb_ = (lapack_int) nb; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldt_ = (lapack_int) ldt; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int nb_ = to_lapack_int( nb ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldt_ = to_lapack_int( ldt ); lapack_int info_ = 0; // Work around bug in LAPACK <= 3.12. See https://github.com/Reference-LAPACK/lapack/pull/1018 diff --git a/src/unmbr.cc b/src/unmbr.cc index eccd60fa..cc9780e7 100644 --- a/src/unmbr.cc +++ b/src/unmbr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,22 +24,14 @@ int64_t unmbr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -172,22 +165,14 @@ int64_t unmbr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char vect_ = to_char( vect ); char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmhr.cc b/src/unmhr.cc index 325d2606..d16c6222 100644 --- a/src/unmhr.cc +++ b/src/unmhr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,23 +24,14 @@ int64_t unmhr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -152,23 +144,14 @@ int64_t unmhr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ilo) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ihi) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ilo_ = (lapack_int) ilo; - lapack_int ihi_ = (lapack_int) ihi; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ilo_ = to_lapack_int( ilo ); + lapack_int ihi_ = to_lapack_int( ihi ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmlq.cc b/src/unmlq.cc index c3bdecae..27ed5964 100644 --- a/src/unmlq.cc +++ b/src/unmlq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,13 @@ int64_t unmlq( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -145,21 +138,13 @@ int64_t unmlq( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmql.cc b/src/unmql.cc index ddee6f19..c652f489 100644 --- a/src/unmql.cc +++ b/src/unmql.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,13 @@ int64_t unmql( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -146,21 +139,13 @@ int64_t unmql( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmqr.cc b/src/unmqr.cc index 87eddf16..2f9b65b9 100644 --- a/src/unmqr.cc +++ b/src/unmqr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,13 @@ int64_t unmqr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -147,21 +140,13 @@ int64_t unmqr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmrq.cc b/src/unmrq.cc index c938f19e..708376ed 100644 --- a/src/unmrq.cc +++ b/src/unmrq.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,21 +24,13 @@ int64_t unmrq( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -145,21 +138,13 @@ int64_t unmrq( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmrz.cc b/src/unmrz.cc index 5088d3e7..90fe70ba 100644 --- a/src/unmrz.cc +++ b/src/unmrz.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,23 +23,14 @@ int64_t unmrz( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -79,23 +71,14 @@ int64_t unmrz( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(k) > std::numeric_limits::max() ); - lapack_error_if( std::abs(l) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int k_ = (lapack_int) k; - lapack_int l_ = (lapack_int) l; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int k_ = to_lapack_int( k ); + lapack_int l_ = to_lapack_int( l ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/unmtr.cc b/src/unmtr.cc index 8d53d6fd..cae551e0 100644 --- a/src/unmtr.cc +++ b/src/unmtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,20 +24,13 @@ int64_t unmtr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size @@ -144,20 +138,13 @@ int64_t unmtr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(lda) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int lda_ = (lapack_int) lda; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int lda_ = to_lapack_int( lda ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // query for workspace size diff --git a/src/upgtr.cc b/src/upgtr.cc index 5eb4fe73..0af937d6 100644 --- a/src/upgtr.cc +++ b/src/upgtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -22,14 +23,9 @@ int64_t upgtr( std::complex const* tau, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace @@ -55,14 +51,9 @@ int64_t upgtr( std::complex const* tau, std::complex* Q, int64_t ldq ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldq) > std::numeric_limits::max() ); - } char uplo_ = to_char( uplo ); - lapack_int n_ = (lapack_int) n; - lapack_int ldq_ = (lapack_int) ldq; + lapack_int n_ = to_lapack_int( n ); + lapack_int ldq_ = to_lapack_int( ldq ); lapack_int info_ = 0; // allocate workspace diff --git a/src/upmtr.cc b/src/upmtr.cc index 79c5669b..f3a278af 100644 --- a/src/upmtr.cc +++ b/src/upmtr.cc @@ -4,6 +4,7 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" #include "NoConstructAllocator.hh" @@ -23,18 +24,12 @@ int64_t upmtr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // from docs @@ -127,18 +122,12 @@ int64_t upmtr( std::complex const* tau, std::complex* C, int64_t ldc ) { - // check for overflow - if (sizeof(int64_t) > sizeof(lapack_int)) { - lapack_error_if( std::abs(m) > std::numeric_limits::max() ); - lapack_error_if( std::abs(n) > std::numeric_limits::max() ); - lapack_error_if( std::abs(ldc) > std::numeric_limits::max() ); - } char side_ = to_char( side ); char uplo_ = to_char( uplo ); char trans_ = to_char( trans ); - lapack_int m_ = (lapack_int) m; - lapack_int n_ = (lapack_int) n; - lapack_int ldc_ = (lapack_int) ldc; + lapack_int m_ = to_lapack_int( m ); + lapack_int n_ = to_lapack_int( n ); + lapack_int ldc_ = to_lapack_int( ldc ); lapack_int info_ = 0; // from docs diff --git a/tools/wrapper_gen.py b/tools/wrapper_gen.py index 8aa87a8c..feac207a 100755 --- a/tools/wrapper_gen.py +++ b/tools/wrapper_gen.py @@ -157,7 +157,9 @@ // the terms of the BSD 3-Clause license. See the accompanying LICENSE file. #include "lapack.hh" +#include "lapack_internal.hh" #include "lapack/fortran.h" +#include "NoConstructAllocator.hh" ''' @@ -1061,7 +1063,8 @@ def parse_lapack( path ): # dimensions, enums arg.lname += '_' arg.pname = '&' + arg.lname - elif (arg.intent in ('out', 'in,out') and not arg.is_array and arg.dtype in ('int64_t', 'bool')): + elif (arg.intent in ('out', 'in,out') and not arg.is_array + and arg.dtype in ('int64_t', 'bool')): # output dimensions (nfound, rank, ...) arg.lname += '_' arg.pname = '&' + arg.lname @@ -1329,7 +1332,6 @@ def generate_docs( func ): def generate_wrapper( func, header=False ): # -------------------- # build list of arguments for prototype, query, and call - int_checks = '' local_vars = '' alloc_work = '' query = '' @@ -1368,9 +1370,9 @@ def generate_wrapper( func, header=False ): query_args.append( prefix + cast + arg.pname ) if (arg.dtype in ('int64_t', 'bool')): # integer input arrays: copy in input - local_vars += (tab + '#if 1\n' + local_vars += (tab + '#ifndef LAPACK_ILP64\n' + tab*2 + '// 32-bit copy\n' - + tab*2 + 'std::vector< lapack_int > ' + arg.lname + '( &' + arg.name + '[0], &' + arg.name + '[' + arg.dim + '] );\n' + + tab*2 + 'lapack::vector< lapack_int > ' + arg.lname + '( &' + arg.name + '[0], &' + arg.name + '[' + arg.dim + '] );\n' + tab*2 + 'lapack_int const* ' + arg.pname + ' = &' + arg.lname + '[0];\n' + tab + '#else\n' + tab*2 + 'lapack_int const* ' + arg.pname + ' = ' + arg.lname + ';\n' @@ -1382,18 +1384,17 @@ def generate_wrapper( func, header=False ): use_query = True elif (arg.is_lwork): # lwork, etc. local variables; not in proto_args - local_vars += tab + 'lapack_int ' + arg.lname + ' = (lapack_int) ' + arg.lbound + ';\n' + local_vars += tab + 'lapack_int ' + arg.lname + ' = to_lapack_int( ' + arg.lbound + ' );\n' else: proto_args.append( arg.dtype + ' ' + arg.name ) alias_args.append( arg.name ) query_args.append( prefix + cast + arg.pname ) if (arg.dtype in ('int64_t', 'bool')): # local 32-bit copy of 64-bit int - int_checks += tab*2 + 'lapack_error_if( std::abs( ' + arg.name + ' ) > std::numeric_limits::max() );\n' - local_vars += tab + 'lapack_int ' + arg.lname + ' = (lapack_int) ' + arg.name + ';\n' + local_vars += tab + 'lapack_int ' + arg.lname + ' = to_lapack_int( ' + arg.name + ' );\n' elif (arg.is_enum): enum2char = enum_map[ arg.name ][1] - local_vars += tab + 'char ' + arg.lname + ' = ' + enum2char + '( ' + arg.name + ' );\n' + local_vars += tab + 'char ' + arg.lname + ' = to_char( ' + arg.name + ' );\n' # end # end else: @@ -1402,10 +1403,11 @@ def generate_wrapper( func, header=False ): query_args.append( prefix + cast + 'qry_' + arg.name ) query += tab + arg.dtype + ' qry_' + arg.name + '[1];\n' + alloc_work += tab + 'lapack::vector< ' + arg.dtype + ' > ' + arg.lname if (arg.use_query): - alloc_work += tab + 'std::vector< ' + arg.dtype + ' > ' + arg.lname + '( ' + func.args[i+1].lname + ' );\n' + alloc_work += '( ' + func.args[i+1].lname + ' );\n' else: - alloc_work += tab + 'std::vector< ' + arg.dtype + ' > ' + arg.lname + '( ' + arg.dim.lower() + ' );\n' + alloc_work += '( ' + arg.dim.lower() + ' );\n' ##alloc_work += (tab + arg.dtype + '* ' + arg.name + '_' ## + ' = new ' + arg.dtype + '[ l' + arg.name + ' ];\n') @@ -1424,7 +1426,11 @@ def generate_wrapper( func, header=False ): else: proto_args.append( '\n ' + arg.dtype + '* ' + arg.name ) alias_args.append( arg.name ) - local_vars += tab + 'lapack_int ' + arg.lname + ' = (lapack_int) *' + arg.name + ';\n' + local_vars += tab + 'lapack_int ' + arg.lname + ' = ' + if (arg.intent == 'out'): + local_vars += '0; // out\n' + else: # in,out + local_vars += 'to_lapack_int( *' + arg.name + ' ); // in,out\n' cleanup += tab + '*' + arg.name + ' = ' + arg.lname + ';\n' else: # output array @@ -1434,24 +1440,24 @@ def generate_wrapper( func, header=False ): if (arg.is_array and (arg.dtype in ('int64_t', 'bool'))): if (arg.intent == 'in,out'): # copy in input, copy out in cleanup - local_vars += (tab + '#if 1\n' + local_vars += (tab + '#ifndef LAPACK_ILP64\n' + tab*2 + '// 32-bit copy\n' - + tab*2 + 'std::vector< lapack_int > ' + arg.lname + '( &' + arg.name + '[0], &' + arg.name + '[' + arg.dim + '] );\n' + + tab*2 + 'lapack::vector< lapack_int > ' + arg.lname + '( &' + arg.name + '[0], &' + arg.name + '[' + arg.dim + '] );\n' + tab*2 + 'lapack_int* ' + arg.pname + ' = &' + arg.lname + '[0];\n' + tab + '#else\n' + tab*2 + 'lapack_int* ' + arg.pname + ' = ' + arg.name + ';\n' + tab + '#endif\n') else: # allocate w/o copy, copy out in cleanup - local_vars += (tab + '#if 1\n' + local_vars += (tab + '#ifndef LAPACK_ILP64\n' + tab*2 + '// 32-bit copy\n' - + tab*2 + 'std::vector< lapack_int > ' + arg.lname + '( ' + arg.dim + ' );\n' + + tab*2 + 'lapack::vector< lapack_int > ' + arg.lname + '( ' + arg.dim + ' );\n' + tab*2 + 'lapack_int* ' + arg.pname + ' = &' + arg.lname + '[0];\n' + tab + '#else\n' + tab*2 + 'lapack_int* ' + arg.pname + ' = ' + arg.name + ';\n' + tab + '#endif\n') # end - cleanup += (tab + '#if 1\n' + cleanup += (tab + '#ifndef LAPACK_ILP64\n' + tab*2 + 'std::copy( ' + arg.lname + '.begin(), ' + arg.lname + '.end(), ' + arg.name + ' );\n' + tab + '#endif\n') # end @@ -1459,14 +1465,16 @@ def generate_wrapper( func, header=False ): i += 1 # end - # -------------------- + #-------------------- # build query if (use_query): query = ('\n' + tab + '// query for workspace size\n' + query + tab + 'lapack_int ineg_one = -1;\n' - + tab + 'LAPACK_' + func.xname + '(\n' + tab*2 + ', '.join( query_args ) + ' );\n' + + tab + 'LAPACK_' + func.xname + '(\n' + + tab*2 + ', '.join( query_args ) + '\n' + + tab + ');\n' + tab + 'if (info_ < 0) {\n' + tab*2 + 'throw Error();\n' + tab + '}\n') @@ -1481,26 +1489,27 @@ def generate_wrapper( func, header=False ): query = '' # end - if (int_checks): - int_checks = (tab + '// check for overflow\n' - + tab + 'if (sizeof( int64_t ) > sizeof( lapack_int )) {\n' - + int_checks - + tab + '}\n') - # end - + #-------------------- if (alloc_work): alloc_work = ('\n' + tab + '// allocate workspace\n' + alloc_work) # end + #-------------------- + # function call if (func.is_func): - call = '\n' + tab + 'return LAPACK_' + func.xname + '(\n' + tab*2 + ', '.join( call_args ) + ' );\n' + call = ('\n' + tab + 'return LAPACK_' + func.xname + '(\n' + + tab*2 + ', '.join( call_args ) + '\n' + + tab + ');\n') if (info_throw or cleanup or info_return): print( 'Warning: why is info or cleanup on a function?' ) else: - call = '\n' + tab + 'LAPACK_' + func.xname + '(\n' + tab*2 + ', '.join( call_args ) + ' );\n' + call = ('\n' + tab + 'LAPACK_' + func.xname + '(\n' + + tab*2 + ', '.join( call_args ) + '\n' + + tab + ');\n') + #-------------------- if (header): txt = (func.retval + ' ' + func.name + '(\n' + tab + ', '.join( proto_args ) @@ -1521,7 +1530,6 @@ def generate_wrapper( func, header=False ): txt = (func.retval + ' ' + func.name + '(\n' + tab + ', '.join( proto_args ) + ' )\n{\n' - + int_checks + local_vars + query + alloc_work