dune-istl  2.2.0
Public Types | Public Member Functions | Protected Attributes
Dune::BlockVector< B, A > Class Template Reference

A vector of blocks with memory management. More...

#include <dune/istl/bvector.hh>

Inheritance diagram for Dune::BlockVector< B, A >:
Dune::block_vector_unmanaged< B, A > Dune::base_array_unmanaged< B, A >

List of all members.

Public Types

enum  { blocklevel = B::blocklevel+1 }
 increment block level counter More...
typedef B::field_type field_type
 export the type representing the field
typedef B block_type
 export the type representing the components
typedef A allocator_type
 export the allocator type
typedef A::size_type size_type
 The type for the index access.
typedef block_vector_unmanaged
< B, A >::Iterator 
Iterator
 make iterators available as types
typedef block_vector_unmanaged
< B, A >::ConstIterator 
ConstIterator
 make iterators available as types
typedef B value_type
 for STL compatibility
typedef B member_type
 export the type representing the components
typedef RealIterator< B > iterator
 iterator type for sequential access
typedef RealIterator< const B > const_iterator
 iterator class for sequential access

Public Member Functions

 BlockVector ()
 makes empty vector
 BlockVector (size_type _n)
 make vector with _n components
 BlockVector (size_type _n, size_type capacity)
 Make vector with _n components but preallocating capacity components.
void reserve (size_type capacity, bool copyOldValues=true)
 Reserve space.
size_type capacity () const
 Get the capacity of the vector.
void resize (size_type size, bool copyOldValues=true)
 Resize the vector.
 BlockVector (const BlockVector &a)
 copy constructor
 BlockVector (const block_vector_unmanaged< B, A > &_a)
 construct from base class object
 ~BlockVector ()
 free dynamic memory
BlockVectoroperator= (const BlockVector &a)
 assignment
BlockVectoroperator= (const block_vector_unmanaged< B, A > &a)
 assign from base class object
BlockVectoroperator= (const field_type &k)
 assign from scalar
block_vector_unmanagedoperator+= (const block_vector_unmanaged &y)
 vector space addition
block_vector_unmanagedoperator-= (const block_vector_unmanaged &y)
 vector space subtraction
block_vector_unmanagedoperator*= (const field_type &k)
 vector space multiplication with scalar
block_vector_unmanagedoperator/= (const field_type &k)
 vector space division by scalar
block_vector_unmanagedaxpy (const field_type &a, const block_vector_unmanaged &y)
 vector space axpy operation
field_type operator* (const block_vector_unmanaged &y) const
 scalar product
double one_norm () const
 one norm (sum over absolute values of entries)
double one_norm_real () const
 simplified one norm (uses Manhattan norm for complex values)
double two_norm () const
 two norm sqrt(sum over squared values of entries)
double two_norm2 () const
 sqare of two norm (sum over squared values of entries), need for block recursion
double infinity_norm () const
 infinity norm (maximum of absolute values of entries)
double infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values)
size_type N () const
 number of blocks in the vector (are of size 1 here)
size_type dim () const
 dimension of the vector space
B & operator[] (size_type i)
 random access to blocks
const B & operator[] (size_type i) const
 same for read only access
iterator begin ()
 begin iterator
const_iterator begin () const
 begin const_iterator
iterator end ()
 end iterator
const_iterator end () const
 end const_iterator
iterator beforeEnd ()
const_iterator beforeEnd () const
iterator beforeBegin ()
const_iterator beforeBegin () const
iterator find (size_type i)
 random access returning iterator (end if not contained)
const_iterator find (size_type i) const
 random access returning iterator (end if not contained)
size_type size () const
 number of blocks in the array (are of size 1 here)

Protected Attributes

size_type capacity_
A allocator_
size_type n
B * p

Detailed Description

template<class B, class A = std::allocator<B>>
class Dune::BlockVector< B, A >

A vector of blocks with memory management.

BlockVector adds memory management with ordinary copy semantics to the block_vector_unmanaged template.

Error checking: no error checking is provided normally. Setting the compile time switch DUNE_ISTL_WITH_CHECKING enables error checking.


Member Typedef Documentation

template<class B, class A = std::allocator<B>>
typedef A Dune::BlockVector< B, A >::allocator_type

export the allocator type

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef B Dune::BlockVector< B, A >::block_type

export the type representing the components

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef RealIterator<const B> Dune::base_array_unmanaged< B, A >::const_iterator [inherited]

iterator class for sequential access

Reimplemented in Dune::base_array< B, A >, and Dune::base_array_window< B, A >.

template<class B, class A = std::allocator<B>>
typedef block_vector_unmanaged<B,A>::ConstIterator Dune::BlockVector< B, A >::ConstIterator

make iterators available as types

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef B::field_type Dune::BlockVector< B, A >::field_type

export the type representing the field

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef RealIterator<B> Dune::base_array_unmanaged< B, A >::iterator [inherited]

iterator type for sequential access

Reimplemented in Dune::base_array< B, A >, and Dune::base_array_window< B, A >.

template<class B, class A = std::allocator<B>>
typedef block_vector_unmanaged<B,A>::Iterator Dune::BlockVector< B, A >::Iterator

make iterators available as types

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef B Dune::base_array_unmanaged< B, A >::member_type [inherited]

export the type representing the components

Reimplemented in Dune::base_array< B, A >, and Dune::base_array_window< B, A >.

template<class B, class A = std::allocator<B>>
typedef A::size_type Dune::BlockVector< B, A >::size_type

The type for the index access.

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
typedef B Dune::block_vector_unmanaged< B, A >::value_type [inherited]

for STL compatibility


Member Enumeration Documentation

template<class B, class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator:
blocklevel 

The number of blocklevel we contain.


Constructor & Destructor Documentation

template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( ) [inline]

makes empty vector

template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( size_type  _n) [inline, explicit]

make vector with _n components

template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( size_type  _n,
size_type  capacity 
) [inline]

Make vector with _n components but preallocating capacity components.

If _n > capacity then space for _n entries is allocated.

Note:
This constructor is somewhat dangerous. People may be tempted to write something like
      BlockVector<FieldVector<double,1> > my_vector(100,0);
expecting to obtain a vector of 100 doubles initialized with zero. However, the code calls this constructor which tacitly does something else!
template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( const BlockVector< B, A > &  a) [inline]

copy constructor

template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( const block_vector_unmanaged< B, A > &  _a) [inline]

construct from base class object

template<class B, class A = std::allocator<B>>
Dune::BlockVector< B, A >::~BlockVector ( ) [inline]

free dynamic memory


Member Function Documentation

template<class B, class A = std::allocator<B>>
block_vector_unmanaged& Dune::block_vector_unmanaged< B, A >::axpy ( const field_type a,
const block_vector_unmanaged< B, A > &  y 
) [inline, inherited]

vector space axpy operation

Referenced by Dune::block_vector_unmanaged< T, A >::axpy().

template<class B, class A = std::allocator<B>>
iterator Dune::base_array_unmanaged< B, A >::beforeBegin ( ) [inline, inherited]
Returns:
an iterator that is positioned before the first entry of the vector.
template<class B, class A = std::allocator<B>>
const_iterator Dune::base_array_unmanaged< B, A >::beforeBegin ( ) const [inline, inherited]
Returns:
an iterator that is positioned before the first entry of the vector.

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
iterator Dune::base_array_unmanaged< B, A >::beforeEnd ( ) [inline, inherited]
Returns:
an iterator that is positioned before the end iterator of the vector, i.e. at the last entry.

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
const_iterator Dune::base_array_unmanaged< B, A >::beforeEnd ( ) const [inline, inherited]
Returns:
an iterator that is positioned before the end iterator of the vector. i.e. at the last element.

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
iterator Dune::base_array_unmanaged< B, A >::begin ( ) [inline, inherited]

begin iterator

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

Referenced by test_basearray(), and test_IO().

template<class B, class A = std::allocator<B>>
const_iterator Dune::base_array_unmanaged< B, A >::begin ( ) const [inline, inherited]

begin const_iterator

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
size_type Dune::BlockVector< B, A >::capacity ( ) const [inline]

Get the capacity of the vector.

I. e. the maximum number of elements the vector can hold.

Returns:
The capacity of the vector.

Referenced by Dune::BlockVector< FieldVector< T, n >, A >::BlockVector(), and Dune::BlockVector< FieldVector< T, n >, A >::reserve().

template<class B, class A = std::allocator<B>>
size_type Dune::block_vector_unmanaged< B, A >::dim ( ) const [inline, inherited]

dimension of the vector space

template<class B, class A = std::allocator<B>>
iterator Dune::base_array_unmanaged< B, A >::end ( ) [inline, inherited]

end iterator

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

Referenced by test_basearray(), and test_IO().

template<class B, class A = std::allocator<B>>
const_iterator Dune::base_array_unmanaged< B, A >::end ( ) const [inline, inherited]

end const_iterator

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
iterator Dune::base_array_unmanaged< B, A >::find ( size_type  i) [inline, inherited]

random access returning iterator (end if not contained)

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
const_iterator Dune::base_array_unmanaged< B, A >::find ( size_type  i) const [inline, inherited]

random access returning iterator (end if not contained)

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::infinity_norm ( ) const [inline, inherited]

infinity norm (maximum of absolute values of entries)

Referenced by Dune::block_vector_unmanaged< T, A >::infinity_norm().

template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::infinity_norm_real ( ) const [inline, inherited]

simplified infinity norm (uses Manhattan norm for complex values)

Referenced by Dune::block_vector_unmanaged< T, A >::infinity_norm_real().

template<class B, class A = std::allocator<B>>
size_type Dune::block_vector_unmanaged< B, A >::N ( ) const [inline, inherited]
template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::one_norm ( ) const [inline, inherited]

one norm (sum over absolute values of entries)

template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::one_norm_real ( ) const [inline, inherited]

simplified one norm (uses Manhattan norm for complex values)

template<class B, class A = std::allocator<B>>
field_type Dune::block_vector_unmanaged< B, A >::operator* ( const block_vector_unmanaged< B, A > &  y) const [inline, inherited]

scalar product

template<class B, class A = std::allocator<B>>
block_vector_unmanaged& Dune::block_vector_unmanaged< B, A >::operator*= ( const field_type k) [inline, inherited]

vector space multiplication with scalar

template<class B, class A = std::allocator<B>>
block_vector_unmanaged& Dune::block_vector_unmanaged< B, A >::operator+= ( const block_vector_unmanaged< B, A > &  y) [inline, inherited]

vector space addition

template<class B, class A = std::allocator<B>>
block_vector_unmanaged& Dune::block_vector_unmanaged< B, A >::operator-= ( const block_vector_unmanaged< B, A > &  y) [inline, inherited]

vector space subtraction

template<class B, class A = std::allocator<B>>
block_vector_unmanaged& Dune::block_vector_unmanaged< B, A >::operator/= ( const field_type k) [inline, inherited]

vector space division by scalar

template<class B, class A = std::allocator<B>>
BlockVector& Dune::BlockVector< B, A >::operator= ( const BlockVector< B, A > &  a) [inline]
template<class B, class A = std::allocator<B>>
BlockVector& Dune::BlockVector< B, A >::operator= ( const block_vector_unmanaged< B, A > &  a) [inline]

assign from base class object

template<class B, class A = std::allocator<B>>
BlockVector& Dune::BlockVector< B, A >::operator= ( const field_type k) [inline]

assign from scalar

Reimplemented from Dune::block_vector_unmanaged< B, A >.

template<class B, class A = std::allocator<B>>
B& Dune::base_array_unmanaged< B, A >::operator[] ( size_type  i) [inline, inherited]

random access to blocks

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
const B& Dune::base_array_unmanaged< B, A >::operator[] ( size_type  i) const [inline, inherited]

same for read only access

Reimplemented in Dune::VariableBlockVector< B, A >, and Dune::VariableBlockVector< T, A >.

template<class B, class A = std::allocator<B>>
void Dune::BlockVector< B, A >::reserve ( size_type  capacity,
bool  copyOldValues = true 
) [inline]

Reserve space.

After calling this method the vector can hold up to capacity values. If the specified capacity is smaller than the current capacity and bigger than the current size space will be freed.

If the template parameter copyOldValues is true the values will be copied. If it is false the old values are lost.

Parameters:
capacityThe maximum number of elements the vector needs to hold.
copyOldValuesIf false no object will be copied and the data might be lost. Default value is true.

Referenced by Dune::BlockVector< FieldVector< T, n >, A >::resize().

template<class B, class A = std::allocator<B>>
void Dune::BlockVector< B, A >::resize ( size_type  size,
bool  copyOldValues = true 
) [inline]

Resize the vector.

After calling this method BlockVector::N() will return size If the capacity of the vector is smaller than the specified size then reserve(size) will be called.

If the template parameter copyOldValues is true the values will be copied if the capacity changes. If it is false the old values are lost.

Parameters:
sizeThe new size of the vector.
copyOldValuesIf false no object will be copied and the data might be lost.
template<class B, class A = std::allocator<B>>
size_type Dune::base_array_unmanaged< B, A >::size ( ) const [inline, inherited]

number of blocks in the array (are of size 1 here)

Referenced by Dune::Matrix< T, A >::coldim(), and Dune::BlockVector< FieldVector< T, n >, A >::resize().

template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::two_norm ( ) const [inline, inherited]

two norm sqrt(sum over squared values of entries)

Referenced by test_Iter().

template<class B, class A = std::allocator<B>>
double Dune::block_vector_unmanaged< B, A >::two_norm2 ( ) const [inline, inherited]

sqare of two norm (sum over squared values of entries), need for block recursion


Member Data Documentation

template<class B, class A = std::allocator<B>>
A Dune::BlockVector< B, A >::allocator_ [protected]
template<class B, class A = std::allocator<B>>
size_type Dune::BlockVector< B, A >::capacity_ [protected]
template<class B, class A = std::allocator<B>>
size_type Dune::base_array_unmanaged< B, A >::n [protected, inherited]

Referenced by Dune::base_array_window< B, A >::advance(), Dune::block_vector_unmanaged< T, A >::axpy(), Dune::base_array< B, A >::base_array(), Dune::base_array_unmanaged< T, A >::beforeEnd(), Dune::BlockVector< FieldVector< T, n >, A >::BlockVector(), Dune::BlockVectorWindow< B, A >::BlockVectorWindow(), Dune::block_vector_unmanaged< T, A >::dim(), Dune::base_array_unmanaged< T, A >::end(), Dune::base_array_unmanaged< T, A >::find(), Dune::BlockVectorWindow< B, A >::getsize(), Dune::block_vector_unmanaged< T, A >::infinity_norm(), Dune::block_vector_unmanaged< T, A >::infinity_norm_real(), Dune::base_array_window< B, A >::move(), Dune::block_vector_unmanaged< T, A >::N(), Dune::block_vector_unmanaged< T, A >::one_norm(), Dune::block_vector_unmanaged< T, A >::one_norm_real(), Dune::block_vector_unmanaged< T, A >::operator*(), Dune::block_vector_unmanaged< T, A >::operator*=(), Dune::VariableBlockVector< B, A >::CreateIterator::operator++(), Dune::block_vector_unmanaged< T, A >::operator+=(), Dune::block_vector_unmanaged< T, A >::operator-=(), Dune::block_vector_unmanaged< T, A >::operator/=(), Dune::block_vector_unmanaged< T, A >::operator=(), Dune::VariableBlockVector< T, A >::operator=(), Dune::BlockVector< FieldVector< T, n >, A >::operator=(), Dune::base_array< B, A >::operator=(), Dune::BlockVectorWindow< B, A >::operator=(), Dune::base_array_unmanaged< T, A >::operator[](), Dune::VariableBlockVector< T, A >::resize(), Dune::BlockVector< FieldVector< T, n >, A >::resize(), Dune::base_array< B, A >::resize(), Dune::base_array_window< B, A >::set(), Dune::BlockVectorWindow< B, A >::set(), Dune::BlockVectorWindow< B, A >::setsize(), Dune::base_array_unmanaged< T, A >::size(), Dune::block_vector_unmanaged< T, A >::two_norm(), Dune::block_vector_unmanaged< T, A >::two_norm2(), Dune::VariableBlockVector< T, A >::VariableBlockVector(), Dune::base_array< B, A >::~base_array(), and Dune::VariableBlockVector< T, A >::~VariableBlockVector().

template<class B, class A = std::allocator<B>>
B* Dune::base_array_unmanaged< B, A >::p [protected, inherited]

The documentation for this class was generated from the following file: