Dune Core Modules (2.3.1)

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_BVECTOR_HH
5 #define DUNE_BVECTOR_HH
6 
7 #include <cmath>
8 #include <complex>
9 #include <memory>
10 #include <limits>
11 
15 #include <dune/common/ftraits.hh>
16 
17 #include "istlexception.hh"
18 #include "basearray.hh"
19 
27 namespace Dune {
28 
29 
41  template<class B, class A=std::allocator<B> >
43  {
44  public:
45 
46  //===== type definitions and constants
47 
49  typedef typename B::field_type field_type;
50 
52  typedef B block_type;
53 
55  typedef A allocator_type;
56 
58  typedef typename A::size_type size_type;
59 
62 
65 
67  typedef B value_type;
68 
69  //===== assignment from scalar
71 
73  {
74  for (size_type i=0; i<this->n; i++)
75  (*this)[i] = k;
76  return *this;
77  }
78 
79  //===== vector space arithmetic
82  {
83 #ifdef DUNE_ISTL_WITH_CHECKING
84  if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
85 #endif
86  for (size_type i=0; i<this->n; ++i) (*this)[i] += y[i];
87  return *this;
88  }
89 
92  {
93 #ifdef DUNE_ISTL_WITH_CHECKING
94  if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
95 #endif
96  for (size_type i=0; i<this->n; ++i) (*this)[i] -= y[i];
97  return *this;
98  }
99 
102  {
103  for (size_type i=0; i<this->n; ++i) (*this)[i] *= k;
104  return *this;
105  }
106 
109  {
110  for (size_type i=0; i<this->n; ++i) (*this)[i] /= k;
111  return *this;
112  }
113 
116  {
117 #ifdef DUNE_ISTL_WITH_CHECKING
118  if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
119 #endif
120  for (size_type i=0; i<this->n; ++i) (*this)[i].axpy(a,y[i]);
121  return *this;
122  }
123 
124 
132  template<class OtherB, class OtherA>
133  typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType operator* (const block_vector_unmanaged<OtherB,OtherA>& y) const
134  {
135  typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
136  PromotedType sum(0);
137 #ifdef DUNE_ISTL_WITH_CHECKING
138  if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
139 #endif
140  for (size_type i=0; i<this->n; ++i) {
141  sum += PromotedType(((*this)[i])*y[i]);
142  }
143  return sum;
144  }
145 
153  template<class OtherB, class OtherA>
154  typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType dot(const block_vector_unmanaged<OtherB,OtherA>& y) const
155  {
156  typedef typename PromotionTraits<field_type,typename OtherB::field_type>::PromotedType PromotedType;
157  PromotedType sum(0);
158 #ifdef DUNE_ISTL_WITH_CHECKING
159  if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
160 #endif
161  for (size_type i=0; i<this->n; ++i) sum += ((*this)[i]).dot(y[i]);
162  return sum;
163  }
164 
165  //===== norms
166 
168  typename FieldTraits<field_type>::real_type one_norm () const
169  {
170  typename FieldTraits<field_type>::real_type sum=0;
171  for (size_type i=0; i<this->n; ++i) sum += (*this)[i].one_norm();
172  return sum;
173  }
174 
176  typename FieldTraits<field_type>::real_type one_norm_real () const
177  {
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();
180  return sum;
181  }
182 
184  typename FieldTraits<field_type>::real_type two_norm () const
185  {
186  typename FieldTraits<field_type>::real_type sum=0;
187  for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
188  return sqrt(sum);
189  }
190 
192  typename FieldTraits<field_type>::real_type two_norm2 () const
193  {
194  typename FieldTraits<field_type>::real_type sum=0;
195  for (size_type i=0; i<this->n; ++i) sum += (*this)[i].two_norm2();
196  return sum;
197  }
198 
200  typename FieldTraits<field_type>::real_type infinity_norm () const
201  {
202  typename FieldTraits<field_type>::real_type max=0;
203  for (size_type i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm());
204  return max;
205  }
206 
208  typename FieldTraits<field_type>::real_type infinity_norm_real () const
209  {
210  typename FieldTraits<field_type>::real_type max=0;
211  for (size_type i=0; i<this->n; ++i) max = std::max(max,(*this)[i].infinity_norm_real());
212  return max;
213  }
214 
215  //===== sizes
216 
218  size_type N () const
219  {
220  return this->n;
221  }
222 
224  size_type dim () const
225  {
226  size_type d=0;
227  for (size_type i=0; i<this->n; i++)
228  d += (*this)[i].dim();
229  return d;
230  }
231 
232  protected:
235  { }
236  };
237 
252  template<class B, class A=std::allocator<B> >
254  {
255  public:
256 
257  //===== type definitions and constants
258 
260  typedef typename B::field_type field_type;
261 
263  typedef B block_type;
264 
266  typedef A allocator_type;
267 
269  typedef typename A::size_type size_type;
270 
272  enum {
274  blocklevel = B::blocklevel+1
275  };
276 
279 
282 
283  //===== constructors and such
284 
287  capacity_(0)
288  {}
289 
291  explicit BlockVector (size_type _n)
292  {
293  this->n = _n;
294  capacity_ = _n;
295  if (capacity_>0) {
296  this->p = this->allocator_.allocate(capacity_);
297  // actually construct the objects
298  new(this->p)B[capacity_];
299  } else
300  {
301  this->p = 0;
302  this->n = 0;
303  capacity_ = 0;
304  }
305  }
306 
318  template<typename S>
319  BlockVector (size_type _n, S _capacity)
320  {
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!)" );
323  size_type capacity = _capacity;
324  this->n = _n;
325  if(this->n > capacity)
326  capacity_ = _n;
327  else
328  capacity_ = capacity;
329 
330  if (capacity_>0) {
331  this->p = this->allocator_.allocate(capacity_);
332  new (this->p)B[capacity_];
333  } else
334  {
335  this->p = 0;
336  this->n = 0;
337  capacity_ = 0;
338  }
339  }
340 
341 
358  void reserve(size_type capacity, bool copyOldValues=true)
359  {
360  if(capacity >= block_vector_unmanaged<B,A>::N() && capacity != capacity_) {
361  // save the old data
362  B* pold = this->p;
363 
364  if(capacity>0) {
365  // create new array with capacity
366  this->p = this->allocator_.allocate(capacity);
367  new (this->p)B[capacity];
368 
369  if(copyOldValues) {
370  // copy the old values
371  B* to = this->p;
372  B* from = pold;
373 
374  for(size_type i=0; i < block_vector_unmanaged<B,A>::N(); ++i, ++from, ++to)
375  *to = *from;
376  }
377  if(capacity_ > 0) {
378  // Destruct old objects and free memory
379  int i=capacity_;
380  while (i)
381  pold[--i].~B();
382  this->allocator_.deallocate(pold,capacity_);
383  }
384  }else{
385  if(capacity_ > 0)
386  // free old data
387  this->p = 0;
388  capacity_ = 0;
389  }
390 
391  capacity_ = capacity;
392  }
393  }
394 
402  {
403  return capacity_;
404  }
405 
420  void resize(size_type size, bool copyOldValues=true)
421  {
423  if(capacity_ < size)
424  this->reserve(size, copyOldValues);
425  this->n = size;
426  }
427 
428 
429 
430 
433  block_vector_unmanaged<B,A>(a)
434  {
435  // allocate memory with same size as a
436  this->n = a.n;
437  capacity_ = a.capacity_;
438 
439  if (capacity_>0) {
440  this->p = this->allocator_.allocate(capacity_);
441  new (this->p)B[capacity_];
442  } else
443  {
444  this->n = 0;
445  this->p = 0;
446  }
447 
448  // and copy elements
449  for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
450  }
451 
454  {
455  // upcast, because protected data inaccessible
456  const BlockVector& a = static_cast<const BlockVector&>(_a);
457 
458  // allocate memory with same size as a
459  this->n = a.n;
460  capacity_ = a.capacity_;
461 
462  if (capacity_>0) {
463  this->p = this->allocator_.allocate(capacity_);
464  new (this->p)B[capacity_];
465  } else
466  {
467  this->n = 0;
468  this->p = 0;
469  capacity_ = 0;
470  }
471 
472  // and copy elements
473  for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
474  }
475 
478  {
479  if (capacity_>0) {
480  int i=capacity_;
481  while (i)
482  this->p[--i].~B();
483  this->allocator_.deallocate(this->p,capacity_);
484  }
485  }
486 
489  {
490  if (&a!=this) // check if this and a are different objects
491  {
492  // adjust size of vector
493  if (capacity_!=a.capacity_) // check if size is different
494  {
495  if (capacity_>0) {
496  int i=capacity_;
497  while (i)
498  this->p[--i].~B();
499  this->allocator_.deallocate(this->p,capacity_); // free old memory
500  }
501  capacity_ = a.capacity_;
502  if (capacity_>0) {
503  this->p = this->allocator_.allocate(capacity_);
504  new (this->p)B[capacity_];
505  } else
506  {
507  this->p = 0;
508  capacity_ = 0;
509  }
510  }
511  this->n = a.n;
512  // copy data
513  for (size_type i=0; i<this->n; i++)
514  this->p[i]=a.p[i];
515  }
516  return *this;
517  }
518 
521  {
522  // forward to regular assignement operator
523  return this->operator=(static_cast<const BlockVector&>(a));
524  }
525 
528  {
529  // forward to operator= in base class
530  (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
531  return *this;
532  }
533  protected:
534  size_type capacity_;
535 
536  A allocator_;
537 
538  };
539 
545  template<class B, class A>
546  struct FieldTraits< BlockVector<B, A> >
547  {
548  typedef typename FieldTraits<B>::field_type field_type;
549  typedef typename FieldTraits<B>::real_type real_type;
550  };
556  template<class K, class A>
557  std::ostream& operator<< (std::ostream& s, const BlockVector<K, A>& v)
558  {
559  typedef typename BlockVector<K, A>::size_type size_type;
560 
561  for (size_type i=0; i<v.size(); i++)
562  s << v[i] << std::endl;
563 
564  return s;
565  }
566 
583  template<class B, class A=std::allocator<B> >
585  {
586  public:
587 
588  //===== type definitions and constants
589 
591  typedef typename B::field_type field_type;
592 
594  typedef B block_type;
595 
597  typedef A allocator_type;
598 
600  typedef typename A::size_type size_type;
601 
603  enum {
605  blocklevel = B::blocklevel+1
606  };
607 
610 
613 
614 
615  //===== constructors and such
618  { }
619 
622  {
623  this->n = _n;
624  this->p = _p;
625  }
626 
629  {
630  this->n = a.n;
631  this->p = a.p;
632  }
633 
636  {
637  // cast needed to access protected data
638  const BlockVectorWindow& a = static_cast<const BlockVectorWindow&>(_a);
639 
640  // make me point to the other's data
641  this->n = a.n;
642  this->p = a.p;
643  }
644 
645 
648  {
649  // check correct size
650 #ifdef DUNE_ISTL_WITH_CHECKING
651  if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
652 #endif
653 
654  if (&a!=this) // check if this and a are different objects
655  {
656  // copy data
657  for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
658  }
659  return *this;
660  }
661 
664  {
665  // forward to regular assignment operator
666  return this->operator=(static_cast<const BlockVectorWindow&>(a));
667  }
668 
671  {
672  (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
673  return *this;
674  }
675 
676 
677  //===== window manipulation methods
678 
680  void set (size_type _n, B* _p)
681  {
682  this->n = _n;
683  this->p = _p;
684  }
685 
687  void setsize (size_type _n)
688  {
689  this->n = _n;
690  }
691 
693  void setptr (B* _p)
694  {
695  this->p = _p;
696  }
697 
699  B* getptr ()
700  {
701  return this->p;
702  }
703 
706  {
707  return this->n;
708  }
709  };
710 
711 
712 
721  template<class B, class A=std::allocator<B> >
723  {
724  public:
725 
726  //===== type definitions and constants
727 
729  typedef typename B::field_type field_type;
730 
732  typedef B block_type;
733 
735  typedef A allocator_type;
736 
739 
742 
744  typedef typename A::size_type size_type;
745 
746  //===== assignment from scalar
747 
748  compressed_block_vector_unmanaged& operator= (const field_type& k)
749  {
750  for (size_type i=0; i<this->n; i++)
751  (this->p)[i] = k;
752  return *this;
753  }
754 
755 
756  //===== vector space arithmetic
757 
759  template<class V>
761  {
762 #ifdef DUNE_ISTL_WITH_CHECKING
763  if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
764 #endif
765  for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) += y.p[i];
766  return *this;
767  }
768 
770  template<class V>
772  {
773 #ifdef DUNE_ISTL_WITH_CHECKING
774  if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
775 #endif
776  for (size_type i=0; i<y.n; ++i) this->operator[](y.j[i]) -= y.p[i];
777  return *this;
778  }
779 
781  template<class V>
783  {
784 #ifdef DUNE_ISTL_WITH_CHECKING
785  if (!includesindexset(y)) DUNE_THROW(ISTLError,"index set mismatch");
786 #endif
787  for (size_type i=0; i<y.n; ++i) (this->operator[](y.j[i])).axpy(a,y.p[i]);
788  return *this;
789  }
790 
793  {
794  for (size_type i=0; i<this->n; ++i) (this->p)[i] *= k;
795  return *this;
796  }
797 
800  {
801  for (size_type i=0; i<this->n; ++i) (this->p)[i] /= k;
802  return *this;
803  }
804 
805 
806  //===== Euclidean scalar product
807 
810  {
811 #ifdef DUNE_ISTL_WITH_CHECKING
812  if (!includesindexset(y) || !y.includesindexset(*this) )
813  DUNE_THROW(ISTLError,"index set mismatch");
814 #endif
815  field_type sum=0;
816  for (size_type i=0; i<this->n; ++i)
817  sum += (this->p)[i] * y[(this->j)[i]];
818  return sum;
819  }
820 
821 
822  //===== norms
823 
825  typename FieldTraits<field_type>::real_type one_norm () const
826  {
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();
829  return sum;
830  }
831 
833  typename FieldTraits<field_type>::real_type one_norm_real () const
834  {
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();
837  return sum;
838  }
839 
841  typename FieldTraits<field_type>::real_type two_norm () const
842  {
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();
845  return sqrt(sum);
846  }
847 
849  typename FieldTraits<field_type>::real_type two_norm2 () const
850  {
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();
853  return sum;
854  }
855 
857  typename FieldTraits<field_type>::real_type infinity_norm () const
858  {
859  typename FieldTraits<field_type>::real_type max=0;
860  for (size_type i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm());
861  return max;
862  }
863 
865  typename FieldTraits<field_type>::real_type infinity_norm_real () const
866  {
867  typename FieldTraits<field_type>::real_type max=0;
868  for (size_type i=0; i<this->n; ++i) max = std::max(max,(this->p)[i].infinity_norm_real());
869  return max;
870  }
871 
872 
873  //===== sizes
874 
876  size_type N () const
877  {
878  return this->n;
879  }
880 
882  size_type dim () const
883  {
884  size_type d=0;
885  for (size_type i=0; i<this->n; i++)
886  d += (this->p)[i].dim();
887  return d;
888  }
889 
890  protected:
893  { }
894 
896  template<class V>
897  bool includesindexset (const V& y)
898  {
899  typename V::ConstIterator e=this->end();
900  for (size_type i=0; i<y.n; i++)
901  if (this->find(y.j[i])==e)
902  return false;
903  return true;
904  }
905  };
906 
907 
924  template<class B, class A=std::allocator<B> >
926  {
927  public:
928 
929  //===== type definitions and constants
930 
932  typedef typename B::field_type field_type;
933 
935  typedef B block_type;
936 
938  typedef A allocator_type;
939 
941  typedef typename A::size_type size_type;
942 
944  enum {
946  blocklevel = B::blocklevel+1
947  };
948 
951 
954 
955 
956  //===== constructors and such
959  { }
960 
963  {
964  this->n = _n;
965  this->p = _p;
966  this->j = _j;
967  }
968 
971  {
972  this->n = a.n;
973  this->p = a.p;
974  this->j = a.j;
975  }
976 
979  {
980  // cast needed to access protected data (upcast)
981  const CompressedBlockVectorWindow& a = static_cast<const CompressedBlockVectorWindow&>(_a);
982 
983  // make me point to the other's data
984  this->n = a.n;
985  this->p = a.p;
986  this->j = a.j;
987  }
988 
989 
992  {
993  // check correct size
994 #ifdef DUNE_ISTL_WITH_CHECKING
995  if (this->n!=a.N()) DUNE_THROW(ISTLError,"vector size mismatch");
996 #endif
997 
998  if (&a!=this) // check if this and a are different objects
999  {
1000  // copy data
1001  for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
1002  for (size_type i=0; i<this->n; i++) this->j[i]=a.j[i];
1003  }
1004  return *this;
1005  }
1006 
1009  {
1010  // forward to regular assignment operator
1011  return this->operator=(static_cast<const CompressedBlockVectorWindow&>(a));
1012  }
1013 
1016  {
1017  (static_cast<compressed_block_vector_unmanaged<B,A>&>(*this)) = k;
1018  return *this;
1019  }
1020 
1021 
1022  //===== window manipulation methods
1023 
1025  void set (size_type _n, B* _p, size_type* _j)
1026  {
1027  this->n = _n;
1028  this->p = _p;
1029  this->j = _j;
1030  }
1031 
1033  void setsize (size_type _n)
1034  {
1035  this->n = _n;
1036  }
1037 
1039  void setptr (B* _p)
1040  {
1041  this->p = _p;
1042  }
1043 
1046  {
1047  this->j = _j;
1048  }
1049 
1051  B* getptr ()
1052  {
1053  return this->p;
1054  }
1055 
1058  {
1059  return this->j;
1060  }
1061 
1063  const B* getptr () const
1064  {
1065  return this->p;
1066  }
1067 
1069  const size_type* getindexptr () const
1070  {
1071  return this->j;
1072  }
1075  {
1076  return this->n;
1077  }
1078  };
1079 
1080 } // end namespace
1081 
1082 #endif
Implements several basic array containers.
Definition: bvector.hh:585
A allocator_type
export the allocator type
Definition: bvector.hh:597
BlockVectorWindow(const BlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition: bvector.hh:628
@ blocklevel
The number of blocklevels we contain.
Definition: bvector.hh:605
void set(size_type _n, B *_p)
set size and pointer
Definition: bvector.hh:680
B * getptr()
get pointer
Definition: bvector.hh:699
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:609
size_type getsize()
get size
Definition: bvector.hh:705
B::field_type field_type
export the type representing the field
Definition: bvector.hh:591
void setsize(size_type _n)
set size only
Definition: bvector.hh:687
BlockVectorWindow(B *_p, size_type _n)
make array from given pointer and size
Definition: bvector.hh:621
B block_type
export the type representing the components
Definition: bvector.hh:594
BlockVectorWindow()
makes empty array
Definition: bvector.hh:617
A::size_type size_type
The type for the index access.
Definition: bvector.hh:600
BlockVectorWindow(const block_vector_unmanaged< B, A > &_a)
construct from base class object with reference semantics!
Definition: bvector.hh:635
void setptr(B *_p)
set pointer only
Definition: bvector.hh:693
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:612
BlockVectorWindow & operator=(const BlockVectorWindow &a)
assignment
Definition: bvector.hh:647
A vector of blocks with memory management.
Definition: bvector.hh:254
BlockVector()
makes empty vector
Definition: bvector.hh:286
@ blocklevel
The number of blocklevel we contain.
Definition: bvector.hh:274
block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:281
void resize(size_type size, bool copyOldValues=true)
Resize the vector.
Definition: bvector.hh:420
BlockVector(const block_vector_unmanaged< B, A > &_a)
construct from base class object
Definition: bvector.hh:453
BlockVector(size_type _n)
make vector with _n components
Definition: bvector.hh:291
void reserve(size_type capacity, bool copyOldValues=true)
Reserve space.
Definition: bvector.hh:358
BlockVector & operator=(const BlockVector &a)
assignment
Definition: bvector.hh:488
A allocator_type
export the allocator type
Definition: bvector.hh:266
BlockVector(const BlockVector &a)
copy constructor
Definition: bvector.hh:432
block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:278
A::size_type size_type
The type for the index access.
Definition: bvector.hh:269
~BlockVector()
free dynamic memory
Definition: bvector.hh:477
size_type capacity() const
Get the capacity of the vector.
Definition: bvector.hh:401
B::field_type field_type
export the type representing the field
Definition: bvector.hh:260
BlockVector(size_type _n, S _capacity)
Make vector with _n components but preallocating capacity components.
Definition: bvector.hh:319
B block_type
export the type representing the components
Definition: bvector.hh:263
Definition: bvector.hh:926
compressed_block_vector_unmanaged< B, A >::ConstIterator ConstIterator
make iterators available as types
Definition: bvector.hh:953
CompressedBlockVectorWindow & operator=(const CompressedBlockVectorWindow &a)
assignment
Definition: bvector.hh:991
CompressedBlockVectorWindow(const CompressedBlockVectorWindow &a)
copy constructor, this has reference semantics!
Definition: bvector.hh:970
void set(size_type _n, B *_p, size_type *_j)
set size and pointer
Definition: bvector.hh:1025
B * getptr()
get pointer
Definition: bvector.hh:1051
void setsize(size_type _n)
set size only
Definition: bvector.hh:1033
compressed_block_vector_unmanaged< B, A >::Iterator Iterator
make iterators available as types
Definition: bvector.hh:950
CompressedBlockVectorWindow(B *_p, size_type *_j, size_type _n)
make array from given pointers and size
Definition: bvector.hh:962
A::size_type size_type
The type for the index access.
Definition: bvector.hh:941
B::field_type field_type
export the type representing the field
Definition: bvector.hh:932
A allocator_type
export the allocator type
Definition: bvector.hh:938
B block_type
export the type representing the components
Definition: bvector.hh:935
void setptr(B *_p)
set pointer only
Definition: bvector.hh:1039
@ blocklevel
The number of block level this vector contains.
Definition: bvector.hh:946
CompressedBlockVectorWindow()
makes empty array
Definition: bvector.hh:958
size_type getsize() const
get size
Definition: bvector.hh:1074
const B * getptr() const
get pointer
Definition: bvector.hh:1063
const size_type * getindexptr() const
get pointer
Definition: bvector.hh:1069
void setindexptr(size_type *_j)
set pointer only
Definition: bvector.hh:1045
CompressedBlockVectorWindow(const compressed_block_vector_unmanaged< B, A > &_a)
construct from base class object with reference semantics!
Definition: bvector.hh:978
size_type * getindexptr()
get pointer
Definition: bvector.hh:1057
derive error class from the base class in common
Definition: istlexception.hh:16
Iterator implementation class
Definition: basearray.hh:80
A simple array container for objects of type B.
Definition: basearray.hh:41
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:236
An unmanaged vector of blocks.
Definition: bvector.hh:43
block_vector_unmanaged & axpy(const field_type &a, const block_vector_unmanaged &y)
vector space axpy operation
Definition: bvector.hh:115
block_vector_unmanaged & operator-=(const block_vector_unmanaged &y)
vector space subtraction
Definition: bvector.hh:91
PromotionTraits< field_type, typename OtherB::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:133
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition: bvector.hh:176
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: bvector.hh:184
A::size_type size_type
The size type for the index access.
Definition: bvector.hh:58
block_vector_unmanaged & operator=(const field_type &k)
Assignment from a scalar.
Definition: bvector.hh:72
block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition: bvector.hh:234
base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition: bvector.hh:61
block_vector_unmanaged & operator+=(const block_vector_unmanaged &y)
vector space addition
Definition: bvector.hh:81
B::field_type field_type
export the type representing the field
Definition: bvector.hh:49
base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition: bvector.hh:64
block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bvector.hh:101
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: bvector.hh:218
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:192
size_type dim() const
dimension of the vector space
Definition: bvector.hh:224
B value_type
for STL compatibility
Definition: bvector.hh:67
PromotionTraits< field_type, typename OtherB::field_type >::PromotedType dot(const block_vector_unmanaged< OtherB, OtherA > &y) const
vector dot product which corresponds to Petsc's VecDot
Definition: bvector.hh:154
B block_type
export the type representing the components
Definition: bvector.hh:52
block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition: bvector.hh:108
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition: bvector.hh:168
FieldTraits< field_type >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition: bvector.hh:200
A allocator_type
export the allocator type
Definition: bvector.hh:55
FieldTraits< field_type >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bvector.hh:208
iterator class for sequential access
Definition: basearray.hh:596
A simple array container with non-consecutive index set.
Definition: basearray.hh:544
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:717
iterator end()
end iterator
Definition: basearray.hh:697
Definition: bvector.hh:723
compressed_block_vector_unmanaged & operator+=(const V &y)
vector space addition
Definition: bvector.hh:760
FieldTraits< field_type >::real_type one_norm_real() const
simplified one norm (uses Manhattan norm for complex values)
Definition: bvector.hh:833
compressed_block_vector_unmanaged & operator-=(const V &y)
vector space subtraction
Definition: bvector.hh:771
A::size_type size_type
The type for the index access.
Definition: bvector.hh:744
size_type N() const
number of blocks in the vector (are of size 1 here)
Definition: bvector.hh:876
FieldTraits< field_type >::real_type infinity_norm() const
infinity norm (maximum of absolute values of entries)
Definition: bvector.hh:857
field_type operator*(const compressed_block_vector_unmanaged &y) const
scalar product
Definition: bvector.hh:809
B block_type
export the type representing the components
Definition: bvector.hh:732
bool includesindexset(const V &y)
return true if index sets coincide
Definition: bvector.hh:897
A allocator_type
export the allocator type
Definition: bvector.hh:735
compressed_block_vector_unmanaged & operator/=(const field_type &k)
vector space division by scalar
Definition: bvector.hh:799
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:849
B::field_type field_type
export the type representing the field
Definition: bvector.hh:729
size_type dim() const
dimension of the vector space
Definition: bvector.hh:882
compressed_block_vector_unmanaged()
make constructor protected, so only derived classes can be instantiated
Definition: bvector.hh:892
FieldTraits< field_type >::real_type one_norm() const
one norm (sum over absolute values of entries)
Definition: bvector.hh:825
FieldTraits< field_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: bvector.hh:841
compressed_block_vector_unmanaged & axpy(const field_type &a, const V &y)
vector space axpy operation
Definition: bvector.hh:782
compressed_block_vector_unmanaged & operator*=(const field_type &k)
vector space multiplication with scalar
Definition: bvector.hh:792
compressed_base_array_unmanaged< B, A >::const_iterator ConstIterator
make iterators available as types
Definition: bvector.hh:741
compressed_base_array_unmanaged< B, A >::iterator Iterator
make iterators available as types
Definition: bvector.hh:738
FieldTraits< field_type >::real_type infinity_norm_real() const
simplified infinity norm (uses Manhattan norm for complex values)
Definition: bvector.hh:865
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_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
std::ostream & operator<<(std::ostream &s, const array< T, N > &e)
Output operator for array.
Definition: array.hh:159
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Dune namespace.
Definition: alignment.hh:14
Provides some promotion traits.
Fallback implementation of the C++0x static_assert feature.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 15, 22:30, 2024)