Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ug::Vector< TValueType > Class Template Reference

#include <vector.h>

+ Inheritance diagram for ug::Vector< TValueType >:

Public Types

typedef TValueType value_type
 
typedef Vector< TValueType > vector_type
 

Public Member Functions

template<typename V >
void add (const V &u)
 
void add (const value_type *u, const size_t *indices, size_t nr)
 
size_t capacity () const
 
SmartPtr< vector_typeclone () const
 clones the vector (deep-copy) including values
 
SmartPtr< vector_typeclone_without_values () const
 clones the vector (deep-copy) excluding values
 
void create (const Vector &v)
 create as a copy of other vector
 
void create (size_t size)
 create a vector with specific size
 
size_t defragment ()
 
double dotprod (const Vector &w)
 returns v.T w, that is the dotprod of this vector and w
 
template<typename V >
void get (V &u) const
 
void get (value_type *u, const size_t *indices, size_t nr) const
 
double maxnorm () const
 return max values[i] (max norm)
 
double norm () const
 return sqrt(sum values[i]^2) (euclidian norm)
 
void operator*= (const number &a)
 
void operator+= (const Vector &v)
 
void operator-= (const Vector &v)
 
void operator= (const Vector &v)
 assign other vector v
 
double operator= (double d)
 assign double d to whole Vector
 
value_typeoperator[] (size_t i)
 access element i of the vector
 
const value_typeoperator[] (size_t i) const
 
void p ()
 gdb shortcut for print
 
void print (const char *const text=NULL) const
 print vector to console
 
void reserve (size_t newCapacity, bool bCopyValues=true)
 
void reserve_exactly (size_t newCapacity, bool bCopyValues)
 
void reserve_sloppy (size_t newCapacity, bool bCopyValues=true)
 
void resize (size_t newSize, bool bCopyValues=true)
 
void resize_exactly (size_t newSize, bool bCopyValues=true)
 resize the vector to be EXACTLY newSize big (no overhead)
 
void resize_sloppy (size_t newSize, bool bCopyValues=true)
 
template<typename V >
void set (const V &u)
 
void set (const value_type *u, const size_t *indices, size_t nr)
 
void set (double d)
 assign double d to whole Vector
 
void set_random (double from, double to)
 
size_t size () const
 
 Vector ()
 constructor
 
 Vector (const vector_type &v)
 
 Vector (size_t size)
 constructor with size
 
virtual ~Vector ()
 virtual destructor
 

Protected Member Functions

virtual vector_typevirtual_clone () const
 virtual clone using covariant return type
 
virtual vector_typevirtual_clone_without_values () const
 virtual clone using covariant return type excluding values
 

Private Member Functions

void destroy ()
 

Private Attributes

size_t m_capacity
 size of the vector (vector is from 0..size-1)
 
size_t m_size
 size of the vector (vector is from 0..size-1)
 
value_typevalues
 array where the values are stored, size m_size
 

Friends

std::ostream & operator<< (std::ostream &output, const Vector &v)
 ostream << operator
 

Member Typedef Documentation

◆ value_type

template<typename TValueType >
typedef TValueType ug::Vector< TValueType >::value_type

◆ vector_type

template<typename TValueType >
typedef Vector<TValueType> ug::Vector< TValueType >::vector_type

Constructor & Destructor Documentation

◆ Vector() [1/3]

template<typename value_type >
Vector< value_type >::Vector ( )

constructor

◆ Vector() [2/3]

◆ ~Vector()

template<typename value_type >
Vector< value_type >::~Vector ( )
virtual

virtual destructor

◆ Vector() [3/3]

Member Function Documentation

◆ add() [1/2]

template<typename value_type >
template<typename V >
void Vector< value_type >::add ( const V &  u)

add/set/get a local vector

The local vector type must provide the following members:

  • size() - length of local vector
  • index(size_t i) - global index for component i
  • operator[](size_t i) - access to value of component i

◆ add() [2/2]

template<typename value_type >
void Vector< value_type >::add ( const value_type u,
const size_t *  indices,
size_t  nr 
)

◆ capacity()

template<typename TValueType >
size_t ug::Vector< TValueType >::capacity ( ) const
inline

◆ clone()

template<typename value_type >
SmartPtr< Vector< value_type > > Vector< value_type >::clone ( ) const

clones the vector (deep-copy) including values

◆ clone_without_values()

template<typename value_type >
SmartPtr< Vector< value_type > > Vector< value_type >::clone_without_values ( ) const

clones the vector (deep-copy) excluding values

◆ create() [1/2]

template<typename value_type >
void Vector< value_type >::create ( const Vector< TValueType > &  v)

create as a copy of other vector

References ug::Vector< TValueType >::m_size, UG_ASSERT, and ug::Vector< TValueType >::values.

◆ create() [2/2]

template<typename value_type >
void Vector< value_type >::create ( size_t  size)

create a vector with specific size

Referenced by ug::Vector< TValueType >::Vector(), and ug::Vector< TValueType >::Vector().

◆ defragment()

template<typename TValueType >
size_t ug::Vector< TValueType >::defragment ( )
inline

◆ destroy()

template<typename value_type >
void Vector< value_type >::destroy ( )
private

◆ dotprod()

template<typename value_type >
double Vector< value_type >::dotprod ( const Vector< TValueType > &  w)
inline

returns v.T w, that is the dotprod of this vector and w

References ug::Vector< TValueType >::m_size, UG_ASSERT, and ug::VecProd().

◆ get() [1/2]

template<typename value_type >
template<typename V >
void Vector< value_type >::get ( V &  u) const

◆ get() [2/2]

template<typename value_type >
void Vector< value_type >::get ( value_type u,
const size_t *  indices,
size_t  nr 
) const

◆ maxnorm()

template<typename value_type >
double Vector< value_type >::maxnorm ( ) const
inline

return max values[i] (max norm)

References ug::BlockMaxNorm().

◆ norm()

template<typename value_type >
double Vector< value_type >::norm ( ) const
inline

return sqrt(sum values[i]^2) (euclidian norm)

References ug::BlockNorm2().

◆ operator*=()

template<typename TValueType >
void ug::Vector< TValueType >::operator*= ( const number a)
inline

◆ operator+=()

template<typename value_type >
void Vector< value_type >::operator+= ( const Vector< TValueType > &  v)
inline

◆ operator-=()

template<typename value_type >
void Vector< value_type >::operator-= ( const Vector< TValueType > &  v)
inline

◆ operator=() [1/2]

template<typename value_type >
void Vector< value_type >::operator= ( const Vector< TValueType > &  v)
inline

assign other vector v

References resize(), and ug::Vector< TValueType >::size().

◆ operator=() [2/2]

template<typename value_type >
double Vector< value_type >::operator= ( double  d)
inline

assign double d to whole Vector

Referenced by ug::Vector< TValueType >::set(), and ug::Vector< TValueType >::Vector().

◆ operator[]() [1/2]

template<typename value_type >
value_type & Vector< value_type >::operator[] ( size_t  i)
inline

access element i of the vector

References UG_ASSERT.

Referenced by ug::GPUVector< TValueType >::operator[](), and ug::GPUVector< TValueType >::operator[]().

◆ operator[]() [2/2]

template<typename value_type >
const value_type & Vector< value_type >::operator[] ( size_t  i) const
inline

References UG_ASSERT.

◆ p()

template<typename TValueType >
void ug::Vector< TValueType >::p ( )
inline

◆ print()

template<typename value_type >
void Vector< value_type >::print ( const char *const  text = NULL) const

print vector to console

Referenced by ug::Vector< TValueType >::p().

◆ reserve()

template<typename TValueType >
void ug::Vector< TValueType >::reserve ( size_t  newCapacity,
bool  bCopyValues = true 
)
inline

◆ reserve_exactly()

template<typename value_type >
void Vector< value_type >::reserve_exactly ( size_t  newCapacity,
bool  bCopyValues 
)

reserve will allocate EXACTLY newCapacity assertion if newCapacity < size

References UG_ASSERT.

Referenced by ug::Vector< TValueType >::reserve().

◆ reserve_sloppy()

template<typename value_type >
void Vector< value_type >::reserve_sloppy ( size_t  newCapacity,
bool  bCopyValues = true 
)

reserve capacity in vector. if bigger than capacity, new capacity is newCapacity+oldCapacity/2

◆ resize()

◆ resize_exactly()

template<typename value_type >
void Vector< value_type >::resize_exactly ( size_t  newSize,
bool  bCopyValues = true 
)

resize the vector to be EXACTLY newSize big (no overhead)

Referenced by ug::Vector< TValueType >::resize().

◆ resize_sloppy()

template<typename value_type >
void Vector< value_type >::resize_sloppy ( size_t  newSize,
bool  bCopyValues = true 
)

resize vector. if bigger than capacity, new capacity is newSize+oldSize/2 so growth factor is 1.5 (this is to keep memory overhead small)

See also
also https://github.com/facebook/folly/blob/master/folly/docs/FBVector.md

◆ set() [1/3]

template<typename value_type >
template<typename V >
void Vector< value_type >::set ( const V &  u)

◆ set() [2/3]

template<typename value_type >
void Vector< value_type >::set ( const value_type u,
const size_t *  indices,
size_t  nr 
)

◆ set() [3/3]

template<typename TValueType >
void ug::Vector< TValueType >::set ( double  d)
inline

assign double d to whole Vector

References ug::Vector< TValueType >::operator=().

◆ set_random()

template<typename value_type >
void Vector< value_type >::set_random ( double  from,
double  to 
)
inline

◆ size()

◆ virtual_clone()

template<typename value_type >
Vector< value_type > * Vector< value_type >::virtual_clone ( ) const
protectedvirtual

virtual clone using covariant return type

This should be used instead of the copy constructor at the places where the additional information stored in the object of the derived class (like the geometry or the topology of the grid) should be kept.

Reimplemented in ug::GPUVector< TValueType >, and ug::ParallelVector< Vector< double > >.

◆ virtual_clone_without_values()

template<typename value_type >
Vector< value_type > * Vector< value_type >::virtual_clone_without_values ( ) const
protectedvirtual

virtual clone using covariant return type excluding values

This should be used instead of the copy constructor at the places where the additional information stored in the object of the derived class (like the geometry or the topology of the grid) should be kept.

Reimplemented in ug::GPUVector< TValueType >, and ug::ParallelVector< Vector< double > >.

Friends And Related Symbol Documentation

◆ operator<<

template<typename TValueType >
std::ostream & operator<< ( std::ostream &  output,
const Vector< TValueType > &  v 
)
friend

ostream << operator

Member Data Documentation

◆ m_capacity

template<typename TValueType >
size_t ug::Vector< TValueType >::m_capacity
private

size of the vector (vector is from 0..size-1)

Referenced by ug::Vector< TValueType >::capacity(), and ug::Vector< TValueType >::Vector().

◆ m_size

template<typename TValueType >
size_t ug::Vector< TValueType >::m_size
private

◆ values

template<typename TValueType >
value_type* ug::Vector< TValueType >::values
private

array where the values are stored, size m_size

Referenced by ug::Vector< TValueType >::create(), ug::Vector< TValueType >::operator*=(), and ug::Vector< TValueType >::Vector().


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