dune-istl 3.0-git
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
12#include <dune/common/promotiontraits.hh>
13#include <dune/common/dotproduct.hh>
14#include <dune/common/ftraits.hh>
15
16#include "istlexception.hh"
17#include "basearray.hh"
18
26namespace Dune {
27
28
40 template<class B, class A=std::allocator<B> >
42 {
43 public:
44
45 //===== type definitions and constants
46
48 typedef typename B::field_type field_type;
49
51 typedef B block_type;
52
54 typedef A allocator_type;
55
57 typedef typename A::size_type size_type;
58
61
64
66 typedef B value_type;
67
69 typedef B& reference;
70
72 typedef const B& const_reference;
73
74 //===== assignment from scalar
76
78 {
79 for (size_type i=0; i<this->n; i++)
80 (*this)[i] = k;
81 return *this;
82 }
83
84 //===== vector space arithmetic
87 {
88#ifdef DUNE_ISTL_WITH_CHECKING
89 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
90#endif
91 for (size_type i=0; i<this->n; ++i) (*this)[i] += y[i];
92 return *this;
93 }
94
97 {
98#ifdef DUNE_ISTL_WITH_CHECKING
99 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
100#endif
101 for (size_type i=0; i<this->n; ++i) (*this)[i] -= y[i];
102 return *this;
103 }
104
107 {
108 for (size_type i=0; i<this->n; ++i) (*this)[i] *= k;
109 return *this;
110 }
111
114 {
115 for (size_type i=0; i<this->n; ++i) (*this)[i] /= k;
116 return *this;
117 }
118
121 {
122#ifdef DUNE_ISTL_WITH_CHECKING
123 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
124#endif
125 for (size_type i=0; i<this->n; ++i) (*this)[i].axpy(a,y[i]);
126 return *this;
127 }
128
129
137 template<class OtherB, class OtherA>
139 {
141 PromotedType sum(0);
142#ifdef DUNE_ISTL_WITH_CHECKING
143 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
144#endif
145 for (size_type i=0; i<this->n; ++i) {
146 sum += PromotedType(((*this)[i])*y[i]);
147 }
148 return sum;
149 }
150
158 template<class OtherB, class OtherA>
160 {
162 PromotedType sum(0);
163#ifdef DUNE_ISTL_WITH_CHECKING
164 if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
165#endif
166 for (size_type i=0; i<this->n; ++i) sum += ((*this)[i]).dot(y[i]);
167 return sum;
168 }
169
170 //===== norms
171
174 {
176 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm();
177 return sum;
178 }
179
182 {
184 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm_real();
185 return sum;
186 }
187
190 {
192 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
193 return sqrt(sum);
194 }
195
198 {
200 for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
201 return sum;
202 }
203
205 template <typename ft = field_type,
206 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
208 using real_type = typename FieldTraits<ft>::real_type;
209 using std::max;
210
211 real_type norm = 0;
212 for (auto const &x : *this) {
213 real_type const a = x.infinity_norm();
214 norm = max(a, norm);
215 }
216 return norm;
217 }
218
220 template <typename ft = field_type,
221 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
223 using real_type = typename FieldTraits<ft>::real_type;
224 using std::max;
225
226 real_type norm = 0;
227 for (auto const &x : *this) {
228 real_type const a = x.infinity_norm_real();
229 norm = max(a, norm);
230 }
231 return norm;
232 }
233
235 template <typename ft = field_type,
236 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
238 using real_type = typename FieldTraits<ft>::real_type;
239 using std::max;
240
241 real_type norm = 0;
242 real_type isNaN = 1;
243 for (auto const &x : *this) {
244 real_type const a = x.infinity_norm();
245 norm = max(a, norm);
246 isNaN += a;
247 }
248 isNaN /= isNaN;
249 return norm * isNaN;
250 }
251
253 template <typename ft = field_type,
254 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
256 using real_type = typename FieldTraits<ft>::real_type;
257 using std::max;
258
259 real_type norm = 0;
260 real_type isNaN = 1;
261 for (auto const &x : *this) {
262 real_type const a = x.infinity_norm_real();
263 norm = max(a, norm);
264 isNaN += a;
265 }
266 isNaN /= isNaN;
267 return norm * isNaN;
268 }
269
270 //===== sizes
271
273 size_type N () const
274 {
275 return this->n;
276 }
277
279 size_type dim () const
280 {
281 size_type d=0;
282 for (size_type i=0; i<this->n; i++)
283 d += (*this)[i].dim();
284 return d;
285 }
286
287 protected:
291 };
292
307 template<class B, class A=std::allocator<B> >
309 {
310 public:
311
312 //===== type definitions and constants
313
315 typedef typename B::field_type field_type;
316
318 typedef B block_type;
319
321 typedef A allocator_type;
322
324 typedef typename A::size_type size_type;
325
327 enum {
329 blocklevel = B::blocklevel+1
330 };
331
334
337
338 //===== constructors and such
339
342 capacity_(0)
343 {}
344
346 explicit BlockVector (size_type _n)
347 {
348 this->n = _n;
349 capacity_ = _n;
350 if (capacity_>0) {
351 this->p = this->allocator_.allocate(capacity_);
352 // actually construct the objects
353 new(this->p)B[capacity_];
354 } else
355 {
356 this->p = 0;
357 this->n = 0;
358 capacity_ = 0;
359 }
360 }
361
363 BlockVector (std::initializer_list<B> const &l)
364 {
365 this->n = l.size();
366 capacity_ = l.size();
367 if (capacity_>0) {
368 this->p = this->allocator_.allocate(capacity_);
369 // actually construct the objects
370 new(this->p)B[capacity_];
371
372 std::copy_n(l.begin(), l.size(), this->p);
373 } else
374 {
375 this->p = 0;
376 this->n = 0;
377 capacity_ = 0;
378 }
379 }
380
381
393 template<typename S>
394 BlockVector (size_type _n, S _capacity)
395 {
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!)" );
399 this->n = _n;
400 if(this->n > capacity)
401 capacity_ = _n;
402 else
404
405 if (capacity_>0) {
406 this->p = this->allocator_.allocate(capacity_);
407 new (this->p)B[capacity_];
408 } else
409 {
410 this->p = 0;
411 this->n = 0;
412 capacity_ = 0;
413 }
414 }
415
416
433 void reserve(size_type capacity, bool copyOldValues=true)
434 {
436 // save the old data
437 B* pold = this->p;
438
439 if(capacity>0) {
440 // create new array with capacity
441 this->p = this->allocator_.allocate(capacity);
442 new (this->p)B[capacity];
443
444 if(copyOldValues) {
445 // copy the old values
446 B* to = this->p;
447 B* from = pold;
448
450 *to = *from;
451 }
452 if(capacity_ > 0) {
453 // Destruct old objects and free memory
454 int i=capacity_;
455 while (i)
456 pold[--i].~B();
457 this->allocator_.deallocate(pold,capacity_);
458 }
459 }else{
460 if(capacity_ > 0)
461 // free old data
462 this->p = 0;
463 capacity_ = 0;
464 }
465
467 }
468 }
469
476 size_type capacity() const
477 {
478 return capacity_;
479 }
480
496 {
498 if(capacity_ < size)
499 this->reserve(size, copyOldValues);
500 this->n = size;
501 }
502
503
504
505
509 {
510 // allocate memory with same size as a
511 this->n = a.n;
513
514 if (capacity_>0) {
515 this->p = this->allocator_.allocate(capacity_);
516 new (this->p)B[capacity_];
517 } else
518 {
519 this->n = 0;
520 this->p = 0;
521 }
522
523 // and copy elements
524 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
525 }
526
529 {
530 // upcast, because protected data inaccessible
531 const BlockVector& a = static_cast<const BlockVector&>(_a);
532
533 // allocate memory with same size as a
534 this->n = a.n;
536
537 if (capacity_>0) {
538 this->p = this->allocator_.allocate(capacity_);
539 new (this->p)B[capacity_];
540 } else
541 {
542 this->n = 0;
543 this->p = 0;
544 capacity_ = 0;
545 }
546
547 // and copy elements
548 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
549 }
550
553 {
554 if (capacity_>0) {
555 int i=capacity_;
556 while (i)
557 this->p[--i].~B();
558 this->allocator_.deallocate(this->p,capacity_);
559 }
560 }
561
564 {
565 if (&a!=this) // check if this and a are different objects
566 {
567 // adjust size of vector
568 if (capacity_!=a.capacity_) // check if size is different
569 {
570 if (capacity_>0) {
571 int i=capacity_;
572 while (i)
573 this->p[--i].~B();
574 this->allocator_.deallocate(this->p,capacity_); // free old memory
575 }
577 if (capacity_>0) {
578 this->p = this->allocator_.allocate(capacity_);
579 new (this->p)B[capacity_];
580 } else
581 {
582 this->p = 0;
583 capacity_ = 0;
584 }
585 }
586 this->n = a.n;
587 // copy data
588 for (size_type i=0; i<this->n; i++)
589 this->p[i]=a.p[i];
590 }
591 return *this;
592 }
593
596 {
597 // forward to regular assignement operator
598 return this->operator=(static_cast<const BlockVector&>(a));
599 }
600
603 {
604 // forward to operator= in base class
605 (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
606 return *this;
607 }
608 protected:
610
612
613 };
614
620 template<class B, class A>
621 struct FieldTraits< BlockVector<B, A> >
622 {
625 };
631 template<class K, class A>
632 std::ostream& operator<< (std::ostream& s, const BlockVector<K, A>& v)
633 {
634 typedef typename BlockVector<K, A>::size_type size_type;
635
636 for (size_type i=0; i<v.size(); i++)
637 s << v[i] << std::endl;
638
639 return s;
640 }
641
658 template<class B, class A=std::allocator<B> >
660 {
661 public:
662
663 //===== type definitions and constants
664
666 typedef typename B::field_type field_type;
667
669 typedef B block_type;
670
672 typedef A allocator_type;
673
675 typedef typename A::size_type size_type;
676
678 enum {
680 blocklevel = B::blocklevel+1
681 };
682
685
688
689
690 //===== constructors and such
694
697 {
698 this->n = _n;
699 this->p = _p;
700 }
701
704 {
705 this->n = a.n;
706 this->p = a.p;
707 }
708
711 {
712 // cast needed to access protected data
713 const BlockVectorWindow& a = static_cast<const BlockVectorWindow&>(_a);
714
715 // make me point to the other's data
716 this->n = a.n;
717 this->p = a.p;
718 }
719
720
723 {
724 // check correct size
725#ifdef DUNE_ISTL_WITH_CHECKING
726 if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
727#endif
728
729 if (&a!=this) // check if this and a are different objects
730 {
731 // copy data
732 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
733 }
734 return *this;
735 }
736
739 {
740 // forward to regular assignment operator
741 return this->operator=(static_cast<const BlockVectorWindow&>(a));
742 }
743
746 {
747 (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
748 return *this;
749 }
750
751
752 //===== window manipulation methods
753
755 void set (size_type _n, B* _p)
756 {
757 this->n = _n;
758 this->p = _p;
759 }
760
763 {
764 this->n = _n;
765 }
766
768 void setptr (B* _p)
769 {
770 this->p = _p;
771 }
772
774 B* getptr ()
775 {
776 return this->p;
777 }
778
780 size_type getsize ()
781 {
782 return this->n;
783 }
784 };
785
786
787
796 template<class B, class A=std::allocator<B> >
798 {
799 public:
800
801 //===== type definitions and constants
802
804 typedef typename B::field_type field_type;
805
807 typedef B block_type;
808
810 typedef A allocator_type;
811
814
817
819 typedef typename A::size_type size_type;
820
821 //===== assignment from scalar
822
824 {
825 for (size_type i=0; i<this->n; i++)
826 (this->p)[i] = k;
827 return *this;
828 }
829
830
831 //===== vector space arithmetic
832
834 template<class V>
836 {
837#ifdef DUNE_ISTL_WITH_CHECKING
838 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
839#endif
840 for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) += y.p[i];
841 return *this;
842 }
843
845 template<class V>
847 {
848#ifdef DUNE_ISTL_WITH_CHECKING
849 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
850#endif
851 for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) -= y.p[i];
852 return *this;
853 }
854
856 template<class V>
858 {
859#ifdef DUNE_ISTL_WITH_CHECKING
860 if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
861#endif
862 for (size_type i=0; i<y.n; ++i) (this->operator[](y.j[i])).axpy(a,y.p[i]);
863 return *this;
864 }
865
868 {
869 for (size_type i=0; i<this->n; ++i) (this->p)[i] *= k;
870 return *this;
871 }
872
875 {
876 for (size_type i=0; i<this->n; ++i) (this->p)[i] /= k;
877 return *this;
878 }
879
880
881 //===== Euclidean scalar product
882
885 {
886#ifdef DUNE_ISTL_WITH_CHECKING
887 if (!includesindexset(y) || !y.includesindexset(*this) )
888 DUNE_THROW(ISTLError,"index set mismatch");
889#endif
890 field_type sum=0;
891 for (size_type i=0; i<this->n; ++i)
892 sum += (this->p)[i] * y[(this->j)[i]];
893 return sum;
894 }
895
896
897 //===== norms
898
901 {
903 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm();
904 return sum;
905 }
906
909 {
911 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].one_norm_real();
912 return sum;
913 }
914
917 {
919 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
920 return sqrt(sum);
921 }
922
925 {
927 for (size_type i=0; i<this->n; ++i) sum += (this->p)[i].two_norm2();
928 return sum;
929 }
930
932 template <typename ft = field_type,
933 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
935 using real_type = typename FieldTraits<ft>::real_type;
936 using std::max;
937
938 real_type norm = 0;
939 for (auto const &x : *this) {
940 real_type const a = x.infinity_norm();
941 norm = max(a, norm);
942 }
943 return norm;
944 }
945
947 template <typename ft = field_type,
948 typename std::enable_if<!has_nan<ft>::value, int>::type = 0>
950 using real_type = typename FieldTraits<ft>::real_type;
951 using std::max;
952
953 real_type norm = 0;
954 for (auto const &x : *this) {
955 real_type const a = x.infinity_norm_real();
956 norm = max(a, norm);
957 }
958 return norm;
959 }
960
962 template <typename ft = field_type,
963 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
965 using real_type = typename FieldTraits<ft>::real_type;
966 using std::max;
967
968 real_type norm = 0;
969 real_type isNaN = 1;
970 for (auto const &x : *this) {
971 real_type const a = x.infinity_norm();
972 norm = max(a, norm);
973 isNaN += a;
974 }
975 isNaN /= isNaN;
976 return norm * isNaN;
977 }
978
980 template <typename ft = field_type,
981 typename std::enable_if<has_nan<ft>::value, int>::type = 0>
983 using real_type = typename FieldTraits<ft>::real_type;
984 using std::max;
985
986 real_type norm = 0;
987 real_type isNaN = 1;
988 for (auto const &x : *this) {
989 real_type const a = x.infinity_norm_real();
990 norm = max(a, norm);
991 isNaN += a;
992 }
993 isNaN /= isNaN;
994 return norm * isNaN;
995 }
996
997 //===== sizes
998
1000 size_type N () const
1001 {
1002 return this->n;
1003 }
1004
1006 size_type dim () const
1007 {
1008 size_type d=0;
1009 for (size_type i=0; i<this->n; i++)
1010 d += (this->p)[i].dim();
1011 return d;
1012 }
1013
1014 protected:
1018
1020 template<class V>
1021 bool includesindexset (const V& y)
1022 {
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)
1026 return false;
1027 return true;
1028 }
1029 };
1030
1031
1048 template<class B, class A=std::allocator<B> >
1050 {
1051 public:
1052
1053 //===== type definitions and constants
1054
1056 typedef typename B::field_type field_type;
1057
1059 typedef B block_type;
1060
1063
1065 typedef typename A::size_type size_type;
1066
1068 enum {
1070 blocklevel = B::blocklevel+1
1072
1075
1078
1079
1080 //===== constructors and such
1084
1087 {
1088 this->n = _n;
1089 this->p = _p;
1090 this->j = _j;
1091 }
1092
1095 {
1096 this->n = a.n;
1097 this->p = a.p;
1098 this->j = a.j;
1099 }
1100
1103 {
1104 // cast needed to access protected data (upcast)
1105 const CompressedBlockVectorWindow& a = static_cast<const CompressedBlockVectorWindow&>(_a);
1106
1107 // make me point to the other's data
1108 this->n = a.n;
1109 this->p = a.p;
1110 this->j = a.j;
1111 }
1112
1113
1116 {
1117 // check correct size
1118#ifdef DUNE_ISTL_WITH_CHECKING
1119 if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
1120#endif
1121
1122 if (&a!=this) // check if this and a are different objects
1123 {
1124 // copy data
1125 for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
1126 for (size_type i=0; i<this->n; i++) this->j[i]=a.j[i];
1127 }
1128 return *this;
1129 }
1130
1133 {
1134 // forward to regular assignment operator
1135 return this->operator=(static_cast<const CompressedBlockVectorWindow&>(a));
1136 }
1137
1140 {
1141 (static_cast<compressed_block_vector_unmanaged<B,A>&>(*this)) = k;
1142 return *this;
1143 }
1144
1145
1146 //===== window manipulation methods
1147
1149 void set (size_type _n, B* _p, size_type* _j)
1150 {
1151 this->n = _n;
1152 this->p = _p;
1153 this->j = _j;
1154 }
1155
1158 {
1159 this->n = _n;
1160 }
1161
1163 void setptr (B* _p)
1164 {
1165 this->p = _p;
1166 }
1167
1170 {
1171 this->j = _j;
1172 }
1173
1176 {
1177 return this->p;
1178 }
1179
1181 size_type* getindexptr ()
1182 {
1183 return this->j;
1184 }
1185
1187 const B* getptr () const
1188 {
1189 return this->p;
1190 }
1191
1193 const size_type* getindexptr () const
1194 {
1195 return this->j;
1196 }
1198 size_type getsize () const
1199 {
1200 return this->n;
1201 }
1202 };
1203
1204} // end namespace
1205
1206#endif
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
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