dune-common 2.9.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Related Symbols | List of all members
Dune::DynamicVector< K, Allocator > Class Template Reference

Construct a vector with a dynamic size. More...

#include <dune/common/dynvector.hh>

Inheritance diagram for Dune::DynamicVector< K, Allocator >:
Inheritance graph

Public Types

typedef Base::size_type size_type
 
typedef Base::value_type value_type
 
typedef std::vector< K, Allocator > container_type
 
typedef Allocator allocator_type
 
typedef Traits::derived_type derived_type
 type of derived vector class
 
typedef FieldTraits< value_type >::field_type field_type
 export the type representing the field
 
typedef Traits::value_type block_type
 export the type representing the components
 
typedef DenseIterator< DenseVector, value_typeIterator
 Iterator class for sequential access.
 
typedef Iterator iterator
 typedef for stl compliant access
 
typedef DenseIterator< const DenseVector, const value_typeConstIterator
 ConstIterator class for sequential access.
 
typedef ConstIterator const_iterator
 typedef for stl compliant access
 

Public Member Functions

 DynamicVector (const allocator_type &a=allocator_type())
 Constructor making uninitialized vector.
 
 DynamicVector (size_type n, const allocator_type &a=allocator_type())
 
 DynamicVector (size_type n, value_type c, const allocator_type &a=allocator_type())
 Constructor making vector with identical coordinates.
 
 DynamicVector (std::initializer_list< K > const &l)
 Construct from a std::initializer_list.
 
 DynamicVector (const DynamicVector &x)
 Constructor making vector with identical coordinates.
 
 DynamicVector (DynamicVector &&x)
 Move constructor.
 
template<class T >
 DynamicVector (const DynamicVector< T, Allocator > &x)
 
template<class X >
 DynamicVector (const DenseVector< X > &x, const allocator_type &a=allocator_type())
 Copy constructor from another DenseVector.
 
DynamicVectoroperator= (const DynamicVector &other)
 Copy assignment operator.
 
DynamicVectoroperator= (DynamicVector &&other)
 Move assignment operator.
 
size_type capacity () const
 Number of elements for which memory has been allocated.
 
void resize (size_type n, value_type c=value_type())
 
void reserve (size_type n)
 
size_type size () const
 
K & operator[] (size_type i)
 
const K & operator[] (size_type i) const
 
K * data () noexcept
 return pointer to underlying array
 
const K * data () const noexcept
 return pointer to underlying array
 
const container_typecontainer () const
 
container_typecontainer ()
 
derived_typeoperator= (const value_type &k)
 Assignment operator for scalar.
 
DenseVectoroperator= (const DenseVector &)=default
 Assignment operator for other DenseVector of same type.
 
template<typename W , std::enable_if_t< std::is_assignable< value_type &, typename DenseVector< W >::value_type >::value, int > = 0>
derived_typeoperator= (const DenseVector< W > &other)
 Assignment operator for other DenseVector of different type.
 
value_typefront ()
 return reference to first element
 
const value_typefront () const
 return reference to first element
 
value_typeback ()
 return reference to last element
 
const value_typeback () const
 return reference to last element
 
bool empty () const
 checks whether the container is empty
 
Iterator begin ()
 begin iterator
 
ConstIterator begin () const
 begin ConstIterator
 
Iterator end ()
 end iterator
 
ConstIterator end () const
 end ConstIterator
 
Iterator beforeEnd ()
 
ConstIterator beforeEnd () const
 
Iterator beforeBegin ()
 
ConstIterator beforeBegin () const
 
Iterator find (size_type i)
 return iterator to given element or end()
 
ConstIterator find (size_type i) const
 return iterator to given element or end()
 
template<class Other >
derived_typeoperator+= (const DenseVector< Other > &x)
 vector space addition
 
template<typename ValueType >
std::enable_if< std::is_convertible< ValueType, value_type >::value, derived_type >::type & operator+= (const ValueType &kk)
 vector space add scalar to all comps
 
template<class Other >
derived_typeoperator-= (const DenseVector< Other > &x)
 vector space subtraction
 
template<typename ValueType >
std::enable_if< std::is_convertible< ValueType, value_type >::value, derived_type >::type & operator-= (const ValueType &kk)
 vector space subtract scalar from all comps
 
template<class Other >
derived_type operator+ (const DenseVector< Other > &b) const
 Binary vector addition.
 
template<class Other >
derived_type operator- (const DenseVector< Other > &b) const
 Binary vector subtraction.
 
derived_type operator- () const
 Vector negation.
 
template<typename FieldType >
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & operator*= (const FieldType &kk)
 vector space multiplication with scalar
 
template<typename FieldType >
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & operator/= (const FieldType &kk)
 vector space division by scalar
 
template<class Other >
bool operator== (const DenseVector< Other > &x) const
 Binary vector comparison.
 
template<class Other >
bool operator!= (const DenseVector< Other > &x) const
 Binary vector incomparison.
 
template<class Other >
derived_typeaxpy (const field_type &a, const DenseVector< Other > &x)
 vector space axpy operation ( *this += a x )
 
template<class Other >
PromotionTraits< field_type, typenameDenseVector< Other >::field_type >::PromotedType operator* (const DenseVector< Other > &x) const
 indefinite vector dot product $\left (x^T \cdot y \right)$ which corresponds to Petsc's VecTDot
 
template<class Other >
PromotionTraits< field_type, typenameDenseVector< Other >::field_type >::PromotedType dot (const DenseVector< Other > &x) const
 vector dot product $\left (x^H \cdot y \right)$ which corresponds to Petsc's VecDot
 
FieldTraits< value_type >::real_type one_norm () const
 one norm (sum over absolute values of entries)
 
FieldTraits< value_type >::real_type one_norm_real () const
 simplified one norm (uses Manhattan norm for complex values)
 
FieldTraits< value_type >::real_type two_norm () const
 two norm sqrt(sum over squared values of entries)
 
FieldTraits< value_type >::real_type two_norm2 () const
 square of two norm (sum over squared values of entries), need for block recursion
 
template<typename vt = value_type, typename std::enable_if<!HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type infinity_norm () const
 infinity norm (maximum of absolute values of entries)
 
template<typename vt = value_type, typename std::enable_if< HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type infinity_norm () const
 infinity norm (maximum of absolute values of entries)
 
template<typename vt = value_type, typename std::enable_if<!HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values)
 
template<typename vt = value_type, typename std::enable_if< HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type 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
 

Static Public Attributes

static constexpr int blocklevel = 1
 The number of block levels we contain. This is the leaf, that is, 1.
 

Related Symbols

(Note that these are not member symbols.)

template<class K , class Allocator >
std::istream & operator>> (std::istream &in, DynamicVector< K, Allocator > &v)
 Read a DynamicVector from an input stream.
 
template<typename V >
std::ostream & operator<< (std::ostream &s, const DenseVector< V > &v)
 Write a DenseVector to an output stream.
 

Detailed Description

template<class K, class Allocator = std::allocator< K >>
class Dune::DynamicVector< K, Allocator >

Construct a vector with a dynamic size.

Template Parameters
Kis the field type (use float, double, complex, etc)
Allocatortype of allocator object used to define the storage allocation model, default Allocator = std::allocator< K >.

Member Typedef Documentation

◆ allocator_type

template<class K , class Allocator = std::allocator< K >>
typedef Allocator Dune::DynamicVector< K, Allocator >::allocator_type

◆ block_type

template<typename V >
typedef Traits::value_type Dune::DenseVector< V >::block_type
inherited

export the type representing the components

◆ const_iterator

template<typename V >
typedef ConstIterator Dune::DenseVector< V >::const_iterator
inherited

typedef for stl compliant access

◆ ConstIterator

template<typename V >
typedef DenseIterator<const DenseVector,const value_type> Dune::DenseVector< V >::ConstIterator
inherited

ConstIterator class for sequential access.

◆ container_type

template<class K , class Allocator = std::allocator< K >>
typedef std::vector< K, Allocator > Dune::DynamicVector< K, Allocator >::container_type

◆ derived_type

template<typename V >
typedef Traits::derived_type Dune::DenseVector< V >::derived_type
inherited

type of derived vector class

◆ field_type

template<typename V >
typedef FieldTraits<value_type>::field_type Dune::DenseVector< V >::field_type
inherited

export the type representing the field

◆ Iterator

template<typename V >
typedef DenseIterator<DenseVector,value_type> Dune::DenseVector< V >::Iterator
inherited

Iterator class for sequential access.

◆ iterator

template<typename V >
typedef Iterator Dune::DenseVector< V >::iterator
inherited

typedef for stl compliant access

◆ size_type

template<class K , class Allocator = std::allocator< K >>
typedef Base::size_type Dune::DynamicVector< K, Allocator >::size_type

◆ value_type

template<class K , class Allocator = std::allocator< K >>
typedef Base::value_type Dune::DynamicVector< K, Allocator >::value_type

Constructor & Destructor Documentation

◆ DynamicVector() [1/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( const allocator_type a = allocator_type())
inlineexplicit

Constructor making uninitialized vector.

◆ DynamicVector() [2/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( size_type  n,
const allocator_type a = allocator_type() 
)
inlineexplicit

◆ DynamicVector() [3/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( size_type  n,
value_type  c,
const allocator_type a = allocator_type() 
)
inline

Constructor making vector with identical coordinates.

◆ DynamicVector() [4/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( std::initializer_list< K > const &  l)
inline

Construct from a std::initializer_list.

◆ DynamicVector() [5/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( const DynamicVector< K, Allocator > &  x)
inline

Constructor making vector with identical coordinates.

◆ DynamicVector() [6/8]

template<class K , class Allocator = std::allocator< K >>
Dune::DynamicVector< K, Allocator >::DynamicVector ( DynamicVector< K, Allocator > &&  x)
inline

Move constructor.

◆ DynamicVector() [7/8]

template<class K , class Allocator = std::allocator< K >>
template<class T >
Dune::DynamicVector< K, Allocator >::DynamicVector ( const DynamicVector< T, Allocator > &  x)
inline

◆ DynamicVector() [8/8]

template<class K , class Allocator = std::allocator< K >>
template<class X >
Dune::DynamicVector< K, Allocator >::DynamicVector ( const DenseVector< X > &  x,
const allocator_type a = allocator_type() 
)
inline

Copy constructor from another DenseVector.

Member Function Documentation

◆ axpy()

template<typename V >
template<class Other >
derived_type & Dune::DenseVector< V >::axpy ( const field_type a,
const DenseVector< Other > &  x 
)
inlineinherited

vector space axpy operation ( *this += a x )

◆ back() [1/2]

template<typename V >
value_type & Dune::DenseVector< V >::back ( )
inlineinherited

return reference to last element

◆ back() [2/2]

template<typename V >
const value_type & Dune::DenseVector< V >::back ( ) const
inlineinherited

return reference to last element

◆ beforeBegin() [1/2]

template<typename V >
Iterator Dune::DenseVector< V >::beforeBegin ( )
inlineinherited
Returns
an iterator that is positioned before the first entry of the vector.

◆ beforeBegin() [2/2]

template<typename V >
ConstIterator Dune::DenseVector< V >::beforeBegin ( ) const
inlineinherited
Returns
an iterator that is positioned before the first entry of the vector.

◆ beforeEnd() [1/2]

template<typename V >
Iterator Dune::DenseVector< V >::beforeEnd ( )
inlineinherited
Returns
an iterator that is positioned before the end iterator of the vector, i.e. at the last entry.

◆ beforeEnd() [2/2]

template<typename V >
ConstIterator Dune::DenseVector< V >::beforeEnd ( ) const
inlineinherited
Returns
an iterator that is positioned before the end iterator of the vector. i.e. at the last element

◆ begin() [1/2]

template<typename V >
Iterator Dune::DenseVector< V >::begin ( )
inlineinherited

begin iterator

◆ begin() [2/2]

template<typename V >
ConstIterator Dune::DenseVector< V >::begin ( ) const
inlineinherited

begin ConstIterator

◆ capacity()

template<class K , class Allocator = std::allocator< K >>
size_type Dune::DynamicVector< K, Allocator >::capacity ( ) const
inline

Number of elements for which memory has been allocated.

capacity() is always greater than or equal to size().

◆ container() [1/2]

template<class K , class Allocator = std::allocator< K >>
container_type & Dune::DynamicVector< K, Allocator >::container ( )
inline

◆ container() [2/2]

template<class K , class Allocator = std::allocator< K >>
const container_type & Dune::DynamicVector< K, Allocator >::container ( ) const
inline

◆ data() [1/2]

template<class K , class Allocator = std::allocator< K >>
const K * Dune::DynamicVector< K, Allocator >::data ( ) const
inlinenoexcept

return pointer to underlying array

◆ data() [2/2]

template<class K , class Allocator = std::allocator< K >>
K * Dune::DynamicVector< K, Allocator >::data ( )
inlinenoexcept

return pointer to underlying array

◆ dim()

template<typename V >
size_type Dune::DenseVector< V >::dim ( ) const
inlineinherited

dimension of the vector space

◆ dot()

template<typename V >
template<class Other >
PromotionTraits< field_type, typenameDenseVector< Other >::field_type >::PromotedType Dune::DenseVector< V >::dot ( const DenseVector< Other > &  x) const
inlineinherited

vector dot product $\left (x^H \cdot y \right)$ which corresponds to Petsc's VecDot

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecDot.html

Parameters
xother vector
Returns

◆ empty()

template<typename V >
bool Dune::DenseVector< V >::empty ( ) const
inlineinherited

checks whether the container is empty

◆ end() [1/2]

template<typename V >
Iterator Dune::DenseVector< V >::end ( )
inlineinherited

end iterator

◆ end() [2/2]

template<typename V >
ConstIterator Dune::DenseVector< V >::end ( ) const
inlineinherited

end ConstIterator

◆ find() [1/2]

template<typename V >
Iterator Dune::DenseVector< V >::find ( size_type  i)
inlineinherited

return iterator to given element or end()

◆ find() [2/2]

template<typename V >
ConstIterator Dune::DenseVector< V >::find ( size_type  i) const
inlineinherited

return iterator to given element or end()

◆ front() [1/2]

template<typename V >
value_type & Dune::DenseVector< V >::front ( )
inlineinherited

return reference to first element

◆ front() [2/2]

template<typename V >
const value_type & Dune::DenseVector< V >::front ( ) const
inlineinherited

return reference to first element

◆ infinity_norm() [1/2]

template<typename V >
template<typename vt = value_type, typename std::enable_if<!HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type Dune::DenseVector< V >::infinity_norm ( ) const
inlineinherited

infinity norm (maximum of absolute values of entries)

◆ infinity_norm() [2/2]

template<typename V >
template<typename vt = value_type, typename std::enable_if< HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type Dune::DenseVector< V >::infinity_norm ( ) const
inlineinherited

infinity norm (maximum of absolute values of entries)

◆ infinity_norm_real() [1/2]

template<typename V >
template<typename vt = value_type, typename std::enable_if<!HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type Dune::DenseVector< V >::infinity_norm_real ( ) const
inlineinherited

simplified infinity norm (uses Manhattan norm for complex values)

◆ infinity_norm_real() [2/2]

template<typename V >
template<typename vt = value_type, typename std::enable_if< HasNaN< vt >::value, int >::type = 0>
FieldTraits< vt >::real_type Dune::DenseVector< V >::infinity_norm_real ( ) const
inlineinherited

simplified infinity norm (uses Manhattan norm for complex values)

◆ N()

template<typename V >
size_type Dune::DenseVector< V >::N ( ) const
inlineinherited

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

◆ one_norm()

template<typename V >
FieldTraits< value_type >::real_type Dune::DenseVector< V >::one_norm ( ) const
inlineinherited

one norm (sum over absolute values of entries)

◆ one_norm_real()

template<typename V >
FieldTraits< value_type >::real_type Dune::DenseVector< V >::one_norm_real ( ) const
inlineinherited

simplified one norm (uses Manhattan norm for complex values)

◆ operator!=()

template<typename V >
template<class Other >
bool Dune::DenseVector< V >::operator!= ( const DenseVector< Other > &  x) const
inlineinherited

Binary vector incomparison.

◆ operator*()

template<typename V >
template<class Other >
PromotionTraits< field_type, typenameDenseVector< Other >::field_type >::PromotedType Dune::DenseVector< V >::operator* ( const DenseVector< Other > &  x) const
inlineinherited

indefinite vector dot product $\left (x^T \cdot y \right)$ which corresponds to Petsc's VecTDot

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecTDot.html

Parameters
xother vector
Returns

◆ operator*=()

template<typename V >
template<typename FieldType >
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & Dune::DenseVector< V >::operator*= ( const FieldType &  kk)
inlineinherited

vector space multiplication with scalar

we use enable_if to avoid an ambiguity, if the function parameter can be converted to field_type implicitly. (see FS#1457)

The function is only enabled, if the parameter is directly convertible to field_type.

◆ operator+()

template<typename V >
template<class Other >
derived_type Dune::DenseVector< V >::operator+ ( const DenseVector< Other > &  b) const
inlineinherited

Binary vector addition.

◆ operator+=() [1/2]

template<typename V >
template<class Other >
derived_type & Dune::DenseVector< V >::operator+= ( const DenseVector< Other > &  x)
inlineinherited

vector space addition

◆ operator+=() [2/2]

template<typename V >
template<typename ValueType >
std::enable_if< std::is_convertible< ValueType, value_type >::value, derived_type >::type & Dune::DenseVector< V >::operator+= ( const ValueType &  kk)
inlineinherited

vector space add scalar to all comps

we use enable_if to avoid an ambiguity, if the function parameter can be converted to value_type implicitly. (see FS#1457)

The function is only enabled, if the parameter is directly convertible to value_type.

◆ operator-() [1/2]

template<typename V >
derived_type Dune::DenseVector< V >::operator- ( ) const
inlineinherited

Vector negation.

◆ operator-() [2/2]

template<typename V >
template<class Other >
derived_type Dune::DenseVector< V >::operator- ( const DenseVector< Other > &  b) const
inlineinherited

Binary vector subtraction.

◆ operator-=() [1/2]

template<typename V >
template<class Other >
derived_type & Dune::DenseVector< V >::operator-= ( const DenseVector< Other > &  x)
inlineinherited

vector space subtraction

◆ operator-=() [2/2]

template<typename V >
template<typename ValueType >
std::enable_if< std::is_convertible< ValueType, value_type >::value, derived_type >::type & Dune::DenseVector< V >::operator-= ( const ValueType &  kk)
inlineinherited

vector space subtract scalar from all comps

we use enable_if to avoid an ambiguity, if the function parameter can be converted to value_type implicitly. (see FS#1457)

The function is only enabled, if the parameter is directly convertible to value_type.

◆ operator/=()

template<typename V >
template<typename FieldType >
std::enable_if< std::is_convertible< FieldType, field_type >::value, derived_type >::type & Dune::DenseVector< V >::operator/= ( const FieldType &  kk)
inlineinherited

vector space division by scalar

we use enable_if to avoid an ambiguity, if the function parameter can be converted to field_type implicitly. (see FS#1457)

The function is only enabled, if the parameter is directly convertible to field_type.

◆ operator=() [1/5]

template<class K , class Allocator = std::allocator< K >>
DenseVector & Dune::DenseVector< V >::operator= ( const DenseVector )
default

Assignment operator for other DenseVector of same type.

◆ operator=() [2/5]

template<class K , class Allocator = std::allocator< K >>
template<typename W , std::enable_if_t< std::is_assignable< value_type &, typename DenseVector< W >::value_type >::value, int > = 0>
derived_type & Dune::DenseVector< V >::operator= ( const DenseVector< W > &  other)
inline

Assignment operator for other DenseVector of different type.

◆ operator=() [3/5]

template<class K , class Allocator = std::allocator< K >>
DynamicVector & Dune::DynamicVector< K, Allocator >::operator= ( const DynamicVector< K, Allocator > &  other)
inline

Copy assignment operator.

◆ operator=() [4/5]

template<class K , class Allocator = std::allocator< K >>
derived_type & Dune::DenseVector< V >::operator= ( const value_type k)
inline

Assignment operator for scalar.

◆ operator=() [5/5]

template<class K , class Allocator = std::allocator< K >>
DynamicVector & Dune::DynamicVector< K, Allocator >::operator= ( DynamicVector< K, Allocator > &&  other)
inline

Move assignment operator.

◆ operator==()

template<typename V >
template<class Other >
bool Dune::DenseVector< V >::operator== ( const DenseVector< Other > &  x) const
inlineinherited

Binary vector comparison.

◆ operator[]() [1/2]

template<class K , class Allocator = std::allocator< K >>
K & Dune::DynamicVector< K, Allocator >::operator[] ( size_type  i)
inline

◆ operator[]() [2/2]

template<class K , class Allocator = std::allocator< K >>
const K & Dune::DynamicVector< K, Allocator >::operator[] ( size_type  i) const
inline

◆ reserve()

template<class K , class Allocator = std::allocator< K >>
void Dune::DynamicVector< K, Allocator >::reserve ( size_type  n)
inline

◆ resize()

template<class K , class Allocator = std::allocator< K >>
void Dune::DynamicVector< K, Allocator >::resize ( size_type  n,
value_type  c = value_type() 
)
inline

◆ size()

template<class K , class Allocator = std::allocator< K >>
size_type Dune::DynamicVector< K, Allocator >::size ( ) const
inline

◆ two_norm()

template<typename V >
FieldTraits< value_type >::real_type Dune::DenseVector< V >::two_norm ( ) const
inlineinherited

two norm sqrt(sum over squared values of entries)

◆ two_norm2()

template<typename V >
FieldTraits< value_type >::real_type Dune::DenseVector< V >::two_norm2 ( ) const
inlineinherited

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

Member Data Documentation

◆ blocklevel

template<typename V >
constexpr int Dune::DenseVector< V >::blocklevel = 1
staticconstexprinherited

The number of block levels we contain. This is the leaf, that is, 1.


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