Feel++  0.91.4
Classes
Feel::VectorUblas< T, Storage > Class Template Reference

interface to vector More...

#include <vectorublas.hpp>

Inheritance diagram for Feel::VectorUblas< T, Storage >:
Feel::Vector< T >

List of all members.

Classes

struct  range
struct  slice

Public Types

Typedefs
typedef T value_type
typedef type_traits
< value_type >::real_type 
real_type
typedef Storage vector_type
typedef
vector_type::difference_type 
difference_type
typedef ublas::basic_range
< size_type, difference_type > 
range_type
typedef ublas::basic_slice
< size_type, difference_type > 
slice_type
typedef Vector< value_type > clone_type
typedef boost::shared_ptr
< clone_type
clone_ptrtype
typedef VectorUblas
< value_type, Storage > 
this_type
typedef vector_type::iterator iterator
typedef vector_type::const_iterator const_iterator

Public Member Functions

Constructors, destructor
 VectorUblas ()
 VectorUblas (size_type __s)
 VectorUblas (DataMap const &dm)
 VectorUblas (size_type __s, size_type __n_local)
 VectorUblas (VectorUblas const &m)
 VectorUblas (VectorUblas< value_type > &m, range_type const &range, DataMap const &dm)
 VectorUblas (ublas::vector< value_type > &m, range_type const &range)
 VectorUblas (VectorUblas< value_type > &m, slice_type const &slice)
 VectorUblas (ublas::vector< value_type > &m, slice_type const &slice)
 ~VectorUblas ()
void init (const size_type N, const size_type n_local, const bool fast=false)
void init (const size_type n, const bool fast=false)
void init (DataMap const &dm)
clone_ptrtype clone () const
Operator overloads
Vector< value_type > & operator= (const Vector< value_type > &V)
template<typename AE >
VectorUblas< value_type,
Storage > & 
operator= (ublas::vector_expression< AE > const &e)
operator() (size_type i) const
T & operator() (size_type i)
operator[] (size_type i) const
T & operator[] (size_type i)
Vector< T > & operator+= (const Vector< T > &v)
Vector< T > & operator-= (const Vector< T > &v)
Accessors
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
size_type start () const
unsigned int rowStart () const
size_type rowStop () const
bool isInitialized () const
void close () const
bool closed () const
vector_type const & vec () const
vector_type & vec ()
bool areGlobalValuesUpdated () const
void updateGlobalValues () const
value_type globalValue (size_type i) const
Mutators
void outdateGlobalValues ()
void setGlobalValue (size_type i, value_type v) const
void setConstant (value_type v)
Methods
void resize (size_type n, bool preserve=true)
void clear ()
void zero ()
void zero (size_type, size_type)
void add (const size_type i, const value_type &value)
void addVector (int *i, int n, value_type *v)
void set (size_type i, const value_type &value)
void addVector (const std::vector< value_type > &v, const std::vector< size_type > &dof_indices)
void addVector (const Vector< value_type > &V, const std::vector< size_type > &dof_indices)
void addVector (const Vector< value_type > &, const MatrixSparse< value_type > &)
void addVector (const ublas::vector< value_type > &V, const std::vector< size_type > &dof_indices)
void insert (const std::vector< T > &, const std::vector< size_type > &)
void insert (const Vector< T > &, const std::vector< size_type > &)
void insert (const ublas::vector< T > &, const std::vector< size_type > &)
void scale (const T factor)
void printMatlab (const std::string name="NULL") const
void close ()
real_type min () const
real_type max () const
real_type l1Norm () const
real_type l2Norm () const
real_type linftyNorm () const
value_type sum () const
FEELPP_DONT_INLINE this_type sqrt () const
this_type pow (int n) const
void add (const T &a)
void add (const Vector< T > &v)
void add (const T &a, const Vector< T > &v)
void localize (std::vector< value_type > &) const
void localize (ublas::vector< value_type > &v_local) const
void localize (ublas::vector_range< ublas::vector< value_type > > &v_local) const
void localize (ublas::vector_slice< ublas::vector< value_type > > &v_local) const
void localize (Vector< T > &v_local) const
void localize (Vector< T > &v_local, const std::vector< size_type > &send_list) const
void localize (const size_type first_local_idx, const size_type last_local_idx, const std::vector< size_type > &send_list)
void localizeToOneProcessor (ublas::vector< T > &v_local, const size_type proc_id=0) const
void localizeToOneProcessor (std::vector< T > &v_local, const size_type proc_id=0) const

Detailed Description

template<typename T, typename Storage = ublas::vector<T>>
class Feel::VectorUblas< T, Storage >

interface to vector

 VectorUblas<T> m;
Author:
Christophe Prud'homme
See also:

Member Function Documentation

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::add ( const size_type  i,
const value_type &  value 
) [inline, virtual]
template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::add ( const T &  a) [inline, virtual]

$U(0-DIM)+=s$. Addition of s to all components.

Note:
s is a scalar and not a vector.

Implements Feel::Vector< T >.

References Feel::Vector< T >::localSize(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::add ( const Vector< T > &  v) [inline, virtual]

$U+=V$. Simple vector addition, equal to the operator+=.

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::add ( const T &  a,
const Vector< T > &  v 
) [inline, virtual]
template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::addVector ( int *  i,
int  n,
value_type *  v 
) [inline, virtual]

v([i1,i2,...,in]) += [value1,...,valuen]

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::addVector ( const std::vector< value_type > &  v,
const std::vector< size_type > &  dof_indices 
) [inline, virtual]

$ U+=v $ where v is a std::vector<T> and you want to specify WHERE to add it

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::addVector ( const Vector< value_type > &  V,
const std::vector< size_type > &  dof_indices 
) [inline, virtual]

$ U+=V $ where U and V are type NumericVector<T> and you want to specify WHERE to add the NumericVector<T> V

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::add(), Feel::VectorUblas< T, Storage >::outdateGlobalValues(), and Feel::Vector< T >::size().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::addVector ( const Vector< value_type > &  ,
const MatrixSparse< value_type > &   
) [inline, virtual]

$ U+=A*V$, add the product of a MatrixSparse A and a Vector V to this, where this=U.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::addVector ( const ublas::vector< value_type > &  V,
const std::vector< size_type > &  dof_indices 
) [inline]

$U+=V $ where U and V are type uvlas::vector<T> and you want to specify WHERE to add the DenseVector<T> V

References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
bool Feel::VectorUblas< T, Storage >::areGlobalValuesUpdated ( ) const [inline]

update global values array

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::clear ( ) [virtual]

Release all memory and return to a state just like after having called the default constructor.

Reimplemented from Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
clone_ptrtype Feel::VectorUblas< T, Storage >::clone ( ) const [inline, virtual]

Creates a copy of this vector and returns it in an shared_ptr<>.

Implements Feel::Vector< T >.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::close ( ) const

close the ublas vector, that will copy the content of write optimized vector into a read optimized vector

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::close ( ) [inline, virtual]

Call the assemble functions

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
bool Feel::VectorUblas< T, Storage >::closed ( ) const [inline, virtual]

see if vector has been closed and fully assembled yet

Reimplemented from Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
value_type Feel::VectorUblas< T, Storage >::globalValue ( size_type  i) const [inline]

get the i -th global value

References Feel::VectorUblas< T, Storage >::operator()().

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::init ( const size_type  N,
const size_type  n_local,
const bool  fast = false 
) [virtual]

Change the dimension of the vector to N. The reserved memory for this vector remains unchanged if possible, to make things faster, but this may waste some memory, so take this in the back of your head. However, if N==0 all memory is freed, i.e. if you want to resize the vector and release the memory not needed, you have to first call init(0) and then init(N). This cited behaviour is analogous to that of the STL containers.

On fast==false, the vector is filled by zeros.

Reimplemented from Feel::Vector< T >.

Referenced by Feel::VectorUblas< T, Storage >::localize().

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::init ( const size_type  n,
const bool  fast = false 
) [virtual]

call init with n_local = N,

Reimplemented from Feel::Vector< T >.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::init ( DataMap const &  dm)

init from a DataMap

Reimplemented from Feel::Vector< T >.

References Feel::DataMap::nDof(), and Feel::DataMap::nLocalDofWithGhost().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::insert ( const std::vector< T > &  ,
const std::vector< size_type > &   
) [inline, virtual]

$ U=v $ where v is a DenseVector<T> and you want to specify WHERE to insert it

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::insert ( const Vector< T > &  ,
const std::vector< size_type > &   
) [inline, virtual]

$U=V$, where U and V are type Vector<T> and you want to specify WHERE to insert the Vector<T> V

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::insert ( const ublas::vector< T > &  ,
const std::vector< size_type > &   
) [inline, virtual]

$ U+=V $ where U and V are type DenseVector<T> and you want to specify WHERE to insert the DenseVector<T> V

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
bool Feel::VectorUblas< T, Storage >::isInitialized ( ) const [inline, virtual]
Returns:
true if vector is initialized/usable, false otherwise

Reimplemented from Feel::Vector< T >.

Referenced by Feel::VectorUblas< T, Storage >::operator()(), and Feel::VectorUblas< T, Storage >::operator[]().

template<typename T, typename Storage = ublas::vector<T>>
real_type Feel::VectorUblas< T, Storage >::l1Norm ( ) const [inline, virtual]
Returns:
the $l_1$-norm of the vector, i.e. the sum of the absolute values.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
real_type Feel::VectorUblas< T, Storage >::l2Norm ( ) const [inline, virtual]
Returns:
the $l_2$-norm of the vector, i.e. the square root of the sum of the squares of the elements.

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::sqrt().

template<typename T, typename Storage = ublas::vector<T>>
real_type Feel::VectorUblas< T, Storage >::linftyNorm ( ) const [inline, virtual]
Returns:
the maximum absolute value of the elements of this vector, which is the $l_\infty$-norm of a vector.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::localize ( std::vector< value_type > &  ) const [inline, virtual]

Creates a copy of the global vector in the local vector v_local.

Implements Feel::Vector< T >.

Referenced by Feel::VectorUblas< T, Storage >::localize().

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( ublas::vector< value_type > &  v_local) const

Creates a copy of the global vector in the local vector v_local.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( ublas::vector_range< ublas::vector< value_type > > &  v_local) const

Creates a copy of the global vector in the local vector v_local.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( ublas::vector_slice< ublas::vector< value_type > > &  v_local) const

Creates a copy of the global vector in the local vector v_local.

template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( Vector< T > &  v_local) const [virtual]
template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( Vector< T > &  v_local,
const std::vector< size_type > &  send_list 
) const [virtual]

Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list.

Implements Feel::Vector< T >.

template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( const size_type  first_local_idx,
const size_type  last_local_idx,
const std::vector< size_type > &  send_list 
) [virtual]

Updates a local vector with selected values from neighboring processors, as defined by send_list.

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::init(), and Feel::VectorUblas< T, Storage >::localize().

template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localizeToOneProcessor ( ublas::vector< T > &  v_local,
const size_type  proc_id = 0 
) const

Creates a local copy of the global vector in v_local only on processor proc_id. By default the data is sent to processor 0. This method is useful for outputting data from one processor.

template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localizeToOneProcessor ( std::vector< T > &  v_local,
const size_type  proc_id = 0 
) const [virtual]

Creates a local copy of the global vector in v_local only on processor proc_id. By default the data is sent to processor 0. This method is useful for outputting data from one processor.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
real_type Feel::VectorUblas< T, Storage >::max ( ) const [inline, virtual]
Returns:
the maximum element in the vector. In case of complex numbers, this returns the maximum Real part.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
real_type Feel::VectorUblas< T, Storage >::min ( ) const [inline, virtual]
Returns:
the minimum element in the vector. In case of complex numbers, this returns the minimum Real part.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
T Feel::VectorUblas< T, Storage >::operator() ( size_type  i) const [inline, virtual]
template<typename T, typename Storage = ublas::vector<T>>
T& Feel::VectorUblas< T, Storage >::operator() ( size_type  i) [inline]
template<typename T, typename Storage = ublas::vector<T>>
Vector<T>& Feel::VectorUblas< T, Storage >::operator+= ( const Vector< T > &  v) [inline, virtual]

Addition operator. Fast equivalent to U.add(1, V).

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
Vector<T>& Feel::VectorUblas< T, Storage >::operator-= ( const Vector< T > &  v) [inline, virtual]

Subtraction operator. Fast equivalent to U.add(-1, V).

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T , typename Storage >
Vector< T > & Feel::VectorUblas< T, Storage >::operator= ( const Vector< value_type > &  V) [virtual]
template<typename T, typename Storage = ublas::vector<T>>
T Feel::VectorUblas< T, Storage >::operator[] ( size_type  i) const [inline]
template<typename T, typename Storage = ublas::vector<T>>
T& Feel::VectorUblas< T, Storage >::operator[] ( size_type  i) [inline]
template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::outdateGlobalValues ( ) [inline]
template<typename T , typename Storage >
VectorUblas< T, Storage >::this_type Feel::VectorUblas< T, Storage >::pow ( int  n) const

pow on each element of the vector.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::printMatlab ( const std::string  name = "NULL") const [virtual]

Print the contents of the vector in Matlab's sparse vector forvec. Optionally prints the vector to the file named name. If name is not specified it is dumped to the screen.

Reimplemented from Feel::Vector< T >.

template<typename T , typename Storage >
void Feel::VectorUblas< T, Storage >::resize ( size_type  n,
bool  preserve = true 
)

resize with size n

template<typename T, typename Storage = ublas::vector<T>>
unsigned int Feel::VectorUblas< T, Storage >::rowStart ( ) const [inline]

return row_start, the index of the first vector row stored on this processor

template<typename T, typename Storage = ublas::vector<T>>
size_type Feel::VectorUblas< T, Storage >::rowStop ( ) const [inline]

return row_stop, the index of the last vector row (+1) stored on this processor

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::scale ( const T  factor) [inline, virtual]

Scale each element of the vector by the given factor.

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::set ( size_type  i,
const value_type &  value 
) [inline, virtual]
template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::setConstant ( value_type  v) [inline, virtual]

set the entries to the constant v

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::setGlobalValue ( size_type  i,
value_type  v 
) const [inline]

set the i -th global value

template<typename T , typename Storage >
VectorUblas< T, Storage >::this_type Feel::VectorUblas< T, Storage >::sqrt ( ) const

sqrt on each element of the vector.

Referenced by Feel::VectorUblas< T, Storage >::l2Norm().

template<typename T , typename Storage >
size_type Feel::VectorUblas< T, Storage >::start ( ) const

if the vector is a range, return the first index of the range, otherwise returns 0

template<typename T, typename Storage = ublas::vector<T>>
value_type Feel::VectorUblas< T, Storage >::sum ( ) const [inline, virtual]
Returns:
the sum of the vector.

Implements Feel::Vector< T >.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::updateGlobalValues ( ) const [inline]

update global values

template<typename T, typename Storage = ublas::vector<T>>
vector_type const& Feel::VectorUblas< T, Storage >::vec ( ) const [inline]

Returns the read optimized ublas vector.

Referenced by Feel::MatrixGmm< T, LayoutType >::energy(), and Feel::BackendGmm< T >::prod().

template<typename T, typename Storage = ublas::vector<T>>
vector_type& Feel::VectorUblas< T, Storage >::vec ( ) [inline]

Returns the read optimized ublas vector.

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::zero ( ) [inline, virtual]

Set all entries to 0. This method retains sparsity structure.

Implements Feel::Vector< T >.

References Feel::VectorUblas< T, Storage >::outdateGlobalValues().

template<typename T, typename Storage = ublas::vector<T>>
void Feel::VectorUblas< T, Storage >::zero ( size_type  ,
size_type   
) [inline, virtual]

Set entries to zero between start and stop

Implements Feel::Vector< T >.