]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Prefer boost::math::iround to static_cast<int>. 1895/head
authorDavid Wells <wellsd2@rpi.edu>
Sat, 21 Nov 2015 23:33:45 +0000 (18:33 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Sat, 21 Nov 2015 23:51:30 +0000 (18:51 -0500)
source/lac/lapack_full_matrix.cc

index 5abe298209ea53e251a53c6f8a65faf0b759c1a8..52faaca1503444c99fb64ef45791197d98e71ab6 100644 (file)
@@ -22,6 +22,8 @@
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/block_vector.h>
 
+#include <boost/math/special_functions/round.hpp>
+
 #include <iostream>
 #include <iomanip>
 
@@ -503,7 +505,7 @@ LAPACKFullMatrix<number>::compute_svd()
         &work[0], &lwork, &ipiv[0], &info);
   AssertThrow (info==0, LAPACKSupport::ExcErrorCode("gesdd", info));
   // Now resize work array and
-  lwork = static_cast<int>(work[0] + .5);
+  lwork = boost::math::iround(work[0]);
 
   work.resize(lwork);
   // Do the actual SVD.
@@ -655,7 +657,7 @@ LAPACKFullMatrix<number>::compute_eigenvalues(const bool right,
   // for work, everything else would not be acceptable.
   Assert (info == 0, ExcInternalError());
   // Allocate working array according to suggestion.
-  lwork = (int) (work[0]+.1);
+  lwork = boost::math::iround(work[0]);
 
   // resize workspace array
   work.resize((size_type ) lwork);
@@ -727,7 +729,7 @@ LAPACKFullMatrix<number>::compute_eigenvalues_symmetric(const number        lowe
   // for work, everything else would not be acceptable.
   Assert (info == 0, ExcInternalError());
   // Allocate working array according to suggestion.
-  lwork = (int) (work[0]+.1);
+  lwork = boost::math::iround(work[0]);
   work.resize(static_cast<size_type> (lwork));
 
   // Finally compute the eigenvalues.
@@ -817,7 +819,7 @@ LAPACKFullMatrix<number>::compute_generalized_eigenvalues_symmetric(
   // for work, everything else would not be acceptable.
   Assert (info == 0, ExcInternalError());
   // Allocate working array according to suggestion.
-  lwork = (int) (work[0]+.1);
+  lwork = boost::math::iround(work[0]);
 
   // resize workspace arrays
   work.resize(static_cast<size_type> (lwork));
@@ -898,7 +900,7 @@ LAPACKFullMatrix<number>::compute_generalized_eigenvalues_symmetric (
   // for work, everything else would not be acceptable.
   Assert (info == 0, ExcInternalError());
   // Allocate working array according to suggestion.
-  lwork = (int) (work[0]+.1);
+  lwork = boost::math::iround(work[0]);
 
   // resize workspace array
   work.resize((size_type) lwork);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.