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.
|
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 >.
Referenced by Feel::Vector< T >::add().
|
pure virtual |
. Addition of
s
to all components. Note that s
is a scalar and not a vector.
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
: Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
. Simple vector addition, equal to the
operator
+=.
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
Referenced by Feel::Vector< T >::addVector(), and Feel::MatrixSparse< T >::multAddVector().
|
pure virtual |
where v is a ublas::vector<T> and you want to specify WHERE to add it
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
|
pure virtual |
, add the product of a
SparseMatrix
A
and a Vector
V
to this
, where this=U
.
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
|
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 >.
|
pure virtual |
Call the assemble functions
Implemented in Feel::VectorUblas< T, Storage >.
|
inlinevirtual |
Reimplemented in Feel::VectorUblas< T, Storage >.
References Feel::Vector< T >::M_is_closed.
|
inline |
|
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, 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[]().
|
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 >.
|
virtual |
call init with n_local = N,
Reimplemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
|
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 >.
|
inlinevirtual |
Reimplemented in Feel::VectorUblas< T, Storage >.
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 >.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >.
|
inlinevirtual |
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[]().
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
Creates a copy of the global vector in the local vector v_local
.
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
Same, but fills a Vector<T>
instead of a std::vector
.
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
|
pure virtual |
Updates a local vector with selected values from neighboring processors, as defined by send_list
.
Implemented in Feel::VectorUblas< T, Storage >.
|
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 >.
|
inlinevirtual |
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=().
|
pure virtual |
retrieve the min component as well as the index of the min component
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
Access components, returns U(i)
.
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
Addition operator. Fast equivalent to U.add(1, V)
.
Implemented in Feel::VectorUblas< T, Storage >.
|
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.
|
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.
|
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 >.
|
pure virtual |
Scale each element of the vector by the given factor.
Implemented in Feel::VectorUblas< T, Storage >.
|
pure virtual |
v(i) = value
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::MatrixGmm< T, LayoutType >::zeroRows().
|
pure virtual |
set the entries to the constant v
Implemented in Feel::VectorUblas< T, Storage >.
Referenced by Feel::Vector< T >::setOnes().
|
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, 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().
|
pure virtual |
Implemented in Feel::VectorUblas< T, Storage >.
|
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().
|
pure virtual |
Set entries to zero between start
and stop
Implemented in Feel::VectorUblas< T, Storage >.
|
friend |
Same as above but allows you to use stream syntax.
|
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().
|
protected |
Flag to tell if init has been called yet
Referenced by Feel::Vector< T >::isInitialized(), and Feel::VectorUblas< T, Storage >::localize().
|
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().