4#ifndef DUNE_ISTL_BVECTOR_HH
5#define DUNE_ISTL_BVECTOR_HH
12#include <dune/common/promotiontraits.hh>
13#include <dune/common/dotproduct.hh>
14#include <dune/common/ftraits.hh>
40 template<
class B,
class A=std::allocator<B> >
88#ifdef DUNE_ISTL_WITH_CHECKING
91 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] +=
y[i];
98#ifdef DUNE_ISTL_WITH_CHECKING
101 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] -=
y[i];
108 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] *= k;
115 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] /= k;
122#ifdef DUNE_ISTL_WITH_CHECKING
125 for (
size_type i=0; i<this->
n; ++i) (*
this)[i].axpy(a,
y[i]);
137 template<
class OtherB,
class OtherA>
142#ifdef DUNE_ISTL_WITH_CHECKING
158 template<
class OtherB,
class OtherA>
163#ifdef DUNE_ISTL_WITH_CHECKING
166 for (
size_type i=0; i<this->
n; ++i) sum += ((*
this)[i]).dot(
y[i]);
176 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].one_norm();
184 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].one_norm_real();
192 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].two_norm2();
200 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].two_norm2();
206 typename std::enable_if<!has_nan<ft>::value,
int>::type = 0>
212 for (
auto const &x : *
this) {
213 real_type
const a = x.infinity_norm();
221 typename std::enable_if<!has_nan<ft>::value,
int>::type = 0>
227 for (
auto const &x : *
this) {
228 real_type
const a = x.infinity_norm_real();
236 typename std::enable_if<has_nan<ft>::value,
int>::type = 0>
243 for (
auto const &x : *
this) {
244 real_type
const a = x.infinity_norm();
254 typename std::enable_if<has_nan<ft>::value,
int>::type = 0>
261 for (
auto const &x : *
this) {
262 real_type
const a = x.infinity_norm_real();
283 d += (*
this)[i].dim();
307 template<
class B,
class A=std::allocator<B> >
372 std::copy_n(
l.begin(),
l.size(),
this->p);
396 static_assert(std::numeric_limits<S>::is_integer,
397 "capacity must be an unsigned integral type (be aware, that this constructor does not set the default value!)" );
400 if(this->
n > capacity)
524 for (size_type i=0; i<this->
n; i++) this->
p[i]=a.
p[i];
548 for (size_type i=0; i<this->
n; i++) this->
p[i]=a.
p[i];
620 template<
class B,
class A>
631 template<
class K,
class A>
636 for (size_type i=0; i<v.size(); i++)
637 s << v[i] << std::endl;
658 template<
class B,
class A=std::allocator<B> >
725#ifdef DUNE_ISTL_WITH_CHECKING
796 template<
class B,
class A=std::allocator<B> >
837#ifdef DUNE_ISTL_WITH_CHECKING
840 for (
size_type i=0; i<
y.n; ++i) this->
operator[](y.j[i]) +=
y.p[i];
848#ifdef DUNE_ISTL_WITH_CHECKING
851 for (
size_type i=0; i<
y.n; ++i) this->
operator[](y.j[i]) -=
y.p[i];
859#ifdef DUNE_ISTL_WITH_CHECKING
862 for (
size_type i=0; i<
y.n; ++i) (this->
operator[](y.j[i])).axpy(a,
y.p[i]);
869 for (
size_type i=0; i<this->
n; ++i) (this->
p)[i] *= k;
876 for (
size_type i=0; i<this->
n; ++i) (this->
p)[i] /= k;
886#ifdef DUNE_ISTL_WITH_CHECKING
892 sum += (this->
p)[i] *
y[(this->
j)[i]];
903 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].one_norm();
911 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].one_norm_real();
919 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].two_norm2();
927 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].two_norm2();
933 typename std::enable_if<!has_nan<ft>::value,
int>::type = 0>
939 for (
auto const &x : *
this) {
940 real_type
const a = x.infinity_norm();
948 typename std::enable_if<!has_nan<ft>::value,
int>::type = 0>
954 for (
auto const &x : *
this) {
955 real_type
const a = x.infinity_norm_real();
963 typename std::enable_if<has_nan<ft>::value,
int>::type = 0>
970 for (
auto const &x : *
this) {
971 real_type
const a = x.infinity_norm();
981 typename std::enable_if<has_nan<ft>::value,
int>::type = 0>
988 for (
auto const &x : *
this) {
989 real_type
const a = x.infinity_norm_real();
1010 d += (this->
p)[i].dim();
1023 typename V::ConstIterator
e=this->
end();
1024 for (size_type i=0; i<
y.n; i++)
1025 if (this->
find(y.j[i])==
e)
1048 template<
class B,
class A=std::allocator<B> >
1118#ifdef DUNE_ISTL_WITH_CHECKING
Implements several basic array containers.
Definition basearray.hh:19
std::ostream & operator<<(std::ostream &s, const BlockVector< K, A > &v)
Send BlockVector to an output stream.
Definition bvector.hh:632
A simple array container for objects of type B.
Definition basearray.hh:45
size_type n
Definition basearray.hh:254
B * p
Definition basearray.hh:255
size_type size() const
number of blocks in the array (are of size 1 here)
Definition basearray.hh:240
Iterator implementation class
Definition basearray.hh:84
A simple array container with non-consecutive index set.
Definition basearray.hh:548
B * p
Definition basearray.hh:768
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition basearray.hh:707
size_type n
Definition basearray.hh:767
size_type * j
Definition basearray.hh:769
iterator end()
end iterator
Definition basearray.hh:687
iterator class for sequential access
Definition basearray.hh:586
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
An unmanaged vector of blocks.
Definition bvector.hh:42
block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition bvector.hh:106
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition bvector.hh:189
A::size_type size_type
The size type for the index access.
Definition bvector.hh:57
block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition bvector.hh:289
FieldTraits< field_type >::real_type two_norm2() const
Square of the two-norm (the sum over the squared values of the entries)
Definition bvector.hh:197
base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition bvector.hh:60
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition bvector.hh:207
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition bvector.hh:181
block_vector_unmanaged & operator-=(const block_vector_unmanaged &y)
vector space subtraction
Definition bvector.hh:96
B::field_type field_type
export the type representing the field
Definition bvector.hh:48
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition bvector.hh:222
base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition bvector.hh:63
block_vector_unmanaged & axpy(const field_type &a, const block_vector_unmanaged &y)
vector space axpy operation
Definition bvector.hh:120
block_vector_unmanaged & operator+=(const block_vector_unmanaged &y)
vector space addition
Definition bvector.hh:86
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition bvector.hh:273
size_type dim() const
dimension of the vector space
Definition bvector.hh:279
B value_type
for STL compatibility
Definition bvector.hh:66
block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition bvector.hh:113
PromotionTraits< field_type, typenameOtherB::field_type >::PromotedType dot(const block_vector_unmanaged< OtherB, OtherA > &y) const
vector dot product which corresponds to Petsc's VecDot
Definition bvector.hh:159
const B & const_reference
Type used for const references.
Definition bvector.hh:72
B & reference
Type used for references.
Definition bvector.hh:69
block_vector_unmanaged & operator=(const field_type &k)
Assignment from a scalar.
Definition bvector.hh:77
PromotionTraits< field_type, typenameOtherB::field_type >::PromotedType operator*(const block_vector_unmanaged< OtherB, OtherA > &y) const
indefinite vector dot product which corresponds to Petsc's VecTDot
Definition bvector.hh:138
B block_type
export the type representing the components
Definition bvector.hh:51
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition bvector.hh:173
A allocator_type
export the allocator type
Definition bvector.hh:54
A vector of blocks with memory management.
Definition bvector.hh:309
BlockVector()
makes empty vector
Definition bvector.hh:341
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition bvector.hh:336
void resize(size_type size, bool copyOldValues=true)
Resize the vector.
Definition bvector.hh:495
BlockVector & operator=(const BlockVector &a)
assignment
Definition bvector.hh:563
BlockVector(const block_vector_unmanaged< B, A > &_a)
construct from base class object
Definition bvector.hh:528
BlockVector(size_type _n)
make vector with _n components
Definition bvector.hh:346
void reserve(size_type capacity, bool copyOldValues=true)
Reserve space.
Definition bvector.hh:433
A allocator_type
export the allocator type
Definition bvector.hh:321
BlockVector(const BlockVector &a)
copy constructor
Definition bvector.hh:507
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition bvector.hh:333
A allocator_
Definition bvector.hh:611
@ blocklevel
The number of blocklevel we contain.
Definition bvector.hh:329
A::size_type size_type
The type for the index access.
Definition bvector.hh:324
~BlockVector()
free dynamic memory
Definition bvector.hh:552
BlockVector(std::initializer_list< B > const &l)
Construct from a std::initializer_list.
Definition bvector.hh:363
size_type capacity() const
Get the capacity of the vector.
Definition bvector.hh:476
B::field_type field_type
export the type representing the field
Definition bvector.hh:315
size_type capacity_
Definition bvector.hh:609
BlockVector(size_type _n, S _capacity)
Make vector with _n components but preallocating capacity components.
Definition bvector.hh:394
B block_type
export the type representing the components
Definition bvector.hh:318
FieldTraits< B >::real_type real_type
Definition bvector.hh:624
FieldTraits< B >::field_type field_type
Definition bvector.hh:623
Definition bvector.hh:660
B * getptr()
get pointer
Definition bvector.hh:774
A allocator_type
export the allocator type
Definition bvector.hh:672
BlockVectorWindow & operator=(const BlockVectorWindow &a)
assignment
Definition bvector.hh:722
BlockVectorWindow(const BlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition bvector.hh:703
void set(size_type _n, B *_p)
set size and pointer
Definition bvector.hh:755
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition bvector.hh:684
size_type getsize()
get size
Definition bvector.hh:780
@ blocklevel
The number of blocklevels we contain.
Definition bvector.hh:680
B::field_type field_type
export the type representing the field
Definition bvector.hh:666
void setsize(size_type _n)
set size only
Definition bvector.hh:762
BlockVectorWindow(B *_p, size_type _n)
make array from given pointer and size
Definition bvector.hh:696
B block_type
export the type representing the components
Definition bvector.hh:669
BlockVectorWindow()
makes empty array
Definition bvector.hh:692
A::size_type size_type
The type for the index access.
Definition bvector.hh:675
BlockVectorWindow(const block_vector_unmanaged< B, A > &_a)
construct from base class object with reference semantics!
Definition bvector.hh:710
void setptr(B *_p)
set pointer only
Definition bvector.hh:768
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition bvector.hh:687
Definition bvector.hh:798
compressed_block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition bvector.hh:867
FieldTraits< field_type >::real_type two_norm2() const
Square of the two-norm (the sum over the squared values of the entries)
Definition bvector.hh:924
compressed_block_vector_unmanaged & operator-=(const V &y)
vector space subtraction
Definition bvector.hh:846
A::size_type size_type
The type for the index access.
Definition bvector.hh:819
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition bvector.hh:1000
compressed_block_vector_unmanaged & operator=(const field_type &k)
Definition bvector.hh:823
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition bvector.hh:908
field_type operator*(const compressed_block_vector_unmanaged &y) const
scalar product
Definition bvector.hh:884
B block_type
export the type representing the components
Definition bvector.hh:807
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition bvector.hh:934
bool includesindexset(const V &y)
return true if index sets coincide
Definition bvector.hh:1021
A allocator_type
export the allocator type
Definition bvector.hh:810
compressed_block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition bvector.hh:874
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition bvector.hh:900
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition bvector.hh:949
B::field_type field_type
export the type representing the field
Definition bvector.hh:804
size_type dim() const
dimension of the vector space
Definition bvector.hh:1006
compressed_block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition bvector.hh:1016
compressed_block_vector_unmanaged & axpy(const field_type &a, const V &y)
vector space axpy operation
Definition bvector.hh:857
compressed_base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition bvector.hh:816
compressed_block_vector_unmanaged & operator+=(const V &y)
vector space addition
Definition bvector.hh:835
compressed_base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition bvector.hh:813
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition bvector.hh:916
Definition bvector.hh:1050
compressed_block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition bvector.hh:1077
const B * getptr() const
get pointer
Definition bvector.hh:1187
CompressedBlockVectorWindow(const CompressedBlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition bvector.hh:1094
void set(size_type _n, B *_p, size_type *_j)
set size and pointer
Definition bvector.hh:1149
size_type * getindexptr()
get pointer
Definition bvector.hh:1181
void setsize(size_type _n)
set size only
Definition bvector.hh:1157
@ blocklevel
The number of block level this vector contains.
Definition bvector.hh:1070
const size_type * getindexptr() const
get pointer
Definition bvector.hh:1193
compressed_block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition bvector.hh:1074
CompressedBlockVectorWindow(B *_p, size_type *_j, size_type _n)
make array from given pointers and size
Definition bvector.hh:1086
A::size_type size_type
The type for the index access.
Definition bvector.hh:1065
B::field_type field_type
export the type representing the field
Definition bvector.hh:1056
A allocator_type
export the allocator type
Definition bvector.hh:1062
B block_type
export the type representing the components
Definition bvector.hh:1059
CompressedBlockVectorWindow & operator=(const CompressedBlockVectorWindow &a)
assignment
Definition bvector.hh:1115
void setptr(B *_p)
set pointer only
Definition bvector.hh:1163
B * getptr()
get pointer
Definition bvector.hh:1175
CompressedBlockVectorWindow()
makes empty array
Definition bvector.hh:1082
size_type getsize() const
get size
Definition bvector.hh:1198
void setindexptr(size_type *_j)
set pointer only
Definition bvector.hh:1169
CompressedBlockVectorWindow(const compressed_block_vector_unmanaged< B, A > &_a)
construct from base class object with reference semantics!
Definition bvector.hh:1102
derive error class from the base class in common
Definition istlexception.hh:16