16 #ifndef dealii_vector_h
17 #define dealii_vector_h
31 #include <boost/serialization/split_member.hpp>
34 #include <initializer_list>
43 # ifdef DEAL_II_WITH_PETSC
50 # ifdef DEAL_II_WITH_TRILINOS
60 template <
typename number>
107 template <
typename Number>
121 "The Vector class only supports basic numeric types. In particular, it "
122 "does not support automatically differentiated numbers.");
182 template <
typename OtherNumber>
200 template <
typename OtherNumber>
201 explicit Vector(
const std::initializer_list<OtherNumber> &v);
203 #ifdef DEAL_II_WITH_PETSC
218 #ifdef DEAL_II_WITH_TRILINOS
251 template <
typename InputIterator>
340 template <
typename Number2>
396 template <
typename Number2>
406 #ifdef DEAL_II_WITH_PETSC
423 #ifdef DEAL_II_WITH_TRILINOS
448 template <
typename Number2>
457 template <
typename Number2>
482 template <
typename Number2>
661 template <
typename OtherNumber>
664 std::vector<OtherNumber> &
values)
const;
693 template <
typename ForwardIterator,
typename OutputIterator>
696 const ForwardIterator indices_end,
697 OutputIterator values_begin)
const;
726 template <
typename OtherNumber>
728 add(
const std::vector<size_type> & indices,
729 const std::vector<OtherNumber> &
values);
735 template <
typename OtherNumber>
744 template <
typename OtherNumber>
748 const OtherNumber *
values);
825 template <
typename Number2>
840 template <
typename Number2>
865 const unsigned int precision = 3,
866 const bool scientific =
true,
867 const bool across =
true)
const;
896 template <
class Archive>
898 save(Archive &ar,
const unsigned int version)
const;
905 template <
class Archive>
907 load(Archive &ar,
const unsigned int version);
915 template <
class Archive>
917 serialize(Archive &archive,
const unsigned int version);
921 BOOST_SERIALIZATION_SPLIT_MEMBER()
1038 const bool omit_zeroing_entries,
1039 const bool reset_partitioner);
1045 mutable std::shared_ptr<parallel::internal::TBBPartitioner>
1049 template <
typename Number2>
1068 template <
typename Number>
1079 template <
typename Number>
1080 template <
typename OtherNumber>
1087 template <
typename Number>
1088 template <
typename InputIterator>
1099 template <
typename Number>
1110 template <
typename Number>
1119 template <
typename Number>
1128 template <
typename Number>
1137 template <
typename Number>
1146 template <
typename Number>
1155 template <
typename Number>
1164 template <
typename Number>
1173 template <
typename Number>
1182 template <
typename Number>
1191 template <
typename Number>
1201 template <
typename Number>
1211 template <
typename Number>
1220 template <
typename Number>
1229 template <
typename Number>
1230 template <
typename OtherNumber>
1233 std::vector<OtherNumber> &
values)
const
1235 for (
size_type i = 0; i < indices.size(); ++i)
1236 values[i] =
operator()(indices[i]);
1241 template <
typename Number>
1242 template <
typename ForwardIterator,
typename OutputIterator>
1245 const ForwardIterator indices_end,
1246 OutputIterator values_begin)
const
1248 while (indices_begin != indices_end)
1258 template <
typename Number>
1271 template <
typename Number>
1272 template <
typename OtherNumber>
1275 const std::vector<OtherNumber> &
values)
1279 add(indices.size(), indices.data(),
values.data());
1284 template <
typename Number>
1285 template <
typename OtherNumber>
1292 add(indices.size(), indices.data(),
values.values.begin());
1297 template <
typename Number>
1298 template <
typename OtherNumber>
1302 const OtherNumber *
values)
1304 for (
size_type i = 0; i < n_indices; ++i)
1310 "The given value is not finite but either infinite or Not A Number (NaN)"));
1312 this->values[indices[i]] +=
values[i];
1318 template <
typename Number>
1319 template <
typename Number2>
1323 return !(*
this == v);
1328 template <
typename Number>
1334 template <
typename Number>
1343 template <
typename Number>
1350 template <
typename Number>
1357 template <
typename Number>
1358 template <
typename Number2>
1361 const bool omit_zeroing_entries)
1365 if (!omit_zeroing_entries ||
size() != v.
size())
1377 template <
typename Number>
1387 template <
typename Number>
1388 template <
class Archive>
1399 template <
typename Number>
1400 template <
class Archive>
1426 template <
typename Number>
1441 template <
typename number>
1442 inline std::ostream &
1450 out << v(v.
size() - 1);
1465 template <
typename Number>
OutputOperator< VectorType > & operator<<(OutputOperator< VectorType > &out, unsigned int step)
typename numbers::NumberTraits< Number >::real_type real_type
void extract_subvector_to(ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
bool operator!=(const Vector< Number2 > &v) const
const value_type * const_pointer
void scale(const Vector< Number2 > &scaling_factors)
Vector< Number > & operator+=(const Vector< Number > &V)
bool has_ghost_elements() const
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
Number & operator()(const size_type i)
void add(const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W)
Vector(const TrilinosWrappers::MPI::Vector &v)
bool in_local_range(const size_type global_index) const
Number operator*(const Vector< Number2 > &V) const
const_pointer data() const
void do_reinit(const size_type new_size, const bool omit_zeroing_entries, const bool reset_partitioner)
void sadd(const Number s, const Number a, const Vector< Number > &V)
Vector(const size_type n)
const value_type * const_iterator
void block_write(std::ostream &out) const
Number mean_value() const
Number add_and_dot(const Number a, const Vector< Number > &V, const Vector< Number > &W)
void load(Archive &ar, const unsigned int version)
const value_type & const_reference
Vector< Number > & operator/=(const Number factor)
void reinit(const Vector< Number2 > &V, const bool omit_zeroing_entries=false)
Vector< Number > & operator=(const TrilinosWrappers::MPI::Vector &v)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
Number & operator[](const size_type i)
Vector< Number > & operator*=(const Number factor)
Vector(const Vector< Number > &v)
std::shared_ptr< parallel::internal::TBBPartitioner > thread_loop_partitioner
void block_read(std::istream &in)
types::global_dof_index size_type
Vector< Number > & operator=(const BlockVector< Number > &v)
Number operator[](const size_type i) const
Vector< Number > & operator=(const Vector< Number > &v)
void equ(const Number a, const Vector< Number > &u)
void zero_out_ghost_values() const
Vector< Number > & operator-=(const Vector< Number > &V)
void serialize(Archive &archive, const unsigned int version)
Vector(const PETScWrappers::VectorBase &v)
real_type lp_norm(const real_type p) const
const_iterator begin() const
void sadd(const Number s, const Vector< Number > &V)
Vector< Number > & operator=(const PETScWrappers::VectorBase &v)
bool operator==(const Vector< Number2 > &v) const
void compress(::VectorOperation::values operation=::VectorOperation::unknown) const
real_type l2_norm() const
virtual void swap(Vector< Number > &v)
void grow_or_shrink(const size_type N)
virtual ~Vector() override=default
Vector(const Vector< OtherNumber > &v)
void save(Archive &ar, const unsigned int version) const
Vector< Number > & operator=(const Number s)
real_type linfty_norm() const
Vector< Number > & operator=(const Vector< Number2 > &v)
void scale(const Vector< Number > &scaling_factors)
void maybe_reset_thread_partitioner()
IndexSet locally_owned_elements() const
real_type norm_sqr() const
void add(const Number a, const Vector< Number > &V)
AlignedVector< Number > values
void equ(const Number a, const Vector< Number2 > &u)
void apply_givens_rotation(const std::array< Number, 3 > &csr, const size_type i, const size_type k)
const_iterator end() const
Vector(Vector< Number > &&v) noexcept=default
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
void add(const size_type n_elements, const size_type *indices, const OtherNumber *values)
size_type locally_owned_size() const
Number operator()(const size_type i) const
bool is_non_negative() const
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
void update_ghost_values() const
Vector< Number > & operator=(Vector< Number > &&v) noexcept=default
std::size_t memory_consumption() const
real_type l1_norm() const
void add(const std::vector< size_type > &indices, const Vector< OtherNumber > &values)
Vector(const InputIterator first, const InputIterator last)
Vector(const std::initializer_list< OtherNumber > &v)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcZero()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
#define AssertIsFinite(number)
static ::ExceptionBase & ExcEmptyObject()
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void swap(Vector< Number > &u, Vector< Number > &v)
types::global_dof_index size_type
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
void copy(const T *begin, const T *end, U *dest)
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
bool is_finite(const double x)
unsigned int global_dof_index