dense_vector_base.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 // C++ includes
19 #include <iostream>
20 #include <iomanip> // for std::setw
21 
22 
23 // Local Includes
25 #include "libmesh/int_range.h"
26 
27 namespace libMesh
28 {
29 
30 template<typename T>
31 void DenseVectorBase<T>::print_scientific (std::ostream & os, unsigned precision) const
32 {
33  // save the initial format flags
34  std::ios_base::fmtflags os_flags = os.flags();
35 
36  // Print the vector entries.
37  for (auto i : IntRange<int>(0, this->size()))
38  os << std::setw(10)
39  << std::scientific
40  << std::setprecision(precision)
41  << this->el(i)
42  << std::endl;
43 
44  // reset the original format flags
45  os.flags(os_flags);
46 }
47 
48 
49 
50 template<typename T>
51 void DenseVectorBase<T>::print (std::ostream & os) const
52 {
53  for (auto i : IntRange<int>(0, this->size()))
54  os << std::setw(8)
55  << this->el(i)
56  << std::endl;
57 }
58 
59 
60 //--------------------------------------------------------------
61 // Explicit instantiations
62 template class DenseVectorBase<Real>;
63 
64 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
65 template class DenseVectorBase<Complex>;
66 #endif
67 
68 } // namespace libMesh
void print_scientific(std::ostream &os, unsigned precision=8) const
void print(std::ostream &os) const