4 #ifndef DUNE_BVECTOR_HH
5 #define DUNE_BVECTOR_HH
12 #include <dune/common/static_assert.hh>
13 #include <dune/common/promotiontraits.hh>
14 #include <dune/common/dotproduct.hh>
15 #include <dune/common/ftraits.hh>
41 template<
class B,
class A=std::allocator<B> >
83 #ifdef DUNE_ISTL_WITH_CHECKING
84 if (this->
n!=y.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
86 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] += y[i];
93 #ifdef DUNE_ISTL_WITH_CHECKING
94 if (this->
n!=y.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
96 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] -= y[i];
103 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] *= k;
110 for (
size_type i=0; i<this->
n; ++i) (*
this)[i] /= k;
117 #ifdef DUNE_ISTL_WITH_CHECKING
118 if (this->
n!=y.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
132 template<
class OtherB,
class OtherA>
135 typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
137 #ifdef DUNE_ISTL_WITH_CHECKING
138 if (this->
n!=y.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
141 sum += PromotedType(((*
this)[i])*y[i]);
153 template<
class OtherB,
class OtherA>
156 typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
158 #ifdef DUNE_ISTL_WITH_CHECKING
159 if (this->
n!=y.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
161 for (
size_type i=0; i<this->
n; ++i) sum += ((*
this)[i]).
dot(y[i]);
168 typename FieldTraits<field_type>::real_type
one_norm ()
const
170 typename FieldTraits<field_type>::real_type sum=0;
171 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].one_norm();
178 typename FieldTraits<field_type>::real_type sum=0;
179 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].one_norm_real();
184 typename FieldTraits<field_type>::real_type
two_norm ()
const
186 typename FieldTraits<field_type>::real_type sum=0;
187 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].two_norm2();
192 typename FieldTraits<field_type>::real_type
two_norm2 ()
const
194 typename FieldTraits<field_type>::real_type sum=0;
195 for (
size_type i=0; i<this->
n; ++i) sum += (*
this)[i].two_norm2();
202 typename FieldTraits<field_type>::real_type max=0;
210 typename FieldTraits<field_type>::real_type max=0;
228 d += (*
this)[i].dim();
252 template<
class B,
class A=std::allocator<B> >
321 dune_static_assert( (std::numeric_limits<S>::is_integer),
322 "capacity must be an unsigned integral type (be aware, that this constructor does not set the default value!)" );
325 if(this->
n > capacity)
367 new (this->
p)B[capacity];
374 for(
size_type i=0; i < block_vector_unmanaged<B,A>::N(); ++i, ++from, ++to)
424 this->
reserve(size, copyOldValues);
523 return this->
operator=(static_cast<const BlockVector&>(a));
545 template<
class B,
class A>
556 template<
class K,
class A>
557 std::ostream& operator<< (std::ostream& s, const BlockVector<K, A>& v)
561 for (size_type i=0; i<v.size(); i++)
562 s << v[i] << std::endl;
583 template<
class B,
class A=std::allocator<B> >
650 #ifdef DUNE_ISTL_WITH_CHECKING
651 if (this->
n!=a.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
666 return this->
operator=(static_cast<const BlockVectorWindow&>(a));
721 template<
class B,
class A=std::allocator<B> >
762 #ifdef DUNE_ISTL_WITH_CHECKING
765 for (
size_type i=0; i<y.n; ++i) this->
operator[](y.j[i]) += y.p[i];
773 #ifdef DUNE_ISTL_WITH_CHECKING
776 for (
size_type i=0; i<y.n; ++i) this->
operator[](y.j[i]) -= y.p[i];
784 #ifdef DUNE_ISTL_WITH_CHECKING
787 for (
size_type i=0; i<y.n; ++i) (this->
operator[](y.j[i])).axpy(a,y.p[i]);
794 for (
size_type i=0; i<this->
n; ++i) (this->
p)[i] *= k;
801 for (
size_type i=0; i<this->
n; ++i) (this->
p)[i] /= k;
811 #ifdef DUNE_ISTL_WITH_CHECKING
813 DUNE_THROW(
ISTLError,
"index set mismatch");
817 sum += (this->
p)[i] * y[(this->
j)[i]];
825 typename FieldTraits<field_type>::real_type
one_norm ()
const
827 typename FieldTraits<field_type>::real_type sum=0;
828 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].one_norm();
835 typename FieldTraits<field_type>::real_type sum=0;
836 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].one_norm_real();
841 typename FieldTraits<field_type>::real_type
two_norm ()
const
843 typename FieldTraits<field_type>::real_type sum=0;
844 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].two_norm2();
849 typename FieldTraits<field_type>::real_type
two_norm2 ()
const
851 typename FieldTraits<field_type>::real_type sum=0;
852 for (
size_type i=0; i<this->
n; ++i) sum += (this->
p)[i].two_norm2();
859 typename FieldTraits<field_type>::real_type max=0;
867 typename FieldTraits<field_type>::real_type max=0;
886 d += (this->
p)[i].dim();
899 typename V::ConstIterator e=this->
end();
901 if (this->
find(y.j[i])==e)
924 template<
class B,
class A=std::allocator<B> >
994 #ifdef DUNE_ISTL_WITH_CHECKING
995 if (this->
n!=a.
N()) DUNE_THROW(
ISTLError,
"vector size mismatch");
1011 return this->
operator=(static_cast<const CompressedBlockVectorWindow&>(a));