Feel++
0.91.4
|
interface to vector More...
#include <vectorublas.hpp>
Classes | |
struct | range |
struct | slice |
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 Vector< T > | self_type |
typedef boost::shared_ptr < Vector< T > > | self_ptrtype |
Public Member Functions | |
Constructors, destructor | |
VectorUblas () | |
VectorUblas (size_type __s) | |
VectorUblas (DataMap const &dm) | |
VectorUblas (size_type __s, size_type __n_local) | |
VectorUblas (VectorUblas const &m) | |
VectorUblas (VectorUblas< value_type > &m, range_type const &range, DataMap 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 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) |
T | operator() (size_type i) const |
T & | operator() (size_type i) |
T | 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 | |
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") 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 |
![]() | |
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 void | setZero () |
virtual void | setOnes () |
Vector< T > & | operator= (const T s) |
Vector< T > & | operator= (const std::vector< T > &v) |
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 |
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) |
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 | 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 |
Additional Inherited Members | |
![]() | |
bool | M_is_closed |
bool | M_is_initialized |
DataMap | M_map |
interface to vector
|
inlinevirtual |
Add value
to the value already accumulated
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
Referenced by Feel::VectorUblas< T, Storage >::add(), Feel::VectorUblas< T, Storage >::addVector(), Feel::VectorUblas< T, Storage >::operator+=(), and Feel::VectorUblas< T, Storage >::operator-=().
|
inlinevirtual |
. Addition of
s
to all components.
s
is a scalar and not a vector. Implements Feel::Vector< T >.
References Feel::Vector< T >::localSize(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
. Simple vector addition, equal to the
operator+=
.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
. Simple vector addition, equal to the
operator
+=.
Implements Feel::Vector< T >.
References Feel::Vector< T >::firstLocalIndex(), Feel::Vector< T >::localSize(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
v([i1,i2,...,in]) += [value1,...,valuen]
Implements Feel::Vector< T >.
|
inlinevirtual |
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().
|
inlinevirtual |
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().
|
inlinevirtual |
, add the product of a
MatrixSparse
A
and a Vector
V
to this
, where this=U
.
Implements Feel::Vector< T >.
|
inline |
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().
|
inline |
update global values array
|
virtual |
Release all memory and return to a state just like after having called the default constructor.
Reimplemented from Feel::Vector< T >.
|
inlinevirtual |
Creates a copy of this vector and returns it in an shared_ptr<>
.
Implements Feel::Vector< T >.
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
|
inlinevirtual |
Call the assemble functions
Implements Feel::Vector< T >.
|
inlinevirtual |
see if vector has been closed and fully assembled yet
Reimplemented from Feel::Vector< T >.
|
inline |
get the i
-th global value
References 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 from Feel::Vector< T >.
Referenced by Feel::VectorUblas< T, Storage >::localize().
|
virtual |
call init with n_local = N,
Reimplemented from Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::init | ( | DataMap const & | dm | ) |
init from a DataMap
Reimplemented from Feel::Vector< T >.
References Feel::DataMap::nDof(), and Feel::DataMap::nLocalDofWithGhost().
|
inlinevirtual |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implements Feel::Vector< T >.
|
inlinevirtual |
, where U and V are type Vector<T> and you want to specify WHERE to insert the Vector<T> V
Implements Feel::Vector< T >.
|
inlinevirtual |
where U and V are type DenseVector<T> and you want to specify WHERE to insert the DenseVector<T> V
Implements Feel::Vector< T >.
|
inlinevirtual |
Reimplemented from Feel::Vector< T >.
Referenced by Feel::VectorUblas< T, Storage >::operator()(), and Feel::VectorUblas< T, Storage >::operator[]().
|
inlinevirtual |
Implements Feel::Vector< T >.
|
inlinevirtual |
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::sqrt().
|
inlinevirtual |
Implements Feel::Vector< T >.
|
inlinevirtual |
Creates a copy of the global vector in the local vector v_local
.
Implements Feel::Vector< T >.
Referenced by Feel::VectorUblas< T, Storage >::localize().
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
.
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
.
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
.
|
virtual |
Same, but fills a NumericVector<T>
instead of a std::vector
.
Implements Feel::Vector< T >.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::init(), Feel::Vector< T >::lastLocalIndex(), Feel::Vector< T >::localSize(), Feel::Vector< T >::M_is_closed, Feel::Vector< T >::M_is_initialized, and Feel::Vector< T >::size().
|
virtual |
Creates a local vector v_local
containing only information relevant to this processor, as defined by the send_list
.
Implements Feel::Vector< T >.
|
virtual |
Updates a local vector with selected values from neighboring processors, as defined by send_list
.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::init(), and Feel::VectorUblas< T, Storage >::localize().
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.
|
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.
Implements Feel::Vector< T >.
|
inlinevirtual |
Implements Feel::Vector< T >.
|
inlinevirtual |
Implements Feel::Vector< T >.
|
inlinevirtual |
Access components, returns u(i)
.
Implements Feel::Vector< T >.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::isInitialized(), and Feel::Vector< T >::lastLocalIndex().
Referenced by Feel::VectorUblas< T, Storage >::globalValue().
|
inline |
Access components, returns u(i)
.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::isInitialized(), Feel::Vector< T >::lastLocalIndex(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
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().
|
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().
|
virtual |
: copy all components.
Reimplemented from Feel::Vector< T >.
References Feel::Vector< T >::firstLocalIndex(), Feel::Vector< T >::lastLocalIndex(), and Feel::Vector< T >::localSize().
|
inline |
Access components, returns u(i)
.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::isInitialized(), and Feel::Vector< T >::lastLocalIndex().
|
inline |
Access components, returns u(i)
.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::isInitialized(), Feel::Vector< T >::lastLocalIndex(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inline |
outdate global values array e.g. they must be update
Referenced by Feel::VectorUblas< T, Storage >::add(), Feel::VectorUblas< T, Storage >::addVector(), Feel::VectorUblas< T, Storage >::operator()(), Feel::VectorUblas< T, Storage >::operator+=(), Feel::VectorUblas< T, Storage >::operator-=(), Feel::VectorUblas< T, Storage >::operator[](), Feel::VectorUblas< T, Storage >::scale(), Feel::VectorUblas< T, Storage >::set(), and Feel::VectorUblas< T, Storage >::zero().
VectorUblas< T, Storage >::this_type Feel::VectorUblas< T, Storage >::pow | ( | int | n | ) | const |
pow on each element of the vector.
|
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 >.
void Feel::VectorUblas< T, Storage >::resize | ( | size_type | n, |
bool | preserve = true |
||
) |
resize with size n
|
inline |
return row_start, the index of the first vector row stored on this processor
|
inline |
return row_stop, the index of the last vector row (+1) stored on this processor
|
inlinevirtual |
Scale each element of the vector by the given factor.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
set to value
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
set the entries to the constant v
Implements Feel::Vector< T >.
|
inline |
set the i
-th global value
VectorUblas< T, Storage >::this_type Feel::VectorUblas< T, Storage >::sqrt | ( | ) | const |
sqrt on each element of the vector.
Referenced by Feel::VectorUblas< T, Storage >::l2Norm().
size_type Feel::VectorUblas< T, Storage >::start | ( | ) | const |
if the vector is a range, return the first index of the range, otherwise returns 0
|
inlinevirtual |
Implements Feel::Vector< T >.
|
inline |
update global values
|
inline |
Returns the read optimized ublas vector.
Referenced by Feel::MatrixGmm< T, LayoutType >::energy(), and Feel::BackendGmm< T >::prod().
|
inline |
Returns the read optimized ublas vector.
|
inlinevirtual |
Set all entries to 0. This method retains sparsity structure.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
|
inlinevirtual |
Set entries to zero between start
and stop
Implements Feel::Vector< T >.