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 |
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 |
interface to vector
VectorUblas<T> m;
void Feel::VectorUblas< T, Storage >::add | ( | const size_type | i, |
const value_type & | value | ||
) | [inline, virtual] |
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-=().
void Feel::VectorUblas< T, Storage >::add | ( | const T & | a | ) | [inline, virtual] |
. 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().
void Feel::VectorUblas< T, Storage >::add | ( | const Vector< T > & | v | ) | [inline, virtual] |
. Simple vector addition, equal to the
operator+=
.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::add(), and Feel::VectorUblas< T, Storage >::outdateGlobalValues().
void Feel::VectorUblas< T, Storage >::add | ( | const T & | a, |
const Vector< T > & | v | ||
) | [inline, virtual] |
. 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().
void Feel::VectorUblas< T, Storage >::addVector | ( | int * | i, |
int | n, | ||
value_type * | v | ||
) | [inline, virtual] |
v([i1,i2,...,in]) += [value1,...,valuen]
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::addVector | ( | const std::vector< value_type > & | v, |
const std::vector< size_type > & | dof_indices | ||
) | [inline, virtual] |
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().
void Feel::VectorUblas< T, Storage >::addVector | ( | const Vector< value_type > & | V, |
const std::vector< size_type > & | dof_indices | ||
) | [inline, virtual] |
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().
void Feel::VectorUblas< T, Storage >::addVector | ( | const Vector< value_type > & | , |
const MatrixSparse< value_type > & | |||
) | [inline, virtual] |
, add the product of a
MatrixSparse
A
and a Vector
V
to this
, where this=U
.
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::addVector | ( | const ublas::vector< value_type > & | V, |
const std::vector< size_type > & | dof_indices | ||
) | [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().
bool Feel::VectorUblas< T, Storage >::areGlobalValuesUpdated | ( | ) | const [inline] |
update global values array
void Feel::VectorUblas< T, Storage >::clear | ( | ) | [virtual] |
Release all memory and return to a state just like after having called the default constructor.
Reimplemented from Feel::Vector< T >.
clone_ptrtype Feel::VectorUblas< T, Storage >::clone | ( | ) | const [inline, virtual] |
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
void Feel::VectorUblas< T, Storage >::close | ( | ) | [inline, virtual] |
Call the assemble functions
Implements Feel::Vector< T >.
bool Feel::VectorUblas< T, Storage >::closed | ( | ) | const [inline, virtual] |
see if vector has been closed and fully assembled yet
Reimplemented from Feel::Vector< T >.
value_type Feel::VectorUblas< T, Storage >::globalValue | ( | size_type | i | ) | const [inline] |
get the i
-th global value
References Feel::VectorUblas< T, Storage >::operator()().
void Feel::VectorUblas< T, Storage >::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 >.
Referenced by Feel::VectorUblas< T, Storage >::localize().
void Feel::VectorUblas< T, Storage >::init | ( | const size_type | n, |
const bool | fast = false |
||
) | [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().
void Feel::VectorUblas< T, Storage >::insert | ( | const std::vector< T > & | , |
const std::vector< size_type > & | |||
) | [inline, virtual] |
where v is a DenseVector<T> and you want to specify WHERE to insert it
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::insert | ( | const Vector< T > & | , |
const std::vector< size_type > & | |||
) | [inline, virtual] |
, where U and V are type Vector<T> and you want to specify WHERE to insert the Vector<T> V
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::insert | ( | const ublas::vector< T > & | , |
const std::vector< size_type > & | |||
) | [inline, virtual] |
where U and V are type DenseVector<T> and you want to specify WHERE to insert the DenseVector<T> V
Implements Feel::Vector< T >.
bool Feel::VectorUblas< T, Storage >::isInitialized | ( | ) | const [inline, virtual] |
Reimplemented from Feel::Vector< T >.
Referenced by Feel::VectorUblas< T, Storage >::operator()(), and Feel::VectorUblas< T, Storage >::operator[]().
real_type Feel::VectorUblas< T, Storage >::l1Norm | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
real_type Feel::VectorUblas< T, Storage >::l2Norm | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::sqrt().
real_type Feel::VectorUblas< T, Storage >::linftyNorm | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::localize | ( | std::vector< value_type > & | ) | const [inline, virtual] |
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
.
void Feel::VectorUblas< T, Storage >::localize | ( | Vector< T > & | v_local | ) | const [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().
void Feel::VectorUblas< T, Storage >::localize | ( | Vector< T > & | v_local, |
const std::vector< size_type > & | send_list | ||
) | const [virtual] |
Creates a local vector v_local
containing only information relevant to this processor, as defined by the send_list
.
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::localize | ( | const size_type | first_local_idx, |
const size_type | last_local_idx, | ||
const std::vector< size_type > & | send_list | ||
) | [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.
void Feel::VectorUblas< T, Storage >::localizeToOneProcessor | ( | std::vector< T > & | v_local, |
const size_type | proc_id = 0 |
||
) | const [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 >.
real_type Feel::VectorUblas< T, Storage >::max | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
real_type Feel::VectorUblas< T, Storage >::min | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
T Feel::VectorUblas< T, Storage >::operator() | ( | size_type | i | ) | const [inline, virtual] |
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().
T& Feel::VectorUblas< T, Storage >::operator() | ( | size_type | i | ) | [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().
Vector<T>& Feel::VectorUblas< T, Storage >::operator+= | ( | const Vector< T > & | v | ) | [inline, virtual] |
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().
Vector<T>& Feel::VectorUblas< T, Storage >::operator-= | ( | const Vector< T > & | v | ) | [inline, virtual] |
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().
Vector< T > & Feel::VectorUblas< T, Storage >::operator= | ( | const Vector< value_type > & | V | ) | [virtual] |
: copy all components.
Reimplemented from Feel::Vector< T >.
References Feel::Vector< T >::firstLocalIndex(), Feel::Vector< T >::lastLocalIndex(), and Feel::Vector< T >::localSize().
T Feel::VectorUblas< T, Storage >::operator[] | ( | size_type | i | ) | const [inline] |
Access components, returns u(i)
.
References Feel::Vector< T >::firstLocalIndex(), Feel::VectorUblas< T, Storage >::isInitialized(), and Feel::Vector< T >::lastLocalIndex().
T& Feel::VectorUblas< T, Storage >::operator[] | ( | size_type | i | ) | [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().
void 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.
void Feel::VectorUblas< T, Storage >::printMatlab | ( | const std::string | name = "NULL" | ) | 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 >.
void Feel::VectorUblas< T, Storage >::resize | ( | size_type | n, |
bool | preserve = true |
||
) |
resize with size n
unsigned int Feel::VectorUblas< T, Storage >::rowStart | ( | ) | const [inline] |
return row_start, the index of the first vector row stored on this processor
size_type Feel::VectorUblas< T, Storage >::rowStop | ( | ) | const [inline] |
return row_stop, the index of the last vector row (+1) stored on this processor
void Feel::VectorUblas< T, Storage >::scale | ( | const T | factor | ) | [inline, virtual] |
Scale each element of the vector by the given factor.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
void Feel::VectorUblas< T, Storage >::set | ( | size_type | i, |
const value_type & | value | ||
) | [inline, virtual] |
set to value
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
void Feel::VectorUblas< T, Storage >::setConstant | ( | value_type | v | ) | [inline, virtual] |
set the entries to the constant v
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::setGlobalValue | ( | size_type | i, |
value_type | v | ||
) | const [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
value_type Feel::VectorUblas< T, Storage >::sum | ( | ) | const [inline, virtual] |
Implements Feel::Vector< T >.
void Feel::VectorUblas< T, Storage >::updateGlobalValues | ( | ) | const [inline] |
update global values
vector_type const& Feel::VectorUblas< T, Storage >::vec | ( | ) | const [inline] |
Returns the read optimized ublas vector.
Referenced by Feel::MatrixGmm< T, LayoutType >::energy(), and Feel::BackendGmm< T >::prod().
vector_type& Feel::VectorUblas< T, Storage >::vec | ( | ) | [inline] |
Returns the read optimized ublas vector.
void Feel::VectorUblas< T, Storage >::zero | ( | ) | [inline, virtual] |
Set all entries to 0. This method retains sparsity structure.
Implements Feel::Vector< T >.
References Feel::VectorUblas< T, Storage >::outdateGlobalValues().
void Feel::VectorUblas< T, Storage >::zero | ( | size_type | , |
size_type | |||
) | [inline, virtual] |
Set entries to zero between start
and stop
Implements Feel::Vector< T >.