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::VectorEigen< T > Class Template Reference

#include <vectoreigen.hpp>

Detailed Description

template<typename T>
class Feel::VectorEigen< T >

interface to vector

VectorEigen<T> m;
Author
Christophe Prud'homme
See Also
+ Inheritance diagram for Feel::VectorEigen< T >:

Public Types

Typedefs
typedef T value_type
 
typedef get_real_type< T >
::value_type 
real_type
 
typedef Eigen::Matrix
< value_type, Eigen::Dynamic, 1 > 
vector_type
 
typedef VectorEigen< value_type > this_type
 
typedef super1::clone_ptrtype clone_ptrtype
 
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
 VectorEigen ()
 
 VectorEigen (size_type __s)
 
 VectorEigen (datamap_ptrtype const &dm)
 
 VectorEigen (size_type __s, size_type __n_local)
 
 VectorEigen (VectorEigen const &m)
 
 ~VectorEigen ()
 
clone_ptrtype clone () const
 
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)
 
Operator overloads
Vector< value_type > & operator= (const Vector< value_type > &V)
 
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
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 ()
 
Mutators
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 vector_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 vector_type &, const std::vector< size_type > &)
 
void insert (const ublas::vector< T > &V, const std::vector< size_type > &dof_indices)
 
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 (const size_type first_local_idx, const size_type last_local_idx, const std::vector< size_type > &send_list)
 
void localize (Vector< T > &v_local) const
 
void localize (vector_type &v_local) const
 
void localize (Vector< T > &v_local, const std::vector< size_type > &send_list) const
 
void localizeToOneProcessor (std::vector< T > &v_local, const size_type proc_id=0) const
 
void localizeToOneProcessor (vector_type &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>
void Feel::VectorEigen< T >::add ( const size_type  i,
const value_type &  value 
)
inlinevirtual

Add value to the value already accumulated

Implements Feel::Vector< T >.

template<typename T>
void Feel::VectorEigen< T >::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().

template<typename T>
void Feel::VectorEigen< T >::add ( const Vector< T > &  v)
inlinevirtual

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

Implements Feel::Vector< T >.

References Feel::VectorEigen< T >::add().

template<typename T>
void Feel::VectorEigen< T >::add ( const T &  a,
const Vector< T > &  v 
)
inlinevirtual

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

Implements Feel::Vector< T >.

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

template<typename T>
void Feel::VectorEigen< T >::addVector ( int *  i,
int  n,
value_type *  v 
)
inlinevirtual

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

Implements Feel::Vector< T >.

template<typename T>
void Feel::VectorEigen< T >::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::VectorEigen< T >::add().

template<typename T>
void Feel::VectorEigen< T >::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::VectorEigen< T >::add(), and Feel::Vector< T >::size().

template<typename T>
void Feel::VectorEigen< T >::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>
void Feel::VectorEigen< T >::addVector ( const vector_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::VectorEigen< T >::add().

template<typename T >
void Feel::VectorEigen< T >::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 >
VectorEigen< T >::clone_ptrtype Feel::VectorEigen< T >::clone ( ) const
virtual

Creates a copy of this vector and returns it in an shared_ptr<>. This must be overloaded in the derived classes.

Implements Feel::Vector< T >.

template<typename T >
void Feel::VectorEigen< T >::close ( ) const

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

template<typename T>
void Feel::VectorEigen< T >::close ( )
inlinevirtual

Call the assemble functions

Implements Feel::Vector< T >.

template<typename T>
bool Feel::VectorEigen< T >::closed ( ) const
inlinevirtual

see if vector has been closed and fully assembled yet

Reimplemented from Feel::Vector< T >.

template<typename T >
void Feel::VectorEigen< T >::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 >
void Feel::VectorEigen< T >::init ( const size_type  n,
const bool  fast = false 
)
virtual

call init with n_local = N,

Reimplemented from Feel::Vector< T >.

template<typename T >
void Feel::VectorEigen< T >::init ( datamap_ptrtype const &  dm)

init from a DataMap

template<typename T>
void Feel::VectorEigen< T >::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>
void Feel::VectorEigen< T >::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>
void Feel::VectorEigen< T >::insert ( const vector_type &  ,
const std::vector< size_type > &   
)
inline

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

template<typename T>
void Feel::VectorEigen< T >::insert ( const ublas::vector< T > &  V,
const std::vector< size_type > &  dof_indices 
)
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>
bool Feel::VectorEigen< T >::isInitialized ( ) const
inlinevirtual
Returns
true if vector is initialized/usable, false otherwise

Reimplemented from Feel::Vector< T >.

template<typename T>
real_type Feel::VectorEigen< T >::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>
real_type Feel::VectorEigen< T >::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(), and Feel::Vector< T >::size().

template<typename T>
real_type Feel::VectorEigen< T >::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>
void Feel::VectorEigen< T >::localize ( std::vector< value_type > &  ) const
inline

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

template<typename T >
void Feel::VectorEigen< T >::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::VectorEigen< T >::init(), and Feel::VectorEigen< T >::localize().

template<typename T>
void Feel::VectorEigen< T >::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>
void Feel::VectorEigen< T >::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>
real_type Feel::VectorEigen< T >::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(), and Feel::Vector< T >::size().

template<typename T>
real_type Feel::VectorEigen< T >::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(), and Feel::Vector< T >::size().

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

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

Implements Feel::Vector< T >.

References Feel::VectorEigen< T >::add().

template<typename T>
Vector<T>& Feel::VectorEigen< T >::operator-= ( const Vector< T > &  v)
inlinevirtual

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

Implements Feel::Vector< T >.

References Feel::VectorEigen< T >::add().

template<typename T >
Vector< T > & Feel::VectorEigen< T >::operator= ( const Vector< value_type > &  V)
virtual
template<typename T>
T Feel::VectorEigen< T >::operator[] ( size_type  i) const
inline
template<typename T>
T& Feel::VectorEigen< T >::operator[] ( size_type  i)
inline
template<typename T >
VectorEigen< T >::this_type Feel::VectorEigen< T >::pow ( int  n) const

pow on each element of the vector.

template<typename T >
void Feel::VectorEigen< T >::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 >
void Feel::VectorEigen< T >::resize ( size_type  n,
bool  preserve = true 
)

resize with size n

template<typename T>
unsigned int Feel::VectorEigen< T >::rowStart ( ) const
inline

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

template<typename T>
size_type Feel::VectorEigen< T >::rowStop ( ) const
inline

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

template<typename T>
void Feel::VectorEigen< T >::scale ( const T  factor)
inlinevirtual

Scale each element of the vector by the given factor.

Implements Feel::Vector< T >.

template<typename T>
void Feel::VectorEigen< T >::set ( size_type  i,
const value_type &  value 
)
inlinevirtual

set to value

Implements Feel::Vector< T >.

template<typename T>
void Feel::VectorEigen< T >::setConstant ( value_type  v)
inlinevirtual

set the entries to the constant v

Implements Feel::Vector< T >.

template<typename T >
VectorEigen< T >::this_type Feel::VectorEigen< T >::sqrt ( ) const

sqrt on each element of the vector.

template<typename T >
size_type Feel::VectorEigen< T >::start ( ) const

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

template<typename T>
value_type Feel::VectorEigen< T >::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>
vector_type const& Feel::VectorEigen< T >::vec ( ) const
inline

Returns the read optimized eigen vector.

template<typename T>
vector_type& Feel::VectorEigen< T >::vec ( )
inline

Returns the read optimized eigen vector.

template<typename T>
void Feel::VectorEigen< T >::zero ( )
inlinevirtual

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

Implements Feel::Vector< T >.

template<typename T>
void Feel::VectorEigen< T >::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 Oct 20 2013 08:25:09 for Feel++ by doxygen 1.8.4