16 #ifndef dealii__vector_h 17 #define dealii__vector_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/logstream.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/subscriptor.h> 24 #include <deal.II/base/index_set.h> 25 #include <deal.II/lac/vector_type_traits.h> 29 #include <boost/version.hpp> 30 #if BOOST_VERSION >= 106400 31 # include <boost/serialization/array_wrapper.hpp> 33 # include <boost/serialization/array.hpp> 35 #include <boost/serialization/split_member.hpp> 42 DEAL_II_NAMESPACE_OPEN
45 #ifdef DEAL_II_WITH_PETSC 56 #ifdef DEAL_II_WITH_TRILINOS 137 template <
typename Number>
199 #ifdef DEAL_II_WITH_CXX11 211 #ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG 224 template <
typename OtherNumber>
229 #ifdef DEAL_II_WITH_PETSC 250 #ifdef DEAL_II_WITH_TRILINOS 281 explicit Vector (
const size_type n);
287 template <
typename InputIterator>
288 Vector (
const InputIterator first,
289 const InputIterator last);
328 virtual void reinit (
const size_type N,
329 const bool omit_zeroing_entries=
false);
338 template <
typename Number2>
340 const bool omit_zeroing_entries=
false);
381 #ifdef DEAL_II_WITH_CXX11 398 template <
typename Number2>
406 #ifdef DEAL_II_WITH_PETSC 430 #ifdef DEAL_II_WITH_TRILINOS 459 template <
typename Number2>
467 template <
typename Number2>
491 template <
typename Number2>
588 const_iterator
begin ()
const;
599 const_iterator
end ()
const;
631 template <
typename OtherNumber>
633 std::vector<OtherNumber> &values)
const;
639 template <
typename ForwardIterator,
typename OutputIterator>
641 const ForwardIterator indices_end,
642 OutputIterator values_begin)
const;
669 template <
typename OtherNumber>
670 void add (
const std::vector<size_type> &indices,
671 const std::vector<OtherNumber> &values);
677 template <
typename OtherNumber>
678 void add (
const std::vector<size_type> &indices,
686 template <
typename OtherNumber>
687 void add (
const size_type n_elements,
688 const size_type *indices,
689 const OtherNumber *values);
697 void add (
const Number s);
729 void sadd (
const Number s,
737 void sadd (
const Number s,
748 void sadd (
const Number s,
762 void sadd (
const Number s,
798 template <
typename Number2>
811 template <
typename Number2>
875 void print (
const char *format = 0) const DEAL_II_DEPRECATED;
884 const
unsigned int precision = 3,
885 const
bool scientific = true,
886 const
bool across = true) const;
897 const
unsigned int width = 6,
898 const
bool across = true) const DEAL_II_DEPRECATED;
924 template <class Archive>
925 void save (Archive &ar, const
unsigned int version) const;
931 template <class Archive>
932 void load (Archive &ar, const
unsigned int version);
934 BOOST_SERIALIZATION_SPLIT_MEMBER()
1029 template <typename Number2> friend class
Vector;
1064 #ifdef DEAL_II_BOOST_BIND_COMPILER_BUG 1078 template <
typename Number>
1091 template <
typename Number>
1092 template <
typename InputIterator>
1101 reinit (std::distance (first, last),
true);
1102 std::copy (first, last,
begin());
1107 template <
typename Number>
1120 template <
typename Number>
1133 template <
typename Number>
1141 template <
typename Number>
1144 (
const size_type)
const 1151 template <
typename Number>
1153 typename Vector<Number>::iterator
1161 template <
typename Number>
1163 typename Vector<Number>::const_iterator
1171 template <
typename Number>
1173 typename Vector<Number>::iterator
1176 return &val[vec_size];
1181 template <
typename Number>
1183 typename Vector<Number>::const_iterator
1186 return &val[vec_size];
1191 template <
typename Number>
1201 template <
typename Number>
1205 Assert (i<vec_size, ExcIndexRangeType<size_type>(i,0,vec_size));
1211 template <
typename Number>
1215 return operator()(i);
1220 template <
typename Number>
1224 return operator()(i);
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)
1250 *values_begin = operator()(*indices_begin);
1258 template <
typename Number>
1266 this->operator *= (Number(1.)/factor);
1272 template <
typename Number>
1273 template <
typename OtherNumber>
1277 const std::vector<OtherNumber> &values)
1279 Assert (indices.size() == values.size(),
1281 add (indices.size(), &indices[0], &values[0]);
1286 template <
typename Number>
1287 template <
typename OtherNumber>
1295 add (indices.size(), &indices[0], values.
val);
1300 template <
typename Number>
1301 template <
typename OtherNumber>
1305 const size_type *indices,
1306 const OtherNumber *values)
1308 for (size_type i=0; i<n_indices; ++i)
1312 ExcMessage(
"The given value is not finite but either infinite or Not A Number (NaN)"));
1314 val[indices[i]] += values[i];
1320 template <
typename Number>
1321 template <
typename Number2>
1326 return ! (*
this == v);
1331 template <
typename Number>
1339 template <
typename Number>
1350 template <
typename Number>
1357 std::swap (val, v.
val);
1362 template <
typename Number>
1363 template <
class Archive>
1371 ar &vec_size &max_vec_size ;
1372 ar &boost::serialization::make_array(val, max_vec_size);
1377 template <
typename Number>
1378 template <
class Archive>
1388 ar &vec_size &max_vec_size ;
1391 ar &boost::serialization::make_array(val, max_vec_size);
1410 template <
typename Number>
1421 template <
typename number>
1424 operator << (std::ostream &os, const Vector<number> &v)
1433 template <
typename number>
1436 operator << (LogStream &os, const Vector<number> &v)
1450 template <
typename Number>
1456 DEAL_II_NAMESPACE_CLOSE
void block_read(std::istream &in)
void update_ghost_values() const
std::size_t memory_consumption() const
real_type l1_norm() const
Number add_and_dot(const Number a, const Vector< Number > &V, const Vector< Number > &W)
Number operator[](const size_type i) const
bool operator!=(const Vector< Number2 > &v) const
void load(Archive &ar, const unsigned int version)
void sadd(const Number s, const Vector< Number > &V)
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
Number operator()(const size_type i) const
real_type linfty_norm() const
bool is_non_negative() const
void equ(const Number a, const Vector< Number > &u)
void print(const char *format=0) const 1
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Vector< Number > & operator=(const Number s)
bool is_finite(const double x)
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
static ::ExceptionBase & ExcMessage(std::string arg1)
numbers::NumberTraits< Number >::real_type real_type
bool in_local_range(const size_type global_index) const
void scale(const Vector< Number > &scaling_factors)
Vector< Number > & operator+=(const Vector< Number > &V)
unsigned int global_dof_index
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
real_type lp_norm(const real_type p) const
void ratio(const Vector< Number > &a, const Vector< Number > &b) 1
Vector< Number > & operator-=(const Vector< Number > &V)
Vector< Number > & operator*=(const Number factor)
Number operator*(const Vector< Number2 > &V) const
void swap(Vector< Number > &u, Vector< Number > &v)
virtual void swap(Vector< Number > &v)
Vector< Number > & operator/=(const Number factor)
void block_write(std::ostream &out) const
IndexSet locally_owned_elements() const
void save(Archive &ar, const unsigned int version) const
bool operator==(const Vector< Number2 > &v) const
void compress(::VectorOperation::values operation=::VectorOperation::unknown) const
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
real_type norm_sqr() const
std_cxx11::shared_ptr< parallel::internal::TBBPartitioner > thread_loop_partitioner
real_type l2_norm() const
static ::ExceptionBase & ExcZero()
#define AssertIsFinite(number)
static const bool supports_distributed_data
Number mean_value() const