#include <BaseVector.h>
Generic vector API, allowing to fill and use a vector independently of the linear algebra library in use.
Note that accessing values using this class is rather slow and should only be used in codes where the provided genericity is necessary.
Public Member Functions | |
virtual | ~BaseVector () |
virtual Index | size (void) const =0 |
Number of elements. More... | |
virtual SReal | element (Index i) const =0 |
Read the value of element i. More... | |
virtual void | resize (Index dim)=0 |
Resize the vector, and reset all values to 0. More... | |
virtual void | clear ()=0 |
Reset all values to 0. More... | |
virtual void | set (Index i, SReal v)=0 |
Write the value of element i. More... | |
virtual void | add (Index i, SReal v)=0 |
Add v to the existing value of element i. More... | |
virtual const float * | elements (Index i0, Index n, float *src) const |
Get the values of n elements, starting at element i0, into given float buffer, or return the pointer to the data if the in-memory format is compatible. More... | |
virtual const double * | elements (Index i0, Index n, double *src) const |
Get the values of n elements, starting at element i0, into given double buffer, or return the pointer to the data if the in-memory format is compatible. More... | |
virtual const int * | elements (Index i0, Index n, int *src) const |
Get the values of n elements, starting at element i0, into given int buffer, or return the pointer to the data if the in-memory format is compatible. More... | |
virtual void | set (Index i0, Index n, const float *src) |
Write the values of n float elements, starting at element i0. More... | |
virtual void | set (Index i0, Index n, const double *src) |
Write the values of n double elements, starting at element i0. More... | |
virtual void | set (Index i0, Index n, const int *src) |
Write the values of n int elements, starting at element i0. More... | |
virtual void | add (Index i0, Index n, const float *src) |
Add to the values of n float elements, starting at element i0. More... | |
virtual void | add (Index i0, Index n, const double *src) |
Add to the values of n double elements, starting at element i0. More... | |
virtual void | add (Index i0, Index n, const int *src) |
Add to the values of n int elements, starting at element i0. More... | |
virtual void | clear (Index i) |
Reset the value of element i to 0. More... | |
Protected Member Functions | |
template<class T > | |
const T * | elementsDefaultImpl (Index i0, Index n, T *buffer) const |
template<class T > | |
void | setDefaultImpl (Index i0, Index n, const T *src) |
template<class T > | |
void | addDefaultImpl (Index i0, Index n, const T *src) |
Friends | |
SOFA_LINEARALGEBRA_API std::ostream & | operator<< (std::ostream &out, const BaseVector &v) |
Declare that the operator << exists but is defined in BaseVector.cpp. More... | |
Get information about the content and structure of this vector | |
enum | ElementType { ELEMENT_UNKNOWN = 0 , ELEMENT_FLOAT , ELEMENT_INT } |
virtual ElementType | getElementType () const |
virtual std::size_t | getElementSize () const |
virtual bool | isFull () const |
Return true if this vector is full, i.a. all elements are stored in memory. More... | |
bool | isSparse () const |
|
inlinevirtual |
Add v to the existing value of element i.
Implemented in sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, sofa::linearalgebra::FullVector< SReal >, and sofa::linearalgebra::EigenVector< TReal, TBlockSize >.
|
inlinevirtual |
Add to the values of n double elements, starting at element i0.
|
inlinevirtual |
Add to the values of n float elements, starting at element i0.
|
inlinevirtual |
Add to the values of n int elements, starting at element i0.
|
inlineprotected |
|
pure virtual |
Reset all values to 0.
Implemented in sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, sofa::linearalgebra::FullVector< SReal >, and sofa::linearalgebra::EigenVector< TReal, TBlockSize >.
|
inlinevirtual |
Reset the value of element i to 0.
Reimplemented in sofa::linearalgebra::EigenVector< TReal, TBlockSize >, sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, and sofa::linearalgebra::FullVector< SReal >.
Read the value of element i.
Implemented in sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, sofa::linearalgebra::FullVector< SReal >, and sofa::linearalgebra::EigenVector< TReal, TBlockSize >.
|
inlinevirtual |
Get the values of n elements, starting at element i0, into given double buffer, or return the pointer to the data if the in-memory format is compatible.
|
inlinevirtual |
Get the values of n elements, starting at element i0, into given float buffer, or return the pointer to the data if the in-memory format is compatible.
|
inlinevirtual |
Get the values of n elements, starting at element i0, into given int buffer, or return the pointer to the data if the in-memory format is compatible.
|
inlineprotected |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Return true if this vector is full, i.a. all elements are stored in memory.
|
inline |
Return true if this vector is sparse, i.a. only some of the elements are stored in memory. This is the exact opposite to isFull().
|
pure virtual |
Resize the vector, and reset all values to 0.
Implemented in sofa::linearalgebra::EigenVector< TReal, TBlockSize >, sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, and sofa::linearalgebra::FullVector< SReal >.
Write the value of element i.
Implemented in sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, sofa::linearalgebra::FullVector< SReal >, and sofa::linearalgebra::EigenVector< TReal, TBlockSize >.
|
inlinevirtual |
Write the values of n double elements, starting at element i0.
|
inlinevirtual |
Write the values of n float elements, starting at element i0.
|
inlinevirtual |
Write the values of n int elements, starting at element i0.
|
inlineprotected |
|
pure virtual |
Number of elements.
Implemented in sofa::linearalgebra::FullVector< T >, sofa::linearalgebra::FullVector< Real >, sofa::linearalgebra::FullVector< SReal >, and sofa::linearalgebra::EigenVector< TReal, TBlockSize >.
|
friend |
Declare that the operator << exists but is defined in BaseVector.cpp.