libMesh
numeric_vector.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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_NUMERIC_VECTOR_H
21 #define LIBMESH_NUMERIC_VECTOR_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/enum_parallel_type.h" // AUTOMATIC
26 #include "libmesh/id_types.h"
27 #include "libmesh/int_range.h"
28 #include "libmesh/reference_counted_object.h"
29 #include "libmesh/libmesh.h"
30 #include "libmesh/parallel_object.h"
31 #include "libmesh/dense_subvector.h"
32 #include "libmesh/dense_vector.h"
33 
34 // C++ includes
35 #include <cstddef>
36 #include <set>
37 #include <vector>
38 #include <memory>
39 #include <mutex>
40 
41 namespace libMesh
42 {
43 
44 
45 // forward declarations
46 template <typename T> class NumericVector;
47 template <typename T> class DenseVector;
48 template <typename T> class DenseSubVector;
49 template <typename T> class SparseMatrix;
50 template <typename T> class ShellMatrix;
51 enum SolverPackage : int;
52 
67 template <typename T>
68 class NumericVector : public ReferenceCountedObject<NumericVector<T>>,
69  public ParallelObject
70 {
71 public:
72 
76  explicit
77  NumericVector (const Parallel::Communicator & comm_in,
78  const ParallelType ptype = AUTOMATIC);
79 
83  explicit
84  NumericVector (const Parallel::Communicator & comm_in,
85  const numeric_index_type n,
86  const ParallelType ptype = AUTOMATIC);
87 
92  NumericVector (const Parallel::Communicator & comm_in,
93  const numeric_index_type n,
94  const numeric_index_type n_local,
95  const ParallelType ptype = AUTOMATIC);
96 
102  NumericVector (const Parallel::Communicator & comm_in,
103  const numeric_index_type N,
104  const numeric_index_type n_local,
105  const std::vector<numeric_index_type> & ghost,
106  const ParallelType ptype = AUTOMATIC);
107 
119  virtual NumericVector<T> & operator= (const NumericVector<T> & v) = 0;
120 
125  NumericVector (NumericVector &&) = default;
126  NumericVector (const NumericVector &) = default;
127  NumericVector & operator= (NumericVector &&) = default;
128 
133  virtual ~NumericVector() = default;
134 
140  static std::unique_ptr<NumericVector<T>>
141  build(const Parallel::Communicator & comm,
143  ParallelType parallel_type = AUTOMATIC);
144 
149  virtual bool initialized() const { return _is_initialized; }
150 
154  ParallelType type() const { return _type; }
155 
163 #ifdef LIBMESH_ENABLE_DEPRECATED
164  ParallelType & type() { return _type; }
165 #endif
166 
176  void set_type(ParallelType t);
177 
182  virtual bool closed() const { return _is_closed; }
183 
188  virtual void close () = 0;
189 
193  virtual void clear ();
194 
199  virtual void zero () = 0;
200 
207  virtual std::unique_ptr<NumericVector<T>> zero_clone () const = 0;
208 
214  virtual std::unique_ptr<NumericVector<T>> clone () const = 0;
215 
226  virtual void init (const numeric_index_type n,
227  const numeric_index_type n_local,
228  const bool fast = false,
229  const ParallelType ptype = AUTOMATIC) = 0;
230 
234  virtual void init (const numeric_index_type n,
235  const bool fast = false,
236  const ParallelType ptype = AUTOMATIC) = 0;
237 
242  virtual void init (const numeric_index_type n,
243  const numeric_index_type n_local,
244  const std::vector<numeric_index_type> & ghost,
245  const bool fast = false,
246  const ParallelType ptype = AUTOMATIC) = 0;
247 
252  virtual void init (const NumericVector<T> & other,
253  const bool fast = false) = 0;
254 
260  virtual NumericVector<T> & operator= (const T s) = 0;
261 
267  virtual NumericVector<T> & operator= (const std::vector<T> & v) = 0;
268 
273  virtual Real min () const = 0;
274 
279  virtual Real max () const = 0;
280 
284  virtual T sum() const = 0;
285 
290  virtual Real l1_norm () const = 0;
291 
296  virtual Real l2_norm () const = 0;
297 
302  virtual Real linfty_norm () const = 0;
303 
310  virtual Real subset_l1_norm (const std::set<numeric_index_type> & indices) const;
311 
319  virtual Real subset_l2_norm (const std::set<numeric_index_type> & indices) const;
320 
327  virtual Real subset_linfty_norm (const std::set<numeric_index_type> & indices) const;
328 
333  Real l2_norm_diff (const NumericVector<T> & other_vec) const;
334 
339  Real l1_norm_diff (const NumericVector<T> & other_vec) const;
340 
344  virtual numeric_index_type size () const = 0;
345 
349  virtual numeric_index_type local_size() const = 0;
350 
357  virtual numeric_index_type first_local_index() const = 0;
358 
365  virtual numeric_index_type last_local_index() const = 0;
366 
370  virtual T operator() (const numeric_index_type i) const = 0;
371 
375  virtual T el(const numeric_index_type i) const { return (*this)(i); }
376 
383  virtual void get(const std::vector<numeric_index_type> & index,
384  T * values) const;
385 
392  void get(const std::vector<numeric_index_type> & index,
393  std::vector<T> & values) const;
394 
402  virtual NumericVector<T> & operator += (const NumericVector<T> & v) = 0;
403 
411  virtual NumericVector<T> & operator -= (const NumericVector<T> & v) = 0;
412 
420  NumericVector<T> & operator *= (const T a) { this->scale(a); return *this; }
421 
429  virtual NumericVector<T> & operator *= (const NumericVector<T> & v) = 0;
430 
438  NumericVector<T> & operator /= (const T a) { this->scale(1./a); return *this; }
439 
446  virtual NumericVector<T> & operator /= (const NumericVector<T> & v) = 0;
447 
452  virtual void reciprocal() = 0;
453 
457  virtual void conjugate() = 0;
458 
463  virtual void set (const numeric_index_type i, const T value) = 0;
464 
469  virtual void add (const numeric_index_type i, const T value) = 0;
470 
475  virtual void add (const T s) = 0;
476 
482  virtual void add (const NumericVector<T> & v) = 0;
483 
489  virtual void add (const T a, const NumericVector<T> & v) = 0;
490 
498  virtual void add_vector (const T * v,
499  const std::vector<numeric_index_type> & dof_indices);
500 
507  void add_vector (const std::vector<T> & v,
508  const std::vector<numeric_index_type> & dof_indices);
509 
516  void add_vector (const NumericVector<T> & v,
517  const std::vector<numeric_index_type> & dof_indices);
518 
525  void add_vector (const DenseVector<T> & v,
526  const std::vector<numeric_index_type> & dof_indices);
527 
533  virtual void add_vector (const NumericVector<T> & v,
534  const SparseMatrix<T> & A) = 0;
535 
541  void add_vector (const NumericVector<T> & v,
542  const ShellMatrix<T> & A);
543 
549  virtual void add_vector_transpose (const NumericVector<T> & v,
550  const SparseMatrix<T> & A) = 0;
551 
556  virtual void insert (const T * v,
557  const std::vector<numeric_index_type> & dof_indices);
558 
563  void insert (const std::vector<T> & v,
564  const std::vector<numeric_index_type> & dof_indices);
565 
570  void insert (const NumericVector<T> & v,
571  const std::vector<numeric_index_type> & dof_indices);
572 
577  void insert (const DenseVector<T> & v,
578  const std::vector<numeric_index_type> & dof_indices);
579 
584  void insert (const DenseSubVector<T> & v,
585  const std::vector<numeric_index_type> & dof_indices);
586 
590  virtual void scale (const T factor) = 0;
591 
595  virtual void abs() = 0;
596 
603  virtual T dot(const NumericVector<T> & v) const = 0;
604 
609  virtual void localize (std::vector<T> & v_local) const = 0;
610 
615  virtual void localize (NumericVector<T> & v_local) const = 0;
616 
621  virtual void localize (NumericVector<T> & v_local,
622  const std::vector<numeric_index_type> & send_list) const = 0;
623 
653  virtual void localize (std::vector<T> & v_local,
654  const std::vector<numeric_index_type> & indices) const = 0;
655 
660  virtual void localize (const numeric_index_type first_local_idx,
661  const numeric_index_type last_local_idx,
662  const std::vector<numeric_index_type> & send_list) = 0;
663 
669  virtual void localize_to_one (std::vector<T> & v_local,
670  const processor_id_type proc_id=0) const = 0;
671 
677  virtual int compare (const NumericVector<T> & other_vector,
678  const Real threshold = TOLERANCE) const;
679 
685  virtual int local_relative_compare (const NumericVector<T> & other_vector,
686  const Real threshold = TOLERANCE) const;
687 
693  virtual int global_relative_compare (const NumericVector<T> & other_vector,
694  const Real threshold = TOLERANCE) const;
695 
701  virtual void pointwise_mult (const NumericVector<T> & vec1,
702  const NumericVector<T> & vec2) = 0;
703 
709  virtual void pointwise_divide (const NumericVector<T> & vec1,
710  const NumericVector<T> & vec2) = 0;
711 
716  virtual void print(std::ostream & os=libMesh::out) const;
717 
722  virtual void print_global(std::ostream & os=libMesh::out) const;
723 
727  friend std::ostream & operator << (std::ostream & os, const NumericVector<T> & v)
728  {
729  v.print_global(os);
730  return os;
731  }
732 
738  virtual void print_matlab(const std::string & filename = "") const;
739 
751  virtual void read_matlab(const std::string & filename);
752 
763  const std::vector<numeric_index_type> &,
764  bool = true) const
765  {
766  libmesh_not_implemented();
767  }
768 
775  virtual std::unique_ptr<NumericVector<T>>
776  get_subvector(const std::vector<numeric_index_type> &)
777  {
778  libmesh_not_implemented();
779  }
780 
786  virtual void restore_subvector(std::unique_ptr<NumericVector<T>>,
787  const std::vector<numeric_index_type> &)
788  {
789  libmesh_not_implemented();
790  }
791 
797  virtual void swap (NumericVector<T> & v);
798 
810  virtual std::size_t max_allowed_id() const = 0;
811 
816  bool readable() const;
817 
822  bool compatible(const NumericVector<T> & v) const;
823 
824 protected:
825 
832 
837 
842 
847 };
848 
849 
850 /*----------------------- Inline functions ----------------------------------*/
851 
852 
853 
854 template <typename T>
855 inline
857  const ParallelType ptype) :
858  ParallelObject(comm_in),
859  _is_closed(false),
860  _is_initialized(false),
861  _type(ptype)
862 {
863 }
864 
865 
866 
867 template <typename T>
868 inline
870  const numeric_index_type /*n*/,
871  const ParallelType ptype) :
872  ParallelObject(comm_in),
873  _is_closed(false),
874  _is_initialized(false),
875  _type(ptype)
876 {
877  libmesh_not_implemented(); // Abstract base class!
878  // init(n, n, false, ptype);
879 }
880 
881 
882 
883 template <typename T>
884 inline
886  const numeric_index_type /*n*/,
887  const numeric_index_type /*n_local*/,
888  const ParallelType ptype) :
889  ParallelObject(comm_in),
890  _is_closed(false),
891  _is_initialized(false),
892  _type(ptype)
893 {
894  libmesh_not_implemented(); // Abstract base class!
895  // init(n, n_local, false, ptype);
896 }
897 
898 
899 
900 template <typename T>
901 inline
903  const numeric_index_type /*n*/,
904  const numeric_index_type /*n_local*/,
905  const std::vector<numeric_index_type> & /*ghost*/,
906  const ParallelType ptype) :
907  ParallelObject(comm_in),
908  _is_closed(false),
909  _is_initialized(false),
910  _type(ptype)
911 {
912  libmesh_not_implemented(); // Abstract base class!
913  // init(n, n_local, ghost, false, ptype);
914 }
915 
916 
917 
918 template <typename T>
919 inline
921 {
922  _is_closed = false;
923  _is_initialized = false;
924 }
925 
926 
927 
928 template <typename T>
929 inline
930 void NumericVector<T>::get(const std::vector<numeric_index_type> & index,
931  T * values) const
932 {
933  const std::size_t num = index.size();
934  for (std::size_t i=0; i<num; i++)
935  {
936  values[i] = (*this)(index[i]);
937  }
938 }
939 
940 
941 
942 template <typename T>
943 inline
944 void NumericVector<T>::get(const std::vector<numeric_index_type> & index,
945  std::vector<T> & values) const
946 {
947  const std::size_t num = index.size();
948  values.resize(num);
949  if (!num)
950  return;
951 
952  this->get(index, values.data());
953 }
954 
955 
956 
957 template <typename T>
958 inline
959 void NumericVector<T>::add_vector(const std::vector<T> & v,
960  const std::vector<numeric_index_type> & dof_indices)
961 {
962  libmesh_assert(v.size() == dof_indices.size());
963  if (!v.empty())
964  this->add_vector(v.data(), dof_indices);
965 }
966 
967 
968 
969 template <typename T>
970 inline
972  const std::vector<numeric_index_type> & dof_indices)
973 {
974  libmesh_assert(v.size() == dof_indices.size());
975  if (!v.empty())
976  this->add_vector(&v(0), dof_indices);
977 }
978 
979 
980 
981 template <typename T>
982 inline
983 void NumericVector<T>::insert(const std::vector<T> & v,
984  const std::vector<numeric_index_type> & dof_indices)
985 {
986  libmesh_assert(v.size() == dof_indices.size());
987  if (!v.empty())
988  this->insert(v.data(), dof_indices);
989 }
990 
991 
992 
993 template <typename T>
994 inline
996  const std::vector<numeric_index_type> & dof_indices)
997 {
998  libmesh_assert(v.size() == dof_indices.size());
999  if (!v.empty())
1000  this->insert(&v(0), dof_indices);
1001 }
1002 
1003 
1004 
1005 template <typename T>
1006 inline
1008  const std::vector<numeric_index_type> & dof_indices)
1009 {
1010  libmesh_assert(v.size() == dof_indices.size());
1011  if (!v.empty())
1012  this->insert(&v(0), dof_indices);
1013 }
1014 
1015 
1016 
1017 // Full specialization of the print() member for complex
1018 // variables. This must precede the non-specialized
1019 // version, at least according to icc v7.1
1020 template <>
1021 inline
1022 void NumericVector<Complex>::print(std::ostream & os) const
1023 {
1024  libmesh_assert (this->initialized());
1025  os << "Size\tglobal = " << this->size()
1026  << "\t\tlocal = " << this->local_size() << std::endl;
1027 
1028  // std::complex<>::operator<<() is defined, but use this form
1029  os << "#\tReal part\t\tImaginary part" << std::endl;
1030  for (auto i : index_range(*this))
1031  os << i << "\t"
1032  << (*this)(i).real() << "\t\t"
1033  << (*this)(i).imag() << std::endl;
1034 }
1035 
1036 
1037 
1038 template <typename T>
1039 inline
1040 void NumericVector<T>::print(std::ostream & os) const
1041 {
1042  libmesh_assert (this->initialized());
1043  os << "Size\tglobal = " << this->size()
1044  << "\t\tlocal = " << this->local_size() << std::endl;
1045 
1046  os << "#\tValue" << std::endl;
1047  for (auto i : index_range(*this))
1048  os << i << "\t" << (*this)(i) << std::endl;
1049 }
1050 
1051 
1052 
1053 template <>
1054 inline
1055 void NumericVector<Complex>::print_global(std::ostream & os) const
1056 {
1057  libmesh_assert (this->initialized());
1058 
1059  std::vector<Complex> v(this->size());
1060  this->localize(v);
1061 
1062  // Right now we only want one copy of the output
1063  if (this->processor_id())
1064  return;
1065 
1066  os << "Size\tglobal = " << this->size() << std::endl;
1067  os << "#\tReal part\t\tImaginary part" << std::endl;
1068  for (auto i : make_range(v.size()))
1069  os << i << "\t"
1070  << v[i].real() << "\t\t"
1071  << v[i].imag() << std::endl;
1072 }
1073 
1074 
1075 template <typename T>
1076 inline
1077 void NumericVector<T>::print_global(std::ostream & os) const
1078 {
1079  libmesh_assert (this->initialized());
1080 
1081  std::vector<T> v(this->size());
1082  this->localize(v);
1083 
1084  // Right now we only want one copy of the output
1085  if (this->processor_id())
1086  return;
1087 
1088  os << "Size\tglobal = " << this->size() << std::endl;
1089  os << "#\tValue" << std::endl;
1090  for (auto i : make_range(v.size()))
1091  os << i << "\t" << v[i] << std::endl;
1092 }
1093 
1094 
1095 
1096 template <typename T>
1097 inline
1099 {
1100  std::swap(_is_closed, v._is_closed);
1101  std::swap(_is_initialized, v._is_initialized);
1102  std::swap(_type, v._type);
1103 }
1104 
1105 template <typename T>
1106 auto
1108 {
1109  return vec.l1_norm();
1110 }
1111 
1112 template <typename T>
1113 auto
1115 {
1116  return vec1.l1_norm_diff(vec2);
1117 }
1118 
1119 } // namespace libMesh
1120 
1121 
1122 // Workaround for weird boost/NumericVector interaction bug
1123 #ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
1124 #include <boost/mpl/bool.hpp>
1125 
1126 namespace boost { namespace multiprecision { namespace detail {
1127 template <typename T, typename To>
1128 struct is_lossy_conversion<libMesh::NumericVector<T>, To> {
1129  typedef boost::mpl::true_ type;
1130  static const bool value = type::value;
1131 };
1132 }}}
1133 #endif
1134 
1135 
1136 #endif // LIBMESH_NUMERIC_VECTOR_H
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
Inserts the entries of v in *this at the locations specified by v.
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
std::mutex _numeric_vector_mutex
Mutex for performing thread-safe operations.
virtual void print_global(std::ostream &os=libMesh::out) const
Prints the global contents of the vector, by default to libMesh::out.
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
virtual T el(const numeric_index_type i) const
static constexpr Real TOLERANCE
virtual T sum() const =0
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A)=0
Computes , i.e.
virtual bool initialized() const
virtual numeric_index_type size() const =0
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
virtual unsigned int size() const override final
virtual NumericVector< T > & operator=(const NumericVector< T > &v)=0
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators...
ParallelType & type()
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: vector_fe_ex5.C:44
const Parallel::Communicator & comm() const
virtual std::unique_ptr< NumericVector< T > > clone() const =0
bool _is_initialized
true once init() has been called.
The libMesh namespace provides an interface to certain functionality in the library.
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
virtual T dot(const NumericVector< T > &v) const =0
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
virtual bool empty() const override final
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
uint8_t processor_id_type
Definition: id_types.h:104
virtual void zero()=0
Set all entries to zero.
Defines a dense subvector for use in finite element computations.
virtual void create_subvector(NumericVector< T > &, const std::vector< numeric_index_type > &, bool=true) const
Fills in subvector from this vector using the indices in rows.
Real l2_norm_diff(const NumericVector< T > &other_vec) const
Generic sparse matrix.
Definition: vector_fe_ex5.C:46
SolverPackage default_solver_package()
Definition: libmesh.C:1117
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const =0
Creates a local copy of the global vector in v_local only on processor proc_id.
virtual Real l2_norm() const =0
virtual NumericVector< T > & operator+=(const NumericVector< T > &v)=0
Adds v to *this, .
virtual ~NumericVector()=default
While this class doesn&#39;t manage any memory, the derived class might and users may be deleting through...
auto l1_norm(const NumericVector< T > &vec)
dof_id_type numeric_index_type
Definition: id_types.h:99
bool _is_initialized
Flag that tells if init() has been called.
Definition: libmesh.C:257
NumericVector(const Parallel::Communicator &comm_in, const ParallelType ptype=AUTOMATIC)
Dummy-Constructor.
NumericVector< T > & operator/=(const T a)
Scales the vector by 1/a, .
auto l1_norm_diff(const NumericVector< T > &vec1, const NumericVector< T > &vec2)
NumericVector< T > & operator*=(const T a)
Scales the vector by a, .
virtual bool empty() const override final
Definition: dense_vector.h:109
libmesh_assert(ctx)
virtual void read_matlab(const std::string &filename)
Read the contents of the vector from the Matlab-script format used by PETSc.
bool compatible(const NumericVector< T > &v) const
virtual int global_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual void print(std::ostream &os=libMesh::out) const
Prints the local contents of the vector, by default to libMesh::out.
virtual Real max() const =0
virtual Real min() const =0
virtual std::unique_ptr< NumericVector< T > > get_subvector(const std::vector< numeric_index_type > &)
Creates a view into this vector using the indices in rows.
An object whose state is distributed along a set of processors.
virtual Real l1_norm() const =0
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
ParallelType _type
Type of vector.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
virtual bool closed() const
Real l1_norm_diff(const NumericVector< T > &other_vec) const
virtual void abs()=0
Sets for each entry in the vector.
virtual numeric_index_type first_local_index() const =0
ParallelType type() const
virtual int local_relative_compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab&#39;s sparse matrix format.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual NumericVector< T > & operator-=(const NumericVector< T > &v)=0
Subtracts v from *this, .
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
virtual int compare(const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
OStreamProxy out
virtual numeric_index_type local_size() const =0
virtual std::size_t max_allowed_id() const =0
static const bool value
Definition: xdr_io.C:54
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:140
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual unsigned int size() const override final
Definition: dense_vector.h:104
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:276
virtual void clear()
Restores the NumericVector<T> to a pristine state.
Defines a dense vector for use in Finite Element-type computations.
Definition: dof_map.h:74
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
virtual void reciprocal()=0
Computes the component-wise reciprocal, .
SolverPackage
Defines an enum for various linear solver packages.
Generic shell matrix, i.e.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual T operator()(const numeric_index_type i) const =0
virtual numeric_index_type last_local_index() const =0
virtual Real linfty_norm() const =0
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
void set_type(ParallelType t)
Allow the user to change the ParallelType of the NumericVector under some circumstances.
const Elem & get(const ElemType type_in)
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
Computes (summation not implied) i.e.
bool _is_closed
Flag which tracks whether the vector&#39;s values are consistent on all processors after insertion or add...
virtual void conjugate()=0
Negates the imaginary component of each entry in the vector.
ParallelType
Defines an enum for parallel data structure types.
virtual void restore_subvector(std::unique_ptr< NumericVector< T >>, const std::vector< numeric_index_type > &)
Restores a view into this vector using the indices in rows.
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.