libMesh
dense_vector_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 
19 
20 #ifndef LIBMESH_DENSE_VECTOR_BASE_H
21 #define LIBMESH_DENSE_VECTOR_BASE_H
22 
23 
24 // Local Includes
25 #include "libmesh/libmesh_common.h"
26 
27 // C++ includes
28 
29 namespace libMesh
30 {
31 
40 template<typename T>
41 class DenseVectorBase
42 {
43 public:
47  DenseVectorBase() = default;
48 
53  DenseVectorBase (DenseVectorBase &&) = default;
54  DenseVectorBase (const DenseVectorBase &) = default;
55  DenseVectorBase & operator= (const DenseVectorBase &) = default;
57  virtual ~DenseVectorBase() = default;
58 
64  virtual void zero() = 0;
65 
69  virtual T el(const unsigned int i) const = 0;
70 
74  virtual T & el(const unsigned int i) = 0;
75 
79  virtual unsigned int size() const = 0;
80 
84  virtual bool empty() const { return (this->size() == 0); }
85 
89  void print(std::ostream & os) const;
90 
95  friend std::ostream & operator << (std::ostream & os, const DenseVectorBase<T> & v)
96  {
97  v.print(os);
98  return os;
99  }
100 
105  void print_scientific(std::ostream & os, unsigned precision=8) const;
106 };
107 
108 } // namespace libMesh
109 
110 
111 
112 #endif // LIBMESH_DENSE_VECTOR_BASE_H
libMesh::DenseVectorBase::DenseVectorBase
DenseVectorBase()=default
Constructor.
libMesh::DenseVectorBase::operator=
DenseVectorBase & operator=(const DenseVectorBase &)=default
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::DenseVectorBase
Defines an abstract dense vector base class for use in Finite Element-type computations.
Definition: dof_map.h:71
libMesh::DenseVectorBase::el
virtual T el(const unsigned int i) const =0
libMesh::DenseVectorBase::operator<<
friend std::ostream & operator<<(std::ostream &os, const DenseVectorBase< T > &v)
Same as above, but allows you to print using the usual stream syntax.
Definition: dense_vector_base.h:95
libMesh::DenseVectorBase::empty
virtual bool empty() const
Definition: dense_vector_base.h:84
libMesh::DenseVectorBase::~DenseVectorBase
virtual ~DenseVectorBase()=default
libMesh::DenseVectorBase::size
virtual unsigned int size() const =0
libMesh::DenseVectorBase::zero
virtual void zero()=0
Set every element in the vector to 0.
libMesh::DenseVectorBase::print_scientific
void print_scientific(std::ostream &os, unsigned precision=8) const
Prints the entries of the vector with additional decimal places in scientific notation.
Definition: dense_vector_base.C:31
libMesh::DenseVectorBase::print
void print(std::ostream &os) const
Pretty-print the vector to stdout.
Definition: dense_vector_base.C:51