#include <vector.hpp>
Numeric vector. Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Public Types | |
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 | |
virtual void | add (const size_type i, const value_type &value)=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 (int *i, int n, value_type *v)=0 |
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 | clear () |
virtual clone_ptrtype | clone () const =0 |
virtual void | close ()=0 |
virtual bool | closed () const |
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 (Vector< T > const &v)=0 |
virtual value_type | dot (boost::shared_ptr< Vector< T > > const &v) |
virtual size_type | firstLocalIndex () const |
virtual void | init (const size_type, const size_type, const bool=false) |
virtual void | init (const size_type, const bool=false) |
void | init (datamap_ptrtype const &dm) |
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 bool | isInitialized () const |
virtual real_type | l1Norm () const =0 |
virtual real_type | l2Norm () const =0 |
virtual size_type | lastLocalIndex () const |
virtual real_type | linftyNorm () const =0 |
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 |
virtual real_type | max () const =0 |
virtual real_type | min () const =0 |
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 |
Vector< T > & | operator= (const T s) |
virtual Vector< T > & | operator= (const Vector< T > &V) |
Vector< T > & | operator= (const std::vector< T > &v) |
virtual void | print (std::ostream &os=std::cout) const |
virtual void | printMatlab (const std::string name="NULL", bool renumber=false) const |
virtual void | scale (const T factor)=0 |
virtual void | set (const size_type i, const value_type &value)=0 |
virtual void | setConstant (value_type v)=0 |
void | setMap (datamap_ptrtype const &d) |
virtual void | setOnes () |
virtual void | setZero () |
virtual size_type | size () const |
virtual value_type | sum () const =0 |
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 void | zero ()=0 |
virtual void | zero (size_type, size_type)=0 |
virtual | ~Vector () |
Protected Attributes | |
bool | M_is_closed |
bool | M_is_initialized |
datamap_ptrtype | M_map |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Vector< T > &v) |
Feel::Vector< T >::Vector | ( | ) |
Dummy-Constructor. Dimension=0
Feel::Vector< T >::Vector | ( | const size_type | n, |
WorldComm const & | _worldComm = Environment::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 = Environment::worldComm() |
||
) |
Constructor. Set local dimension to n_local
, the global dimension to n
, and initialize all elements with zero.
|
virtual |
Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.
|
pure virtual |
v(i) += value
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
. Addition of
s
to all components. Note that s
is a scalar and not a vector.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
: Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
. Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
inline |
. Simple vector addition, equal to the
operator
+=.
References Feel::Vector< T >::add().
|
pure virtual |
v([i1,i2,...,in]) += [value1,...,valuen]
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
where v is a ublas::vector<T> and you want to specify WHERE to add it
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
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 >, and Feel::VectorEigen< T >.
|
pure virtual |
, add the product of a
SparseMatrix
A
and a Vector
V
to this
, where this=U
.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
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
.
|
virtual |
Vector<T>
to a pristine state. Reimplemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
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 >, and Feel::VectorEigen< T >.
|
pure virtual |
Call the assemble functions
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
inlinevirtual |
Reimplemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
References Feel::Vector< T >::M_is_closed.
|
inline |
References Feel::Vector< T >::M_map.
|
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.
|
inlinevirtual |
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.
|
inlinevirtual |
0
. References Feel::Vector< T >::M_map.
|
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 >, and Feel::VectorEigen< T >.
|
virtual |
call init with n_local = N,
Reimplemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
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 >, and Feel::VectorEigen< T >.
|
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 >, and Feel::VectorEigen< T >.
|
inlinevirtual |
Reimplemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
References Feel::Vector< T >::M_is_initialized.
|
pure virtual |
retrieve the max component as well as the index of the max component
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
inlinevirtual |
size()
. References Feel::Vector< T >::M_map.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
inlinevirtual |
References Feel::Vector< T >::M_map.
|
pure virtual |
retrieve the min component as well as the index of the min component
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Access components, returns U(i)
.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Addition operator. Fast equivalent to U.add(1, V)
.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Subtraction operator. Fast equivalent to U.add
(-1, V).
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
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.
|
virtual |
: copy all components.
Reimplemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
References Feel::Vector< T >::firstLocalIndex().
Vector< T > & Feel::Vector< T >::operator= | ( | const std::vector< T > & | v | ) |
: copy all components.
|
virtual |
Prints the contents of the vector to the screen.
|
inlinevirtual |
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 >, and Feel::VectorEigen< T >.
|
pure virtual |
Scale each element of the vector by the given factor.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
v(i) = value
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
set the entries to the constant v
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
inlinevirtual |
set the entries to 1
References Feel::Vector< T >::setConstant().
|
inlinevirtual |
set the entries to 0
References Feel::Vector< T >::zero().
|
inlinevirtual |
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.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Set all entries to zero. Equivalent to v
= 0, but more obvious and faster.
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
pure virtual |
Set entries to zero between start
and stop
Implemented in Feel::VectorUblas< T, Storage >, and Feel::VectorEigen< T >.
|
friend |
Same as above but allows you to use stream syntax.
|
protected |
Flag to see if the Numeric assemble routines have been called yet
|
protected |
Flag to tell if init has been called yet
|
protected |
data distribution map of the vector over the processors