Go to the documentation of this file.
3 #ifndef DUNE_DENSEVECTOR_HH
4 #define DUNE_DENSEVECTOR_HH
58 return abs(c.real()) + abs(c.imag());
78 return c.real()*c.real() + c.imag()*c.imag();
85 template<class K, bool isInteger = std::numeric_limits<K>::is_integer>
116 return Sqrt<K>::sqrt(k);
125 template<
class C,
class T,
class R =T&>
130 friend class
DenseIterator<const typename std::remove_const<C>::type, const typename std::remove_const<T>::type, typename const_reference<R>::type >;
132 typedef
DenseIterator<typename std::remove_const<C>::type, typename std::remove_const<T>::type, typename mutable_reference<R>::type >
MutableIterator;
133 typedef
DenseIterator<const typename std::remove_const<C>::type, const typename std::remove_const<T>::type, typename const_reference<R>::type >
ConstIterator;
148 : container_(0), position_()
152 : container_(&cont), position_(pos)
156 : container_(other.container_), position_(other.position_)
160 : container_(other.container_), position_(other.position_)
166 return position_ == other.position_ && container_ == other.container_;
172 return position_ == other.position_ && container_ == other.container_;
176 return container_->operator[](position_);
190 return container_->operator[](position_+i);
194 position_=position_+n;
199 assert(other.container_==container_);
205 assert(other.container_==container_);
212 return this->position_;
236 typedef DenseMatVecTraits<V> Traits;
240 V & asImp() {
return static_cast<V&
>(*this); }
241 const V & asImp()
const {
return static_cast<const V&
>(*this); }
299 return asImp().size();
379 template <
class Other>
389 template <
class Other>
399 template <
class Other>
407 template <
class Other>
423 template <
typename ValueType>
424 typename std::enable_if<
425 std::is_convertible<ValueType, value_type>::value,
445 template <
typename ValueType>
446 typename std::enable_if<
447 std::is_convertible<ValueType, value_type>::value,
467 template <
typename FieldType>
468 typename std::enable_if<
469 std::is_convertible<FieldType, field_type>::value,
489 template <
typename FieldType>
490 typename std::enable_if<
491 std::is_convertible<FieldType, field_type>::value,
503 template <
class Other>
508 if ((*
this)[i]!=y[i])
515 template <
class Other>
523 template <
class Other>
528 (*
this)[i] += a*y[i];
539 template<
class Other>
542 PromotedType result(0);
543 assert(y.size() ==
size());
545 result += PromotedType((*
this)[i]*y[i]);
557 template<
class Other>
560 PromotedType result(0);
561 assert(y.size() ==
size());
575 result += abs((*
this)[i]);
585 result += fvmeta::absreal((*
this)[i]);
594 result += fvmeta::abs2((*
this)[i]);
595 return fvmeta::sqrt(result);
603 result += fvmeta::abs2((*
this)[i]);
609 typename std::enable_if<!has_nan<vt>::value,
int>::type = 0>
616 for (
auto const &x : *
this) {
617 real_type
const a = abs(x);
625 typename std::enable_if<!has_nan<vt>::value,
int>::type = 0>
631 for (
auto const &x : *
this) {
632 real_type
const a = fvmeta::absreal(x);
640 typename std::enable_if<has_nan<vt>::value,
int>::type = 0>
648 for (
auto const &x : *
this) {
649 real_type
const a = abs(x);
659 typename std::enable_if<has_nan<vt>::value,
int>::type = 0>
666 for (
auto const &x : *
this) {
667 real_type
const a = fvmeta::absreal(x);
703 s << ((i>0) ?
" " :
"") << v[i];
711 #endif // DUNE_DENSEVECTOR_HH
value_type & operator[](size_type i)
random access
Definition: densevector.hh:286
DenseIterator(C &cont, SizeType pos)
Definition: densevector.hh:151
derived_type operator-(const DenseVector< Other > &b) const
Binary vector subtraction.
Definition: densevector.hh:408
size_type dim() const
dimension of the vector space
Definition: densevector.hh:684
Provides the functions dot(a,b) := and dotT(a,b) := .
FieldTraits< value_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: densevector.hh:590
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & operator/=(const FieldType &kk)
vector space division by scalar
Definition: densevector.hh:494
C::size_type SizeType
The type to index the underlying container.
Definition: densevector.hh:144
FieldTraits< vt >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: densevector.hh:626
DifferenceType distanceTo(DenseIterator< const typename std::remove_const< C >::type, const typename std::remove_const< T >::type > other) const
Definition: densevector.hh:197
Dune namespace.
Definition: alignedallocator.hh:9
PromotionTraits< field_type, typename DenseVector< Other >::field_type >::PromotedType operator*(const DenseVector< Other > &y) const
indefinite vector dot product which corresponds to Petsc's VecTDot
Definition: densevector.hh:540
ConstIterator end() const
end ConstIterator
Definition: densevector.hh:351
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: densevector.hh:678
bool equals(const MutableIterator &other) const
Definition: densevector.hh:164
Traits::value_type value_type
export the type representing the field
Definition: densevector.hh:257
Implements a generic iterator class for writing stl conformant iterators.
ConstIterator find(size_type i) const
return iterator to given element or end()
Definition: densevector.hh:371
ConstIterator begin() const
begin ConstIterator
Definition: densevector.hh:345
void decrement()
Definition: densevector.hh:184
DenseIterator(const ConstIterator &other)
Definition: densevector.hh:159
ConstIterator beforeEnd() const
Definition: densevector.hh:358
derived_type & axpy(const field_type &a, const DenseVector< Other > &y)
vector space axpy operation ( *this += a y )
Definition: densevector.hh:524
FieldTraits< value_type >::field_type field_type
export the type representing the field
Definition: densevector.hh:260
derived_type & operator+=(const DenseVector< Other > &y)
vector space addition
Definition: densevector.hh:380
DifferenceType distanceTo(DenseIterator< typename std::remove_const< C >::type, typename std::remove_const< T >::type > other) const
Definition: densevector.hh:203
ConstIterator beforeBegin() const
Definition: densevector.hh:365
void increment()
Definition: densevector.hh:179
SizeType index() const
return index
Definition: densevector.hh:210
R elementAt(DifferenceType i) const
Definition: densevector.hh:189
Traits::value_type block_type
export the type representing the components
Definition: densevector.hh:263
Base::value_type value_type
Definition: dynvector.hh:63
T real_type
export the type representing the real type of the field
Definition: ftraits.hh:28
bool operator==(const DenseVector< Other > &y) const
Binary vector comparison.
Definition: densevector.hh:504
Generic iterator class for dense vector and matrix implementations.
Definition: densevector.hh:126
Iterator begin()
begin iterator
Definition: densevector.hh:308
@ blocklevel
The number of block levels we contain.
Definition: densevector.hh:271
FieldTraits< value_type >::real_type two_norm2() const
square of two norm (sum over squared values of entries), need for block recursion
Definition: densevector.hh:599
Documentation of the traits classes you need to write for each implementation of DenseVector or Dense...
FieldTraits< value_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition: densevector.hh:581
FieldTraits< typename DenseMatVecTraits< V >::value_type >::field_type field_type
Definition: densevector.hh:24
Type traits to determine the type of reals (when working with complex numbers)
Traits::derived_type derived_type
type of derived vector class
Definition: densevector.hh:254
Iterator end()
end iterator
Definition: densevector.hh:314
Macro for wrapping boundary checks.
Base::size_type size_type
Definition: dynvector.hh:62
Iterator find(size_type i)
return iterator to given element or end()
Definition: densevector.hh:334
FieldTraits< value_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition: densevector.hh:571
Compute type of the result of an arithmetic operation involving two different number types.
Iterator iterator
typedef for stl compliant access
Definition: densevector.hh:305
Definition: ftraits.hh:23
std::ostream & operator<<(std::ostream &s, const bigunsignedint< k > &x)
Definition: bigunsignedint.hh:272
DenseIterator< const DenseVector, const value_type > ConstIterator
ConstIterator class for sequential access.
Definition: densevector.hh:340
auto dot(const A &a, const B &b) -> typename std::enable_if<!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,...
Definition: dotproduct.hh:40
derived_type & operator-=(const DenseVector< Other > &y)
vector space subtraction
Definition: densevector.hh:390
PromotionTraits< field_type, typename DenseVector< Other >::field_type >::PromotedType dot(const DenseVector< Other > &y) const
vector dot product which corresponds to Petsc's VecDot
Definition: densevector.hh:558
FieldTraits< typename DenseMatVecTraits< V >::value_type >::real_type real_type
Definition: densevector.hh:25
Interface for a class of dense vectors over a given field.
Definition: densevector.hh:19
T field_type
export the type representing the field
Definition: ftraits.hh:26
Compute type of the result of an arithmetic operation involving two different number types.
Definition: promotiontraits.hh:24
#define DUNE_ASSERT_BOUNDS(cond)
If DUNE_CHECK_BOUNDS is defined: check if condition cond holds; otherwise, do nothing.
Definition: boundschecking.hh:28
derived_type operator+(const DenseVector< Other > &b) const
Binary vector addition.
Definition: densevector.hh:400
Traits::size_type size_type
The type used for the index access and size operation.
Definition: densevector.hh:266
void advance(DifferenceType n)
Definition: densevector.hh:193
bool operator!=(const DenseVector< Other > &y) const
Binary vector incomparison.
Definition: densevector.hh:516
DenseIterator< DenseVector, value_type > Iterator
Iterator class for sequential access.
Definition: densevector.hh:303
derived_type & operator=(const value_type &k)
Assignment operator for scalar.
Definition: densevector.hh:276
R dereference() const
Definition: densevector.hh:175
Iterator beforeBegin()
Definition: densevector.hh:328
ConstIterator const_iterator
typedef for stl compliant access
Definition: densevector.hh:342
size_type size() const
size method
Definition: densevector.hh:297
bool equals(const ConstIterator &other) const
Definition: densevector.hh:170
FieldTraits< vt >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition: densevector.hh:610
std::ptrdiff_t DifferenceType
The type of the difference between two positions.
Definition: densevector.hh:139
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:427
Iterator beforeEnd()
Definition: densevector.hh:321
DenseIterator(const MutableIterator &other)
Definition: densevector.hh:155
get the 'mutable' version of a reference to a const object
Definition: genericiterator.hh:113
constexpr DenseVector()
Definition: densevector.hh:248
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & operator*=(const FieldType &kk)
vector space multiplication with scalar
Definition: densevector.hh:472