3 #ifndef DUNE_DENSEVECTOR_HH
4 #define DUNE_DENSEVECTOR_HH
17 template<
typename V>
class DenseVector;
54 return std::abs(c.real()) + std::abs(c.imag());
74 return c.real()*c.real() + c.imag()*c.imag();
81 template<class K, bool isInteger = std::numeric_limits<K>::is_integer>
110 return Sqrt<K>::sqrt(k);
119 template<
class C,
class T>
124 friend class
DenseIterator<const typename remove_const<C>::type, const typename remove_const<T>::type >;
144 : container_(&cont), position_(pos)
148 : container_(other.container_), position_(other.position_)
154 return position_ == other.position_ && container_ == other.container_;
160 return position_ == other.position_ && container_ == other.container_;
164 return container_->operator[](position_);
178 return container_->operator[](position_+i);
182 position_=position_+n;
187 assert(other.container_==container_);
188 return other.position_ - position_;
193 assert(other.container_==container_);
194 return other.position_ - position_;
200 return this->position_;
228 V & asImp() {
return static_cast<V&
>(*this); }
229 const V & asImp()
const {
return static_cast<const V&
>(*this); }
276 return asImp().vec_access(i);
281 return asImp().vec_access(i);
287 return asImp().vec_size();
367 template <
class Other>
377 template <
class Other>
387 template <
class Other>
395 template <
class Other>
435 template <
class Other>
440 if ((*
this)[i]!=y[i])
447 template <
class Other>
455 template <
class Other>
460 (*
this)[i] += a*y[i];
471 template<
class Other>
473 typedef typename PromotionTraits<field_type, typename DenseVector<Other>::field_type>::PromotedType PromotedType;
474 PromotedType result(0);
477 result += PromotedType((*
this)[i]*y[i]);
489 template<
class Other>
490 typename PromotionTraits<field_type,typename DenseVector<Other>::field_type>::PromotedType
dot(
const DenseVector<Other>& y)
const {
491 typedef typename PromotionTraits<field_type, typename DenseVector<Other>::field_type>::PromotedType PromotedType;
492 PromotedType result(0);
506 result += std::abs((*
this)[i]);
516 result += fvmeta::absreal((*
this)[i]);
525 result += fvmeta::abs2((*
this)[i]);
526 return fvmeta::sqrt(result);
534 result += fvmeta::abs2((*
this)[i]);
546 for (it = it + 1; it !=
end(); ++it)
547 max = std::max(max, std::abs(*it));
560 for (it = it + 1; it !=
end(); ++it)
561 max = std::max(max, fvmeta::absreal(*it));
591 std::ostream& operator<< (std::ostream& s, const DenseVector<V>& v)
594 s << ((i>0) ?
" " :
"") << v[i];
602 #endif // DUNE_DENSEVECTOR_HH