Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Feel::VectorUblas< T, Storage > Class Template Reference

#include <vectorublas.hpp>

Detailed Description

template<typename T, typename Storage>
class Feel::VectorUblas< T, Storage >

interface to vector

* VectorUblas<T> m;
*
Author
Christophe Prud'homme
See Also
+ Inheritance diagram for Feel::VectorUblas< T, Storage >:

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
 
typedef super1::datamap_type datamap_type
 
typedef super1::datamap_ptrtype datamap_ptrtype
 
- Public Types inherited from Feel::Vector< T >
typedef boost::shared_ptr
< Vector< T > > 
clone_ptrtype
 
typedef boost::shared_ptr
< datamap_type
datamap_ptrtype
 
typedef DataMap datamap_type
 
typedef type_traits< T >::real_type real_type
 
typedef boost::shared_ptr
< Vector< T > > 
self_ptrtype
 
typedef Vector< T > self_type
 
typedef T value_type
 

Public Member Functions

Constructors, destructor
 VectorUblas ()
 
 VectorUblas (size_type __s)
 
 VectorUblas (datamap_ptrtype const &dm)
 
 VectorUblas (size_type __s, size_type __n_local)
 
 VectorUblas (VectorUblas const &m)
 
 VectorUblas (VectorUblas< value_type > &m, range_type const &range, datamap_ptrtype 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_ptrtype 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)
 
Vector< T > & operator*= (T const &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", bool renumber=false) 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
 
value_type dot (Vector< T > const &__v)
 
- Public Member Functions inherited from Feel::Vector< T >
void add (const value_type &a, const boost::shared_ptr< Vector< value_type > > &v)
 
void addVector (const boost::shared_ptr< Vector< T > > &V_in, const boost::shared_ptr< MatrixSparse< T > > &A_in)
 
void addVector (const Vector< T > &V_in, const MatrixShell< T > &A_in)
 
void addVector (const boost::shared_ptr< Vector< T > > &V_in, const boost::shared_ptr< MatrixShell< T > > &A_in)
 
WorldComm const & comm () const
 
template<>
int compare (const Vector< float > &other_vector, const real_type threshold) const
 
template<>
int compare (const Vector< double > &other_vector, const real_type threshold) const
 
virtual int compare (const Vector< T > &other_vector, const real_type threshold=1e-10) const
 
virtual void createSubvector (Vector< T > &, const std::vector< size_type > &) const
 
virtual value_type dot (boost::shared_ptr< Vector< T > > const &v)
 
virtual size_type firstLocalIndex () const
 
void init (datamap_ptrtype const &dm)
 
virtual size_type lastLocalIndex () const
 
virtual bool localIndexIsGhost (size_type localDof) const
 
void localize (const Vector< T > &V)
 
virtual size_type localSize () const
 
datamap_type const & map () const
 
datamap_ptrtype const & mapPtr () const
 
Vector< T > & operator= (const T s)
 
Vector< T > & operator= (const std::vector< T > &v)
 
virtual void print (std::ostream &os=std::cout) const
 
void setMap (datamap_ptrtype const &d)
 
virtual void setOnes ()
 
virtual void setZero ()
 
virtual size_type size () const
 
 Vector ()
 
 Vector (datamap_ptrtype const &n)
 
 Vector (const size_type n, WorldComm const &_worldComm=Environment::worldComm())
 
 Vector (const size_type n, const size_type n_local, WorldComm const &_worldComm=Environment::worldComm())
 
 Vector (Vector const &v)
 
virtual ~Vector ()
 

Additional Inherited Members

- Protected Attributes inherited from Feel::Vector< T >
bool M_is_closed
 
bool M_is_initialized
 
datamap_ptrtype M_map
 

Member Function Documentation

template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::add ( const size_type  i,
const value_type &  value 
)
inlinevirtual

Add value to the value already accumulated

Implements Feel::Vector< T >.

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

template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::add ( const T &  a)
inlinevirtual

$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>
void Feel::VectorUblas< T, Storage >::add ( const Vector< T > &  v)
inlinevirtual

$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>
void Feel::VectorUblas< T, Storage >::add ( const T &  a,
const Vector< T > &  v 
)
inlinevirtual
template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::addVector ( int *  i,
int  n,
value_type *  v 
)
inlinevirtual

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

Implements Feel::Vector< T >.

template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::addVector ( const std::vector< value_type > &  v,
const std::vector< size_type > &  dof_indices 
)
inlinevirtual

$ 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>
void Feel::VectorUblas< T, Storage >::addVector ( const Vector< value_type > &  V,
const std::vector< size_type > &  dof_indices 
)
inlinevirtual

$ 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>
void Feel::VectorUblas< T, Storage >::addVector ( const Vector< value_type > &  ,
const MatrixSparse< value_type > &   
)
inlinevirtual

$ 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>
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>
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>
clone_ptrtype Feel::VectorUblas< T, Storage >::clone ( ) const
inlinevirtual

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>
void Feel::VectorUblas< T, Storage >::close ( )
inlinevirtual

Call the assemble functions

Implements Feel::Vector< T >.

template<typename T, typename Storage>
bool Feel::VectorUblas< T, Storage >::closed ( ) const
inlinevirtual

see if vector has been closed and fully assembled yet

Reimplemented from Feel::Vector< T >.

template<typename T, typename Storage>
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 >.

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_ptrtype const &  dm)

init from a DataMap

template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::insert ( const std::vector< T > &  ,
const std::vector< size_type > &   
)
inlinevirtual

$ 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>
void Feel::VectorUblas< T, Storage >::insert ( const Vector< T > &  ,
const std::vector< size_type > &   
)
inlinevirtual

$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>
void Feel::VectorUblas< T, Storage >::insert ( const ublas::vector< T > &  ,
const std::vector< size_type > &   
)
inlinevirtual

$ 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>
bool Feel::VectorUblas< T, Storage >::isInitialized ( ) const
inlinevirtual
Returns
true if vector is initialized/usable, false otherwise

Reimplemented from Feel::Vector< T >.

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

Implements Feel::Vector< T >.

References Feel::Vector< T >::comm(), and Feel::Vector< T >::size().

template<typename T, typename Storage>
real_type Feel::VectorUblas< T, Storage >::l2Norm ( ) const
inlinevirtual
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::Vector< T >::comm(), Feel::Vector< T >::firstLocalIndex(), Feel::Vector< T >::localSize(), Feel::Vector< T >::size(), and Feel::VectorUblas< T, Storage >::start().

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

Implements Feel::Vector< T >.

References Feel::Vector< T >::comm(), and Feel::Vector< T >::size().

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

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< 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
template<typename T, typename Storage >
void Feel::VectorUblas< T, Storage >::localize ( Vector< T > &  v_local,
const std::vector< size_type > &  send_list 
) const

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

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 
)

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

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

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>
real_type Feel::VectorUblas< T, Storage >::max ( ) const
inlinevirtual
Returns
the maximum element in the vector. In case of complex numbers, this returns the maximum Real part.

Implements Feel::Vector< T >.

References Feel::Vector< T >::comm().

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

Implements Feel::Vector< T >.

References Feel::Vector< T >::comm().

template<typename T, typename Storage>
T Feel::VectorUblas< T, Storage >::operator() ( size_type  i) const
inlinevirtual
template<typename T, typename Storage>
T& Feel::VectorUblas< T, Storage >::operator() ( size_type  i)
inline
template<typename T, typename Storage>
Vector<T>& Feel::VectorUblas< T, Storage >::operator*= ( T const &  v)
inline
template<typename T, typename Storage>
Vector<T>& Feel::VectorUblas< T, Storage >::operator+= ( const Vector< T > &  v)
inlinevirtual

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>
Vector<T>& Feel::VectorUblas< T, Storage >::operator-= ( const Vector< T > &  v)
inlinevirtual

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

$U = V$: copy all components.

Reimplemented from Feel::Vector< T >.

References Feel::Vector< T >::firstLocalIndex(), and Feel::Vector< T >::lastLocalIndex().

template<typename T, typename Storage>
T Feel::VectorUblas< T, Storage >::operator[] ( size_type  i) const
inline
template<typename T, typename Storage>
T& Feel::VectorUblas< T, Storage >::operator[] ( size_type  i)
inline
template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::outdateGlobalValues ( )
inline

outdate global values array e.g. they must be update

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",
bool  renumber = false 
) 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>
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>
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>
void Feel::VectorUblas< T, Storage >::scale ( const T  factor)
inlinevirtual

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>
void Feel::VectorUblas< T, Storage >::set ( size_type  i,
const value_type &  value 
)
inlinevirtual
template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::setConstant ( value_type  v)
inlinevirtual

set the entries to the constant v

Implements Feel::Vector< T >.

template<typename T, typename Storage>
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.

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>
value_type Feel::VectorUblas< T, Storage >::sum ( ) const
inlinevirtual
Returns
the sum of the vector.

Implements Feel::Vector< T >.

References Feel::Vector< T >::comm(), and Feel::Vector< T >::size().

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

update global values

template<typename T, typename Storage>
vector_type const& Feel::VectorUblas< T, Storage >::vec ( ) const
inline

Returns the read optimized ublas vector.

template<typename T, typename Storage>
vector_type& Feel::VectorUblas< T, Storage >::vec ( )
inline

Returns the read optimized ublas vector.

template<typename T, typename Storage>
void Feel::VectorUblas< T, Storage >::zero ( )
inlinevirtual

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>
void Feel::VectorUblas< T, Storage >::zero ( size_type  ,
size_type   
)
inlinevirtual

Set entries to zero between start and stop

Implements Feel::Vector< T >.


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

Generated on Sun Dec 22 2013 13:11:22 for Feel++ by doxygen 1.8.5