Dune Core Modules (2.5.0)

bvector.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_ISTL_BVECTOR_HH
5#define DUNE_ISTL_BVECTOR_HH
6
7#include <cmath>
8#include <complex>
9#include <memory>
10#include <limits>
11
15
16#include "istlexception.hh"
17#include "basearray.hh"
18
26namespace Dune {
27
28 template<class B, class A=std::allocator<B> >
29 class BlockVectorWindow;
30
44 template<class B, class A=std::allocator<B> >
46 {
47 public:
48
49 //===== type definitions and constants
50
52 typedef typename B::field_type field_type;
53
55 typedef B block_type;
56
58 typedef A allocator_type;
59
61 typedef typename A::size_type size_type;
62
65
68
70 typedef B value_type;
71
73 typedef B& reference;
74
76 typedef const B& const_reference;
77
78 //===== assignment from scalar
80
82 {
83 for (size_type i=0; i<this->n; i++)
84 (*this)[i] = k;
85 return *this;
86 }
87
88 //===== vector space arithmetic
91 {
92#ifdef DUNE_ISTL_WITH_CHECKING
93 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
94#endif
95 for (size_type i=0; i<this->n; ++i) (*this)[i] += y[i];
96 return *this;
97 }
98
101 {
102#ifdef DUNE_ISTL_WITH_CHECKING
103 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
104#endif
105 for (size_type i=0; i<this->n; ++i) (*this)[i] -= y[i];
106 return *this;
107 }
108
111 {
112 for (size_type i=0; i<this->n; ++i) (*this)[i] *= k;
113 return *this;
114 }
115
118 {
119 for (size_type i=0; i<this->n; ++i) (*this)[i] /= k;
120 return *this;
121 }
122
125 {
126#ifdef DUNE_ISTL_WITH_CHECKING
127 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
128#endif
129 for (size_type i=0; i<this->n; ++i) (*this)[i].axpy(a,y[i]);
130 return *this;
131 }
132
133
141 template<class OtherB, class OtherA>
142 typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType operator* (const block_vector_unmanaged<OtherB,OtherA>& y) const
143 {
144 typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
145 PromotedType sum(0);
146#ifdef DUNE_ISTL_WITH_CHECKING
147 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
148#endif
149 for (size_type i=0; i<this->n; ++i) {
150 sum += PromotedType(((*this)[i])*y[i]);
151 }
152 return sum;
153 }
154
162 template<class OtherB, class OtherA>
163 typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType dot(const block_vector_unmanaged<OtherB,OtherA>& y) const
164 {
165 typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
166 PromotedType sum(0);
167#ifdef DUNE_ISTL_WITH_CHECKING
168 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
169#endif
170 for (size_type i=0; i<this->n; ++i) sum += ((*this)[i]).dot(y[i]);
171 return sum;
172 }
173
174 //===== norms
175
177 typename FieldTraits<field_type>::real_type one_norm () const
178 {
179 typename FieldTraits<field_type>::real_type sum=0;
180 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm();
181 return sum;
182 }
183
185 typename FieldTraits<field_type>::real_type one_norm_real () const
186 {
187 typename FieldTraits<field_type>::real_type sum=0;
188 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm_real();
189 return sum;
190 }
191
193 typename FieldTraits<field_type>::real_type two_norm () const
194 {
195 typename FieldTraits<field_type>::real_type sum=0;
196 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
197 return sqrt(sum);
198 }
199
201 typename FieldTraits<field_type>::real_type two_norm2 () const
202 {
203 typename FieldTraits<field_type>::real_type sum=0;
204 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
205 return sum;
206 }
207
209 template <typename ft = field_type,
210 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
211 typename FieldTraits<ft>::real_type infinity_norm() const {
212 using real_type = typename FieldTraits<ft>::real_type;
213 using std::max;
214
215 real_type norm = 0;
216 for (auto const &x : *this) {
217 real_type const a = x.infinity_norm();
218 norm = max(a, norm);
219 }
220 return norm;
221 }
222
224 template <typename ft = field_type,
225 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
226 typename FieldTraits<ft>::real_type infinity_norm_real() const {
227 using real_type = typename FieldTraits<ft>::real_type;
228 using std::max;
229
230 real_type norm = 0;
231 for (auto const &x : *this) {
232 real_type const a = x.infinity_norm_real();
233 norm = max(a, norm);
234 }
235 return norm;
236 }
237
239 template <typename ft = field_type,
240 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
241 typename FieldTraits<ft>::real_type infinity_norm() const {
242 using real_type = typename FieldTraits<ft>::real_type;
243 using std::max;
244
245 real_type norm = 0;
246 real_type isNaN = 1;
247 for (auto const &x : *this) {
248 real_type const a = x.infinity_norm();
249 norm = max(a, norm);
250 isNaN += a;
251 }
252 isNaN /= isNaN;
253 return norm * isNaN;
254 }
255
257 template <typename ft = field_type,
258 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
259 typename FieldTraits<ft>::real_type infinity_norm_real() const {
260 using real_type = typename FieldTraits<ft>::real_type;
261 using std::max;
262
263 real_type norm = 0;
264 real_type isNaN = 1;
265 for (auto const &x : *this) {
266 real_type const a = x.infinity_norm_real();
267 norm = max(a, norm);
268 isNaN += a;
269 }
270 isNaN /= isNaN;
271 return norm * isNaN;
272 }
273
274 //===== sizes
275
277 size_type N () const
278 {
279 return this->n;
280 }
281
283 size_type dim () const
284 {
285 size_type d=0;
286 for (size_type i=0; i<this->n; i++)
287 d += (*this)[i].dim();
288 return d;
289 }
290
291 protected:
294 { }
295 };
296
311 template<class B, class A=std::allocator<B> >
313 {
314 public:
315
316 //===== type definitions and constants
317
319 typedef typename B::field_type field_type;
320
322 typedef B block_type;
323
325 typedef A allocator_type;
326
328 typedef typename A::size_type size_type;
329
331 enum {
333 blocklevel = B::blocklevel+1
334 };
335
338
341
342 //===== constructors and such
343
346 capacity_(0)
347 {}
348
350 explicit BlockVector (size_type _n)
351 {
352 this->n = _n;
353 capacity_ = _n;
354 if (capacity_>0) {
355 this->p = this->allocator_.allocate(capacity_);
356 // actually construct the objects
357 new(this->p)B[capacity_];
358 } else
359 {
360 this->p = 0;
361 this->n = 0;
362 capacity_ = 0;
363 }
364 }
365
367 BlockVector (std::initializer_list<B> const &l)
368 {
369 this->n = l.size();
370 capacity_ = l.size();
371 if (capacity_>0) {
372 this->p = this->allocator_.allocate(capacity_);
373 // actually construct the objects
374 new(this->p)B[capacity_];
375
376 std::copy_n(l.begin(), l.size(), this->p);
377 } else
378 {
379 this->p = 0;
380 this->n = 0;
381 capacity_ = 0;
382 }
383 }
384
385
397 template<typename S>
398 BlockVector (size_type _n, S _capacity)
399 {
400 static_assert(std::numeric_limits<S>::is_integer,
401 "capacity must be an unsigned integral type (be aware, that this constructor does not set the default value!)" );
402 size_type capacity = _capacity;
403 this->n = _n;
404 if(this->n > capacity)
405 capacity_ = _n;
406 else
407 capacity_ = capacity;
408
409 if (capacity_>0) {
410 this->p = this->allocator_.allocate(capacity_);
411 new (this->p)B[capacity_];
412 } else
413 {
414 this->p = 0;
415 this->n = 0;
416 capacity_ = 0;
417 }
418 }
419
420
437 void reserve(size_type capacity, bool copyOldValues=true)
438 {
439 if(capacity >= block_vector_unmanaged<B,A>::N() && capacity != capacity_) {
440 // save the old data
441 B* pold = this->p;
442
443 if(capacity>0) {
444 // create new array with capacity
445 this->p = this->allocator_.allocate(capacity);
446 new (this->p)B[capacity];
447
448 if(copyOldValues) {
449 // copy the old values
450 B* to = this->p;
451 B* from = pold;
452
453 for(size_type i=0; i < block_vector_unmanaged<B,A>::N(); ++i, ++from, ++to)
454 *to = *from;
455 }
456 if(capacity_ > 0) {
457 // Destruct old objects and free memory
458 int i=capacity_;
459 while (i)
460 pold[--i].~B();
461 this->allocator_.deallocate(pold,capacity_);
462 }
463 }else{
464 if(capacity_ > 0)
465 // free old data
466 this->p = 0;
467 capacity_ = 0;
468 }
469
470 capacity_ = capacity;
471 }
472 }
473
481 {
482 return capacity_;
483 }
484
499 void resize(size_type size, bool copyOldValues=true)
500 {
502 if(capacity_ < size)
503 this->reserve(size, copyOldValues);
504 this->n = size;
505 }
506
507
508
509
513 {
514 // allocate memory with same size as a
515 this->n = a.n;
516 capacity_ = a.capacity_;
517
518 if (capacity_>0) {
519 this->p = this->allocator_.allocate(capacity_);
520 new (this->p)B[capacity_];
521 } else
522 {
523 this->n = 0;
524 this->p = 0;
525 }
526
527 // and copy elements
528 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
529 }
530
533 {
534 if (capacity_>0) {
535 int i=capacity_;
536 while (i)
537 this->p[--i].~B();
538 this->allocator_.deallocate(this->p,capacity_);
539 }
540 }
541
544 {
545 if (&a!=this) // check if this and a are different objects
546 {
547 // adjust size of vector
548 if (capacity_!=a.capacity_) // check if size is different
549 {
550 if (capacity_>0) {
551 int i=capacity_;
552 while (i)
553 this->p[--i].~B();
554 this->allocator_.deallocate(this->p,capacity_); // free old memory
555 }
556 capacity_ = a.capacity_;
557 if (capacity_>0) {
558 this->p = this->allocator_.allocate(capacity_);
559 new (this->p)B[capacity_];
560 } else
561 {
562 this->p = 0;
563 capacity_ = 0;
564 }
565 }
566 this->n = a.n;
567 // copy data
568 for (size_type i=0; i<this->n; i++)
569 this->p[i]=a.p[i];
570 }
571 return *this;
572 }
573
576 {
577 // forward to operator= in base class
578 (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
579 return *this;
580 }
581
583 template<class OtherAlloc>
585 {
586 resize(other.size());
587 for(std::size_t i=0; i<other.size(); ++i)
588 (*this)[i] = other[i];
589 return *this;
590 }
591
592 protected:
593 size_type capacity_;
594
595 A allocator_;
596
597 };
598
604 template<class B, class A>
605 struct FieldTraits< BlockVector<B, A> >
606 {
607 typedef typename FieldTraits<B>::field_type field_type;
608 typedef typename FieldTraits<B>::real_type real_type;
609 };
615 template<class K, class A>
616 std::ostream& operator<< (std::ostream& s, const BlockVector<K, A>& v)
617 {
618 typedef typename BlockVector<K, A>::size_type size_type;
619
620 for (size_type i=0; i<v.size(); i++)
621 s << v[i] << std::endl;
622
623 return s;
624 }
625
644#ifndef DOXYGEN
645 template<class B, class A>
646#else
647 template<class B, class A=std::allocator<B> >
648#endif
650 {
651 public:
652
653 //===== type definitions and constants
654
656 typedef typename B::field_type field_type;
657
659 typedef B block_type;
660
662 typedef A allocator_type;
663
665 typedef typename A::size_type size_type;
666
668 enum {
670 blocklevel = B::blocklevel+1
671 };
672
675
678
679
680 //===== constructors and such
683 { }
684
687 {
688 this->n = _n;
689 this->p = _p;
690 }
691
694 {
695 this->n = a.n;
696 this->p = a.p;
697 }
698
701 {
702 // check correct size
703#ifdef DUNE_ISTL_WITH_CHECKING
704 if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
705#endif
706
707 if (&a!=this) // check if this and a are different objects
708 {
709 // copy data
710 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
711 }
712 return *this;
713 }
714
717 {
718 (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
719 return *this;
720 }
721
722
723 //===== window manipulation methods
724
726 void set (size_type _n, B* _p)
727 {
728 this->n = _n;
729 this->p = _p;
730 }
731
734 {
735 this->n = _n;
736 }
737
739 void setptr (B* _p)
740 {
741 this->p = _p;
742 }
743
745 B* getptr ()
746 {
747 return this->p;
748 }
749
752 {
753 return this->n;
754 }
755 };
756
757
758
769 template<class B, class A=std::allocator<B> >
771 {
772 public:
773
774 //===== type definitions and constants
775
777 typedef typename B::field_type field_type;
778
780 typedef B block_type;
781
783 typedef A allocator_type;
784
787
790
792 typedef typename A::size_type size_type;
793
794 //===== assignment from scalar
795
797 {
798 for (size_type i=0; i<this->n; i++)
799 (this->p)[i] = k;
800 return *this;
801 }
802
803
804 //===== vector space arithmetic
805
807 template<class V>
809 {
810#ifdef DUNE_ISTL_WITH_CHECKING
811 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
812#endif
813 for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) += y.p[i];
814 return *this;
815 }
816
818 template<class V>
820 {
821#ifdef DUNE_ISTL_WITH_CHECKING
822 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
823#endif
824 for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) -= y.p[i];
825 return *this;
826 }
827
829 template<class V>
831 {
832#ifdef DUNE_ISTL_WITH_CHECKING
833 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
834#endif
835 for (size_type i=0; i<y.n; ++i) (this->operator[](y.j[i])).axpy(a,y.p[i]);
836 return *this;
837 }
838
841 {
842 for (size_type i=0; i<this->n; ++i) (this->p)[i] *= k;
843 return *this;
844 }
845
848 {
849 for (size_type i=0; i<this->n; ++i) (this->p)[i] /= k;
850 return *this;
851 }
852
853
854 //===== Euclidean scalar product
855
858 {
859#ifdef DUNE_ISTL_WITH_CHECKING
860 if (!includesindexset(y) || !y.includesindexset(*this) )
861 DUNE_THROW(ISTLError,"index set mismatch");
862#endif
863 field_type sum=0;
864 for (size_type i=0; i<this->n; ++i)
865 sum += (this->p)[i] * y[(this->j)[i]];
866 return sum;
867 }
868
869
870 //===== norms
871
873 typename FieldTraits<field_type>::real_type one_norm () const
874 {
875 typename FieldTraits<field_type>::real_type sum=0;
876 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm();
877 return sum;
878 }
879
881 typename FieldTraits<field_type>::real_type one_norm_real () const
882 {
883 typename FieldTraits<field_type>::real_type sum=0;
884 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm_real();
885 return sum;
886 }
887
889 typename FieldTraits<field_type>::real_type two_norm () const
890 {
891 typename FieldTraits<field_type>::real_type sum=0;
892 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
893 return sqrt(sum);
894 }
895
897 typename FieldTraits<field_type>::real_type two_norm2 () const
898 {
899 typename FieldTraits<field_type>::real_type sum=0;
900 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
901 return sum;
902 }
903
905 template <typename ft = field_type,
906 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
907 typename FieldTraits<ft>::real_type infinity_norm() const {
908 using real_type = typename FieldTraits<ft>::real_type;
909 using std::max;
910
911 real_type norm = 0;
912 for (auto const &x : *this) {
913 real_type const a = x.infinity_norm();
914 norm = max(a, norm);
915 }
916 return norm;
917 }
918
920 template <typename ft = field_type,
921 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
922 typename FieldTraits<ft>::real_type infinity_norm_real() const {
923 using real_type = typename FieldTraits<ft>::real_type;
924 using std::max;
925
926 real_type norm = 0;
927 for (auto const &x : *this) {
928 real_type const a = x.infinity_norm_real();
929 norm = max(a, norm);
930 }
931 return norm;
932 }
933
935 template <typename ft = field_type,
936 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
937 typename FieldTraits<ft>::real_type infinity_norm() const {
938 using real_type = typename FieldTraits<ft>::real_type;
939 using std::max;
940
941 real_type norm = 0;
942 real_type isNaN = 1;
943 for (auto const &x : *this) {
944 real_type const a = x.infinity_norm();
945 norm = max(a, norm);
946 isNaN += a;
947 }
948 isNaN /= isNaN;
949 return norm * isNaN;
950 }
951
953 template <typename ft = field_type,
954 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
955 typename FieldTraits<ft>::real_type infinity_norm_real() const {
956 using real_type = typename FieldTraits<ft>::real_type;
957 using std::max;
958
959 real_type norm = 0;
960 real_type isNaN = 1;
961 for (auto const &x : *this) {
962 real_type const a = x.infinity_norm_real();
963 norm = max(a, norm);
964 isNaN += a;
965 }
966 isNaN /= isNaN;
967 return norm * isNaN;
968 }
969
970 //===== sizes
971
973 size_type N () const
974 {
975 return this->n;
976 }
977
979 size_type dim () const
980 {
981 size_type d=0;
982 for (size_type i=0; i<this->n; i++)
983 d += (this->p)[i].dim();
984 return d;
985 }
986
987 protected:
990 { }
991
993 template<class V>
994 bool includesindexset (const V& y)
995 {
996 typename V::ConstIterator e=this->end();
997 for (size_type i=0; i<y.n; i++)
998 if (this->find(y.j[i])==e)
999 return false;
1000 return true;
1001 }
1002 };
1003
1004
1023 template<class B, class A=std::allocator<B> >
1025 {
1026 public:
1027
1028 //===== type definitions and constants
1029
1031 typedef typename B::field_type field_type;
1032
1034 typedef B block_type;
1035
1038
1040 typedef typename A::size_type size_type;
1041
1043 enum {
1045 blocklevel = B::blocklevel+1
1047
1050
1053
1054
1055 //===== constructors and such
1058 { }
1059
1062 {
1063 this->n = _n;
1064 this->p = _p;
1065 this->j = _j;
1066 }
1067
1070 {
1071 this->n = a.n;
1072 this->p = a.p;
1073 this->j = a.j;
1074 }
1075
1078 {
1079 // check correct size
1080#ifdef DUNE_ISTL_WITH_CHECKING
1081 if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
1082#endif
1083
1084 if (&a!=this) // check if this and a are different objects
1085 {
1086 // copy data
1087 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
1088 for (size_type i=0; i<this->n; i++) this->j[i]=a.j[i];
1089 }
1090 return *this;
1091 }
1092
1095 {
1096 (static_cast<compressed_block_vector_unmanaged<B,A>&>(*this)) = k;
1097 return *this;
1098 }
1099
1100
1101 //===== window manipulation methods
1102
1104 void set (size_type _n, B* _p, size_type* _j)
1105 {
1106 this->n = _n;
1107 this->p = _p;
1108 this->j = _j;
1109 }
1110
1113 {
1114 this->n = _n;
1115 }
1116
1118 void setptr (B* _p)
1119 {
1120 this->p = _p;
1121 }
1122
1125 {
1126 this->j = _j;
1127 }
1128
1131 {
1132 return this->p;
1133 }
1134
1137 {
1138 return this->j;
1139 }
1140
1142 const B* getptr () const
1143 {
1144 return this->p;
1145 }
1146
1148 const size_type* getindexptr () const
1149 {
1150 return this->j;
1151 }
1154 {
1155 return this->n;
1156 }
1157 };
1158
1159} // end namespace
1160
1161#endif
Implements several basic array containers.
Definition: bvector.hh:650
B * getptr()
get pointer
Definition: bvector.hh:745
A allocator_type
export the allocator type
Definition: bvector.hh:662
BlockVectorWindow & operator=(const BlockVectorWindow &a)
assignment
Definition: bvector.hh:700
BlockVectorWindow(const BlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition: bvector.hh:693
void set(size_type _n, B *_p)
set size and pointer
Definition: bvector.hh:726
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:674
size_type getsize()
get size
Definition: bvector.hh:751
B::field_type field_type
export the type representing the field
Definition: bvector.hh:656
void setsize(size_type _n)
set size only
Definition: bvector.hh:733
@ blocklevel
The number of blocklevels we contain.
Definition: bvector.hh:670
BlockVectorWindow(B *_p, size_type _n)
make array from given pointer and size
Definition: bvector.hh:686
B block_type
export the type representing the components
Definition: bvector.hh:659
BlockVectorWindow()
makes empty array
Definition: bvector.hh:682
A::size_type size_type
The type for the index access.
Definition: bvector.hh:665
void setptr(B *_p)
set pointer only
Definition: bvector.hh:739
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:677
A vector of blocks with memory management.
Definition: bvector.hh:313
BlockVector()
makes empty vector
Definition: bvector.hh:345
@ blocklevel
The number of blocklevel we contain.
Definition: bvector.hh:333
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:340
void resize(size_type size, bool copyOldValues=true)
Resize the vector.
Definition: bvector.hh:499
BlockVector & operator=(const BlockVector &a)
assignment
Definition: bvector.hh:543
BlockVector(size_type _n)
make vector with _n components
Definition: bvector.hh:350
void reserve(size_type capacity, bool copyOldValues=true)
Reserve space.
Definition: bvector.hh:437
A allocator_type
export the allocator type
Definition: bvector.hh:325
BlockVector(const BlockVector &a)
copy constructor
Definition: bvector.hh:511
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:337
A::size_type size_type
The type for the index access.
Definition: bvector.hh:328
~BlockVector()
free dynamic memory
Definition: bvector.hh:532
BlockVector(std::initializer_list< B > const &l)
Construct from a std::initializer_list.
Definition: bvector.hh:367
size_type capacity() const
Get the capacity of the vector.
Definition: bvector.hh:480
B::field_type field_type
export the type representing the field
Definition: bvector.hh:319
BlockVector(size_type _n, S _capacity)
Make vector with _n components but preallocating capacity components.
Definition: bvector.hh:398
B block_type
export the type representing the components
Definition: bvector.hh:322
Definition: bvector.hh:1025
compressed_block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:1052
const B * getptr() const
get pointer
Definition: bvector.hh:1142
CompressedBlockVectorWindow(const CompressedBlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition: bvector.hh:1069
void set(size_type _n, B *_p, size_type *_j)
set size and pointer
Definition: bvector.hh:1104
size_type * getindexptr()
get pointer
Definition: bvector.hh:1136
void setsize(size_type _n)
set size only
Definition: bvector.hh:1112
const size_type * getindexptr() const
get pointer
Definition: bvector.hh:1148
compressed_block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:1049
CompressedBlockVectorWindow(B *_p, size_type *_j, size_type _n)
make array from given pointers and size
Definition: bvector.hh:1061
A::size_type size_type
The type for the index access.
Definition: bvector.hh:1040
B::field_type field_type
export the type representing the field
Definition: bvector.hh:1031
A allocator_type
export the allocator type
Definition: bvector.hh:1037
B block_type
export the type representing the components
Definition: bvector.hh:1034
CompressedBlockVectorWindow & operator=(const CompressedBlockVectorWindow &a)
assignment
Definition: bvector.hh:1077
void setptr(B *_p)
set pointer only
Definition: bvector.hh:1118
B * getptr()
get pointer
Definition: bvector.hh:1130
CompressedBlockVectorWindow()
makes empty array
Definition: bvector.hh:1057
size_type getsize() const
get size
Definition: bvector.hh:1153
void setindexptr(size_type *_j)
set pointer only
Definition: bvector.hh:1124
@ blocklevel
The number of block level this vector contains.
Definition: bvector.hh:1045
derive error class from the base class in common
Definition: istlexception.hh:16
A simple array container for objects of type B.
Definition: basearray.hh:47
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:242
An unmanaged vector of blocks.
Definition: bvector.hh:46
block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bvector.hh:110
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: bvector.hh:193
A::size_type size_type
The size type for the index access.
Definition: bvector.hh:61
block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition: bvector.hh:293
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:201
base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition: bvector.hh:64
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition: bvector.hh:211
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition: bvector.hh:185
block_vector_unmanaged & operator-=(const block_vector_unmanaged &y)
vector space subtraction
Definition: bvector.hh:100
B::field_type field_type
export the type representing the field
Definition: bvector.hh:52
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bvector.hh:226
base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition: bvector.hh:67
block_vector_unmanaged & axpy(const field_type &a, const block_vector_unmanaged &y)
vector space axpy operation
Definition: bvector.hh:124
block_vector_unmanaged & operator+=(const block_vector_unmanaged &y)
vector space addition
Definition: bvector.hh:90
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: bvector.hh:277
size_type dim() const
dimension of the vector space
Definition: bvector.hh:283
B value_type
for STL compatibility
Definition: bvector.hh:70
block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition: bvector.hh:117
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:163
const B & const_reference
Type used for const references.
Definition: bvector.hh:76
B & reference
Type used for references.
Definition: bvector.hh:73
block_vector_unmanaged & operator=(const field_type &k)
Assignment from a scalar.
Definition: bvector.hh:81
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:142
B block_type
export the type representing the components
Definition: bvector.hh:55
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition: bvector.hh:177
A allocator_type
export the allocator type
Definition: bvector.hh:58
A simple array container with non-consecutive index set.
Definition: basearray.hh:527
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:686
iterator end()
end iterator
Definition: basearray.hh:666
Definition: bvector.hh:771
compressed_block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bvector.hh:840
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:897
compressed_block_vector_unmanaged & operator-=(const V &y)
vector space subtraction
Definition: bvector.hh:819
A::size_type size_type
The type for the index access.
Definition: bvector.hh:792
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: bvector.hh:973
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition: bvector.hh:881
field_type operator*(const compressed_block_vector_unmanaged &y) const
scalar product
Definition: bvector.hh:857
B block_type
export the type representing the components
Definition: bvector.hh:780
FieldTraits< ft >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition: bvector.hh:907
bool includesindexset(const V &y)
return true if index sets coincide
Definition: bvector.hh:994
A allocator_type
export the allocator type
Definition: bvector.hh:783
compressed_block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition: bvector.hh:847
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition: bvector.hh:873
FieldTraits< ft >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bvector.hh:922
B::field_type field_type
export the type representing the field
Definition: bvector.hh:777
size_type dim() const
dimension of the vector space
Definition: bvector.hh:979
compressed_block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition: bvector.hh:989
compressed_block_vector_unmanaged & axpy(const field_type &a, const V &y)
vector space axpy operation
Definition: bvector.hh:830
compressed_base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition: bvector.hh:789
compressed_block_vector_unmanaged & operator+=(const V &y)
vector space addition
Definition: bvector.hh:808
compressed_base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition: bvector.hh:786
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: bvector.hh:889
Provides the functions dot(a,b) := and dotT(a,b) := .
Type traits to determine the type of reals (when working with complex numbers)
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11
Compute type of the result of an arithmetic operation involving two different number types.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)