Feel++
0.91.4
|
#include <vector.hpp>
Public Types | |
typedef T | value_type |
typedef type_traits< T >::real_type | real_type |
typedef Vector< T > | self_type |
typedef boost::shared_ptr < Vector< T > > | self_ptrtype |
typedef boost::shared_ptr < Vector< T > > | clone_ptrtype |
Public Member Functions | |
Vector () | |
Vector (DataMap const &n) | |
Vector (const size_type n, WorldComm const &_worldComm=WorldComm()) | |
Vector (const size_type n, const size_type n_local, WorldComm const &_worldComm=WorldComm()) | |
virtual | ~Vector () |
DataMap const & | map () const |
void | setMap (DataMap const &d) |
virtual bool | isInitialized () const |
virtual bool | closed () const |
virtual void | close ()=0 |
virtual void | clear () |
virtual void | zero ()=0 |
virtual void | zero (size_type, size_type)=0 |
virtual void | setConstant (value_type v)=0 |
virtual void | setZero () |
virtual void | setOnes () |
virtual clone_ptrtype | clone () const =0 |
virtual void | init (const size_type, const size_type, const bool=false) |
virtual void | init (const size_type, const bool=false) |
void | init (DataMap const &dm) |
Vector< T > & | operator= (const T s) |
virtual Vector< T > & | operator= (const Vector< T > &V) |
Vector< T > & | operator= (const std::vector< T > &v) |
virtual value_type | sum () const =0 |
virtual real_type | min () const =0 |
virtual real_type | max () const =0 |
virtual real_type | l1Norm () const =0 |
virtual real_type | l2Norm () const =0 |
virtual real_type | linftyNorm () const =0 |
virtual size_type | size () const |
virtual size_type | localSize () const |
virtual size_type | firstLocalIndex () const |
virtual size_type | lastLocalIndex () const |
mpi::communicator const & | comm () const |
virtual T | operator() (const size_type i) const =0 |
virtual Vector< T > & | operator+= (const Vector< value_type > &V)=0 |
virtual Vector< T > & | operator-= (const Vector< value_type > &V)=0 |
virtual void | set (const size_type i, const value_type &value)=0 |
virtual void | add (const size_type i, const value_type &value)=0 |
virtual void | addVector (int *i, int n, value_type *v)=0 |
virtual void | add (const value_type &s)=0 |
virtual void | add (const Vector< value_type > &V)=0 |
virtual void | add (const value_type &a, const Vector< value_type > &v)=0 |
void | add (const value_type &a, const boost::shared_ptr< Vector< value_type > > &v) |
virtual void | addVector (const std::vector< T > &v, const std::vector< size_type > &dof_indices)=0 |
virtual void | addVector (const Vector< T > &V, const std::vector< size_type > &dof_indices)=0 |
virtual void | addVector (const Vector< T > &V_in, const MatrixSparse< T > &A_in)=0 |
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) |
virtual void | insert (const std::vector< T > &v, const std::vector< size_type > &dof_indices)=0 |
virtual void | insert (const Vector< T > &V, const std::vector< size_type > &dof_indices)=0 |
virtual void | insert (const ublas::vector< T > &V, const std::vector< size_type > &dof_indices)=0 |
virtual void | scale (const T factor)=0 |
virtual void | localize (std::vector< T > &v_local) const =0 |
virtual void | localize (Vector< T > &v_local) const =0 |
virtual void | localize (Vector< T > &v_local, const std::vector< size_type > &send_list) const =0 |
virtual void | localize (const size_type first_local_idx, const size_type last_local_idx, const std::vector< size_type > &send_list)=0 |
virtual void | localizeToOneProcessor (std::vector< T > &v_local, const size_type proc_id=0) const =0 |
virtual int | compare (const Vector< T > &other_vector, const real_type threshold=1e-10) const |
virtual void | print (std::ostream &os=std::cout) const |
virtual void | printMatlab (const std::string name="NULL") const |
virtual void | createSubvector (Vector< T > &, const std::vector< size_type > &) 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 |
Protected Attributes | |
bool | M_is_closed |
bool | M_is_initialized |
DataMap | M_map |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Vector< T > &v) |
Numeric vector. Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Feel::Vector< T >::Vector | ( | ) |
Dummy-Constructor. Dimension=0
Feel::Vector< T >::Vector | ( | const size_type | n, |
WorldComm const & | _worldComm = WorldComm() |
||
) |
Constructor. Set dimension to n
and initialize all elements with zero.
Feel::Vector< T >::Vector | ( | const size_type | n, |
const size_type | n_local, | ||
WorldComm const & | _worldComm = WorldComm() |
||
) |
Constructor. Set local dimension to n_local
, the global dimension to n
, and initialize all elements with zero.
Feel::Vector< T >::~Vector | ( | ) | [virtual] |
Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.
virtual void Feel::Vector< T >::add | ( | const size_type | i, |
const value_type & | value | ||
) | [pure virtual] |
v(i) += value
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::Vector< T >::add().
virtual void Feel::Vector< T >::add | ( | const value_type & | s | ) | [pure virtual] |
. Addition of
s
to all components. Note that s
is a scalar and not a vector.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::add | ( | const Vector< value_type > & | V | ) | [pure virtual] |
: Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::add | ( | const value_type & | a, |
const Vector< value_type > & | v | ||
) | [pure virtual] |
. Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >.
void Feel::Vector< T >::add | ( | const value_type & | a, |
const boost::shared_ptr< Vector< value_type > > & | v | ||
) | [inline] |
. Simple vector addition, equal to the
operator
+=.
References Feel::Vector< T >::add().
virtual void Feel::Vector< T >::addVector | ( | int * | i, |
int | n, | ||
value_type * | v | ||
) | [pure virtual] |
v([i1,i2,...,in]) += [value1,...,valuen]
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::Vector< T >::addVector(), and Feel::MatrixSparse< T >::multAddVector().
virtual void Feel::Vector< T >::addVector | ( | const std::vector< T > & | v, |
const std::vector< size_type > & | dof_indices | ||
) | [pure virtual] |
where v is a ublas::vector<T> and you want to specify WHERE to add it
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::addVector | ( | const Vector< T > & | V, |
const std::vector< size_type > & | dof_indices | ||
) | [pure virtual] |
, where U and V are type Vector<T> and you want to specify WHERE to add the Vector<T> V
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::addVector | ( | const Vector< T > & | V_in, |
const MatrixSparse< T > & | A_in | ||
) | [pure virtual] |
, add the product of a
SparseMatrix
A
and a Vector
V
to this
, where this=U
.
Implemented in Feel::VectorUblas< T, Storage >.
void Feel::Vector< T >::addVector | ( | const boost::shared_ptr< Vector< T > > & | V_in, |
const boost::shared_ptr< MatrixSparse< T > > & | A_in | ||
) | [inline] |
, add the product of a
SparseMatrix
A
and a Vector
V
to this
, where this=U
.
References Feel::Vector< T >::addVector().
void Feel::Vector< T >::addVector | ( | const Vector< T > & | V_in, |
const MatrixShell< T > & | A_in | ||
) |
, add the product of a
MatrixShell
A
and a Vector
V
to this
, where this=U
.
References Feel::MatrixShell< T >::multVector().
void Feel::Vector< T >::addVector | ( | const boost::shared_ptr< Vector< T > > & | V_in, |
const boost::shared_ptr< MatrixShell< T > > & | A_in | ||
) |
, add the product of a
MatrixShell
A
and a Vector
V
to this
, where this=U
.
void Feel::Vector< T >::clear | ( | ) | [virtual] |
Vector<T>
to a pristine state. Reimplemented in Feel::VectorUblas< T, Storage >.
virtual clone_ptrtype Feel::Vector< T >::clone | ( | ) | const [pure virtual] |
Creates a copy of this vector and returns it in an shared_ptr<>
. This must be overloaded in the derived classes.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::close | ( | ) | [pure virtual] |
Call the assemble functions
Implemented in Feel::VectorUblas< T, Storage >.
virtual bool Feel::Vector< T >::closed | ( | ) | const [inline, virtual] |
Reimplemented in Feel::VectorUblas< T, Storage >.
References Feel::Vector< T >::M_is_closed.
mpi::communicator const& Feel::Vector< T >::comm | ( | ) | const [inline] |
virtual int Feel::Vector< T >::compare | ( | const Vector< T > & | other_vector, |
const real_type | threshold = 1e-10 |
||
) | const [virtual] |
-1
when this
is equivalent to other_vector
, up to the given threshold
. When differences occur, the return value contains the first index where the difference exceeded the threshold. When no threshold is given, the Application
TOLERANCE
is used. virtual void Feel::Vector< T >::createSubvector | ( | Vector< T > & | , |
const std::vector< size_type > & | |||
) | const [inline, virtual] |
Creates the subvector "subvector" from the indices in the "rows" array. Similar to the create_submatrix routine for the SparseMatrix class, it is currently only implemented for PetscVectors.
virtual size_type Feel::Vector< T >::firstLocalIndex | ( | ) | const [inline, virtual] |
0
. References Feel::Vector< T >::M_map, and Feel::DataMap::minMyGID().
Referenced by Feel::VectorUblas< T, Storage >::add(), Feel::element_product(), Feel::inner_product(), Feel::VectorUblas< T, Storage >::localize(), Feel::VectorUblas< T, Storage >::operator()(), Feel::VectorUblas< T, Storage >::operator=(), Feel::Vector< T >::operator=(), and Feel::VectorUblas< T, Storage >::operator[]().
void Feel::Vector< T >::init | ( | const size_type | n, |
const size_type | nl, | ||
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 in Feel::VectorUblas< T, Storage >.
void Feel::Vector< T >::init | ( | const size_type | n, |
const bool | fast = false |
||
) | [virtual] |
call init with n_local = N,
Reimplemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::insert | ( | const std::vector< T > & | v, |
const std::vector< size_type > & | dof_indices | ||
) | [pure virtual] |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::insert | ( | const Vector< T > & | V, |
const std::vector< size_type > & | dof_indices | ||
) | [pure virtual] |
, where U and V are type Vector<T> and you want to specify WHERE to insert the Vector<T> V
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::insert | ( | const ublas::vector< T > & | V, |
const std::vector< size_type > & | dof_indices | ||
) | [pure virtual] |
where U and V are type DenseVector<T> and you want to specify WHERE to insert the DenseVector<T> V
Implemented in Feel::VectorUblas< T, Storage >.
virtual bool Feel::Vector< T >::isInitialized | ( | ) | const [inline, virtual] |
Reimplemented in Feel::VectorUblas< T, Storage >.
References Feel::Vector< T >::M_is_initialized.
virtual real_type Feel::Vector< T >::l1Norm | ( | ) | const [pure virtual] |
retrieve the max component as well as the index of the max component
Implemented in Feel::VectorUblas< T, Storage >.
virtual real_type Feel::Vector< T >::l2Norm | ( | ) | const [pure virtual] |
Implemented in Feel::VectorUblas< T, Storage >.
virtual size_type Feel::Vector< T >::lastLocalIndex | ( | ) | const [inline, virtual] |
size()
. References Feel::Vector< T >::M_map, and Feel::DataMap::maxMyGID().
Referenced by Feel::VectorUblas< T, Storage >::localize(), Feel::VectorUblas< T, Storage >::operator()(), Feel::VectorUblas< T, Storage >::operator=(), and Feel::VectorUblas< T, Storage >::operator[]().
virtual real_type Feel::Vector< T >::linftyNorm | ( | ) | const [pure virtual] |
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::localize | ( | std::vector< T > & | v_local | ) | const [pure virtual] |
Creates a copy of the global vector in the local vector v_local
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::localize | ( | Vector< T > & | v_local | ) | const [pure virtual] |
Same, but fills a Vector<T>
instead of a std::vector
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::localize | ( | Vector< T > & | v_local, |
const std::vector< size_type > & | send_list | ||
) | const [pure virtual] |
Creates a local vector v_local
containing only information relevant to this processor, as defined by the send_list
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::localize | ( | const size_type | first_local_idx, |
const size_type | last_local_idx, | ||
const std::vector< size_type > & | send_list | ||
) | [pure virtual] |
Updates a local vector with selected values from neighboring processors, as defined by send_list
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::localizeToOneProcessor | ( | std::vector< T > & | v_local, |
const size_type | proc_id = 0 |
||
) | const [pure 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.
Implemented in Feel::VectorUblas< T, Storage >.
virtual size_type Feel::Vector< T >::localSize | ( | ) | const [inline, virtual] |
References Feel::Vector< T >::M_map, and Feel::DataMap::nLocalDofWithGhost().
Referenced by Feel::VectorUblas< T, Storage >::add(), Feel::Backend< T >::dot(), Feel::element_product(), Feel::inner_product(), Feel::VectorUblas< T, Storage >::localize(), and Feel::VectorUblas< T, Storage >::operator=().
virtual real_type Feel::Vector< T >::max | ( | ) | const [pure virtual] |
retrieve the min component as well as the index of the min component
Implemented in Feel::VectorUblas< T, Storage >.
virtual real_type Feel::Vector< T >::min | ( | ) | const [pure virtual] |
Implemented in Feel::VectorUblas< T, Storage >.
virtual T Feel::Vector< T >::operator() | ( | const size_type | i | ) | const [pure virtual] |
Access components, returns U(i)
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual Vector<T>& Feel::Vector< T >::operator+= | ( | const Vector< value_type > & | V | ) | [pure virtual] |
Addition operator. Fast equivalent to U.add(1, V)
.
Implemented in Feel::VectorUblas< T, Storage >.
virtual Vector<T>& Feel::Vector< T >::operator-= | ( | const Vector< value_type > & | V | ) | [pure virtual] |
Subtraction operator. Fast equivalent to U.add
(-1, V).
Implemented in Feel::VectorUblas< T, Storage >.
Vector< T > & Feel::Vector< T >::operator= | ( | const T | s | ) |
Change the dimension to that of the vector V
. The same applies as for the other init
function.
The elements of V
are not copied, i.e. this function is the same as calling init
(V.size(),fast). : fill all components.
Vector< T > & Feel::Vector< T >::operator= | ( | const Vector< T > & | V | ) | [virtual] |
: copy all components.
Reimplemented in Feel::VectorUblas< T, Storage >.
References Feel::Vector< T >::firstLocalIndex().
Vector< T > & Feel::Vector< T >::operator= | ( | const std::vector< T > & | v | ) |
: copy all components.
void Feel::Vector< T >::print | ( | std::ostream & | os = std::cout | ) | const [virtual] |
Prints the contents of the vector to the screen.
virtual void Feel::Vector< T >::printMatlab | ( | const std::string | name = "NULL" | ) | const [inline, virtual] |
Print the contents of the matrix in Matlab's sparse matrix format. Optionally prints the matrix to the file named name
. If name
is not specified it is dumped to the screen.
Reimplemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::scale | ( | const T | factor | ) | [pure virtual] |
Scale each element of the vector by the given factor.
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::set | ( | const size_type | i, |
const value_type & | value | ||
) | [pure virtual] |
v(i) = value
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::MatrixGmm< T, LayoutType >::zeroRows().
virtual void Feel::Vector< T >::setConstant | ( | value_type | v | ) | [pure virtual] |
set the entries to the constant v
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::Vector< T >::setOnes().
virtual void Feel::Vector< T >::setOnes | ( | ) | [inline, virtual] |
set the entries to 1
References Feel::Vector< T >::setConstant().
virtual void Feel::Vector< T >::setZero | ( | ) | [inline, virtual] |
set the entries to 0
References Feel::Vector< T >::zero().
virtual size_type Feel::Vector< T >::size | ( | ) | const [inline, virtual] |
n()
, but was renamed to get the Vector<T>
class closer to the C++ standard library's std::vector
container. References Feel::Vector< T >::M_map, and Feel::DataMap::nDof().
Referenced by Feel::VectorUblas< T, Storage >::addVector(), Feel::element_product(), Feel::MatrixGmm< T, LayoutType >::energy(), Feel::inner_product(), and Feel::VectorUblas< T, Storage >::localize().
virtual value_type Feel::Vector< T >::sum | ( | ) | const [pure virtual] |
Implemented in Feel::VectorUblas< T, Storage >.
virtual void Feel::Vector< T >::zero | ( | ) | [pure virtual] |
Set all entries to zero. Equivalent to v
= 0, but more obvious and faster.
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::MatrixSparse< T >::multVector(), and Feel::Vector< T >::setZero().
virtual void Feel::Vector< T >::zero | ( | size_type | , |
size_type | |||
) | [pure virtual] |
Set entries to zero between start
and stop
Implemented in Feel::VectorUblas< T, Storage >.
std::ostream& operator<< | ( | std::ostream & | os, |
const Vector< T > & | v | ||
) | [friend] |
Same as above but allows you to use stream syntax.
bool Feel::Vector< T >::M_is_closed [protected] |
Flag to see if the Numeric assemble routines have been called yet
Referenced by Feel::Vector< T >::closed(), and Feel::VectorUblas< T, Storage >::localize().
bool Feel::Vector< T >::M_is_initialized [protected] |
Flag to tell if init has been called yet
Referenced by Feel::Vector< T >::isInitialized(), and Feel::VectorUblas< T, Storage >::localize().
DataMap Feel::Vector< T >::M_map [protected] |
data distribution map of the vector over the processors
Referenced by Feel::Vector< T >::comm(), Feel::Vector< T >::firstLocalIndex(), Feel::Vector< T >::lastLocalIndex(), Feel::Vector< T >::localSize(), and Feel::Vector< T >::size().