From: Daniel Arndt Date: Fri, 2 Feb 2018 12:34:07 +0000 (+0100) Subject: static_cast in full_matrix.templates.h X-Git-Tag: v9.0.0-rc1~479^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47a03a5ca8e7bef86e79647c17dff1c2afd6fb38;p=dealii.git static_cast in full_matrix.templates.h --- diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h index 8e54331910..bedb3aa375 100644 --- a/include/deal.II/lac/full_matrix.templates.h +++ b/include/deal.II/lac/full_matrix.templates.h @@ -528,7 +528,10 @@ void FullMatrix::mmult (FullMatrix &dst, std::is_same::value) && std::is_same::value) - if (this->n()*this->m()*src.n() > 300) + if (this->n()*this->m()*src.n() > 300 && + src.n() <= std::numeric_limits::max() && + this->m() <= std::numeric_limits::max() && + this->n() <= std::numeric_limits::max()) { // In case we have the BLAS function gemm detected by CMake, we // use that algorithm for matrix-matrix multiplication since it @@ -542,9 +545,9 @@ void FullMatrix::mmult (FullMatrix &dst, // transpose matrices, and read the result as if it were row-wise // again. In other words, we calculate (B^T A^T)^T, which is AB. - const types::blas_int m = src.n(); - const types::blas_int n = this->m(); - const types::blas_int k = this->n(); + const types::blas_int m = static_cast(src.n()); + const types::blas_int n = static_cast(this->m()); + const types::blas_int k = static_cast(this->n()); const char *notrans = "n"; const number alpha = 1.; @@ -598,7 +601,10 @@ void FullMatrix::Tmmult (FullMatrix &dst, std::is_same::value) && std::is_same::value) - if (this->n()*this->m()*src.n() > 300) + if (this->n()*this->m()*src.n() > 300 && + src.n() <= std::numeric_limits::max() && + this->n() <= std::numeric_limits::max() && + this->m() <= std::numeric_limits::max()) { // In case we have the BLAS function gemm detected by CMake, we // use that algorithm for matrix-matrix multiplication since it @@ -612,9 +618,9 @@ void FullMatrix::Tmmult (FullMatrix &dst, // transpose matrices, and read the result as if it were row-wise // again. In other words, we calculate (B^T A)^T, which is A^T B. - const types::blas_int m = src.n(); - const types::blas_int n = this->n(); - const types::blas_int k = this->m(); + const types::blas_int m = static_cast(src.n()); + const types::blas_int n = static_cast(this->n()); + const types::blas_int k = static_cast(this->m()); const char *trans = "t"; const char *notrans = "n"; @@ -688,7 +694,10 @@ void FullMatrix::mTmult (FullMatrix &dst, std::is_same::value) && std::is_same::value) - if (this->n()*this->m()*src.m() > 300) + if (this->n()*this->m()*src.m() > 300 && + src.m() <= std::numeric_limits::max() && + this->n() <= std::numeric_limits::max() && + this->m() <= std::numeric_limits::max()) { // In case we have the BLAS function gemm detected by CMake, we // use that algorithm for matrix-matrix multiplication since it @@ -702,9 +711,9 @@ void FullMatrix::mTmult (FullMatrix &dst, // transpose matrices, and read the result as if it were row-wise // again. In other words, we calculate (B A^T)^T, which is AB^T. - const types::blas_int m = src.m(); - const types::blas_int n = this->m(); - const types::blas_int k = this->n(); + const types::blas_int m = static_cast(src.m()); + const types::blas_int n = static_cast(this->m()); + const types::blas_int k = static_cast(this->n()); const char *notrans = "n"; const char *trans = "t"; @@ -776,7 +785,10 @@ void FullMatrix::TmTmult (FullMatrix &dst, std::is_same::value) && std::is_same::value) - if (this->n()*this->m()*src.m() > 300) + if (this->n()*this->m()*src.m() > 300 && + src.m() <= std::numeric_limits::max() && + this->n() <= std::numeric_limits::max() && + this->m() <= std::numeric_limits::max()) { // In case we have the BLAS function gemm detected by CMake, we // use that algorithm for matrix-matrix multiplication since it @@ -790,9 +802,9 @@ void FullMatrix::TmTmult (FullMatrix &dst, // transpose matrices, and read the result as if it were row-wise // again. In other words, we calculate (B A)^T, which is A^T B^T. - const types::blas_int m = src.m(); - const types::blas_int n = this->n(); - const types::blas_int k = this->m(); + const types::blas_int m = static_cast(src.m()); + const types::blas_int n = static_cast(this->n()); + const types::blas_int k = static_cast(this->m()); const char *trans = "t"; const number alpha = 1.; @@ -1182,8 +1194,8 @@ namespace internal static number value (const FullMatrix &A) { using s_type = typename LAPACKFullMatrix::size_type; - AssertIndexRange (A.m(), std::numeric_limits::max()+1); - AssertIndexRange (A.n(), std::numeric_limits::max()+1); + AssertIndexRange (A.m()-1, std::numeric_limits::max()); + AssertIndexRange (A.n()-1, std::numeric_limits::max()); LAPACKFullMatrix lp_A (static_cast(A.m()), static_cast(A.n())); lp_A = A; @@ -1759,7 +1771,8 @@ FullMatrix::gauss_jordan () if (std::is_same::value || std::is_same::value) - if (this->n_cols() > 15) + if (this->n_cols() > 15 && + this->n_cols() <= std::numeric_limits::max()) { // In case we have the LAPACK functions // getrf and getri detected by CMake, @@ -1780,7 +1793,7 @@ FullMatrix::gauss_jordan () // we just got ((A^T)^{-1})^T, which is // A^{-1}. - const types::blas_int nn = this->n(); + const types::blas_int nn = static_cast(this->n()); // workspace for permutations std::vector ipiv(nn);