Public Types | Public Member Functions | Protected Attributes | List of all members
Seldon::Vector< T, VectSparse, Allocator > Class Template Reference

Sparse vector class. More...

#include <SparseVector.hxx>

Inheritance diagram for Seldon::Vector< T, VectSparse, Allocator >:
Seldon::Vector< T, VectFull, Allocator > Seldon::Vector_Base< T, Allocator >

Public Types

typedef Allocator::value_type value_type
 
typedef Allocator::pointer pointer
 
typedef Allocator::const_pointer const_pointer
 
typedef Allocator::reference reference
 
typedef Allocator::const_reference const_reference
 
typedef SeldonDefaultAllocator< VectFull, int >::allocator AllocatorInt
 
typedef VectSparse storage
 
typedef Allocator allocator
 

Public Member Functions

 Vector ()
 Default constructor. More...
 
 Vector (size_t i)
 Main constructor. More...
 
 Vector (const Vector< T, VectSparse, Allocator > &A)
 Copy constructor. More...
 
 ~Vector ()
 Destructor.
 
void Clear ()
 Clears the vector. More...
 
void Reallocate (size_t i)
 Vector reallocation. More...
 
void ReallocateVector (size_t i)
 Vector reallocation. More...
 
void Resize (size_t i)
 Changes the number of non-zero entries of the vector. More...
 
void ResizeVector (size_t i)
 Changes the number of non-zero entries of the vector. More...
 
void SetData (size_t nz, T *data, int *index)
 Changes the length of the vector and sets its data array (low level method). More...
 
template<class Allocator2 >
void SetData (Vector< T, VectFull, Allocator2 > &data, Vector< int > &index)
 Changes the length of the vector and sets its data array (low level method). More...
 
template<class Allocator2 >
void SetData (const Vector< T, VectSparse, Allocator2 > &V)
 Lets the current vector point to the data of a second vector (low level method). More...
 
void Nullify ()
 Clears the vector without releasing memory. More...
 
reference Value (int i)
 Access operator. More...
 
const_reference Value (int i) const
 Access operator. More...
 
int & Index (int i)
 Access operator. More...
 
int Index (int i) const
 Access operator. More...
 
value_type operator() (int i)
 Access method. More...
 
reference Get (int i)
 Access method. More...
 
reference Val (int i)
 Access method. More...
 
value_type operator() (int i) const
 Access operator. More...
 
const_reference Get (int i) const
 Access method. More...
 
const_reference Val (int i) const
 Access method. More...
 
Vector< T, VectSparse, Allocator > & operator= (const Vector< T, VectSparse, Allocator > &X)
 Duplicates a vector (assignment operator). More...
 
template<class T2 , class Alloc2 >
void Copy (const Vector< T2, VectSparse, Alloc2 > &X)
 Duplicates a vector. More...
 
int * GetIndex () const
 Returns a pointer to the array containing the indices of the non-zero entries. More...
 
size_t GetMemorySize () const
 Returns the memory used by the object in bytes. More...
 
template<class T0 >
Vector< T, VectSparse, Allocator > & operator= (const T0 &X)
 Fills the vector with a given value. More...
 
void Print () const
 Displays the vector.
 
void Assemble ()
 Assembles the vector. More...
 
template<class T0 >
void RemoveSmallEntry (const T0 &epsilon)
 Removes small entries. More...
 
void AddInteraction (int i, const T &val)
 Adds val to the vector component #i. More...
 
void AddInteractionRow (size_t, int *, T *, bool already_sorted=false)
 Adds given values to several components of the vector. More...
 
template<class Allocator0 >
void AddInteractionRow (size_t nb, const Vector< int > &col, const Vector< T, VectFull, Allocator0 > &val, bool already_sorted=false)
 Adds given values to several components of the vector. More...
 
ClassComplexType< T >::Treal GetNormInf () const
 Returns the infinite norm. More...
 
int GetNormInfIndex () const
 Returns the index of the highest absolute value. More...
 
void Write (string FileName) const
 Writes the vector in a file. More...
 
void Write (ostream &FileStream) const
 Writes the vector in a stream, in binary format. More...
 
void WriteText (string FileName) const
 Writes the vector in a text file. More...
 
void WriteText (ostream &FileStream) const
 Writes the vector in a stream, in text format. More...
 
void Read (string FileName)
 Sets the vector from a file in binary format. More...
 
void Read (istream &FileStream)
 Sets the vector from a file stream, in binary format. More...
 
void ReadText (string FileName)
 Sets the vector from a text file. More...
 
void ReadText (istream &FileStream)
 Sets the vector from a file stream, in text format. More...
 
void SetData (size_t i, pointer data)
 
template<class Allocator0 >
void SetData (const Vector< T, VectFull, Allocator0 > &V)
 Lets the current vector point to the data of another vector. More...
 
reference operator() (long i)
 Access operator. More...
 
const_reference operator() (long i) const
 Access operator. More...
 
reference Get (long i)
 Access to element i. More...
 
const_reference Get (long i) const
 Access to element i. More...
 
void Copy (const Vector< T, VectFull, Allocator > &X)
 Duplicates a vector. More...
 
Vector< T, VectFull, Allocator > Copy () const
 Duplicates a vector. More...
 
void Append (const T &x)
 Appends an element to the vector. More...
 
template<class T0 >
void PushBack (const T0 &x)
 Appends an element at the end of the vector. More...
 
template<class Allocator0 >
void PushBack (const Vector< T, VectFull, Allocator0 > &X)
 Appends a vector X at the end of the vector. More...
 
size_t GetDataSize ()
 Returns the number of elements stored. More...
 
void Zero ()
 Sets all elements to zero. More...
 
void Fill ()
 Fills the vector with 0, 1, 2, ...
 
template<class T0 >
void Fill (const T0 &x)
 Fills the vector with a given value. More...
 
template<class T0 >
Vector< T, VectFull, Allocator > & operator*= (const T0 &X)
 Multiplies a vector by a scalar. More...
 
template<class E >
Vector< T, VectFull, Allocator > & operator+= (const VectorExpression< T, E > &)
 Operator +=, *this = *this + X where X is an expression.
 
template<class E >
Vector< T, VectFull, Allocator > & operator-= (const VectorExpression< T, E > &)
 Operator -=, *this = *this - X where X is an expression.
 
void FillRand ()
 Fills the vector randomly. More...
 
void Write (string FileName, bool with_size=true) const
 Writes the vector in a file. More...
 
void Write (ostream &FileStream, bool with_size=true) const
 Writes the vector in a file stream. More...
 
void Read (string FileName, bool with_size=true)
 Sets the vector from a file. More...
 
void Read (istream &FileStream, bool with_size=true)
 Sets the vector from a file stream. More...
 
long GetM () const
 Returns the number of elements. More...
 
size_t GetLength () const
 Returns the number of elements. More...
 
size_t GetSize () const
 Returns the number of elements stored. More...
 
pointer GetData () const
 Returns a pointer to data_ (stored data). More...
 
const_pointer GetDataConst () const
 Returns a const pointer to data_ (stored data). More...
 
void * GetDataVoid () const
 Returns a pointer of type "void*" to the data array (data_). More...
 
const void * GetDataConstVoid () const
 Returns a pointer of type "const void*" to the data array (data_). More...
 

Protected Attributes

size_t m_
 
pointer data_
 

Detailed Description

template<class T, class Allocator>
class Seldon::Vector< T, VectSparse, Allocator >

Sparse vector class.

Definition at line 29 of file SparseVector.hxx.

Constructor & Destructor Documentation

◆ Vector() [1/3]

template<class T , class Allocator >
Seldon::Vector< T, VectSparse, Allocator >::Vector
inlineexplicit

Default constructor.

On exit, the vector is empty.

Definition at line 39 of file SparseVectorInline.cxx.

◆ Vector() [2/3]

template<class T , class Allocator >
Seldon::Vector< T, VectSparse, Allocator >::Vector ( size_t  i)
explicit

Main constructor.

Builds a vector of a given size.

Parameters
ilength of the vector.

Definition at line 38 of file SparseVector.cxx.

◆ Vector() [3/3]

template<class T , class Allocator >
Seldon::Vector< T, VectSparse, Allocator >::Vector ( const Vector< T, VectSparse, Allocator > &  V)
inline

Copy constructor.

Builds a copy of a vector.

Parameters
Vvector to be copied.

Definition at line 52 of file SparseVectorInline.cxx.

Member Function Documentation

◆ AddInteraction()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::AddInteraction ( int  i,
const T &  val 
)

Adds val to the vector component #i.

If the vector has no entry at i, a new entry with value val is introduced. Otherwise, this method sums the existing value and val.

Parameters
[in]iindex of the component.
[in]valvalue to be added to the vector component i.

Definition at line 560 of file SparseVector.cxx.

◆ AddInteractionRow() [1/2]

template<class T , class Allocator >
template<class Allocator0 >
void Seldon::Vector< T, VectSparse, Allocator >::AddInteractionRow ( size_t  n,
const Vector< int > &  index2,
const Vector< T, VectFull, Allocator0 > &  value2,
bool  already_sorted = false 
)

Adds given values to several components of the vector.

This method sorts the values to be added (according to their indices) and adds them with the vector values. For every component, if the vector has no entry, a new entry is introduced. Otherwise, the method sums the existing value and the corresponsing value in value.

Parameters
[in]nnumber of values to be added.
[in]indexindices of the values to be added.
[in]valuevalues to be added.
[in]already_sortedtrue if the indices are already sorted.

Definition at line 629 of file SparseVector.cxx.

◆ AddInteractionRow() [2/2]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::AddInteractionRow ( size_t  n,
int *  index,
T *  value,
bool  already_sorted = false 
)

Adds given values to several components of the vector.

This method sorts the values to be added (according to their indices) and adds them with the vector values. For every component, if the vector has no entry, a new entry is introduced. Otherwise, the method sums the existing value and the corresponsing value in value.

Parameters
[in]nnumber of values to be added.
[in]indexindices of the values to be added.
[in]valuevalues to be added.
[in]already_sortedtrue if the indices are already sorted.

Definition at line 604 of file SparseVector.cxx.

◆ Append()

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Append ( const T &  x)
inlineinherited

Appends an element to the vector.

Parameters
xelement to be appended.
Warning
This method will only work if the allocator preserves the elements while reallocating.

Definition at line 665 of file VectorInline.cxx.

◆ Assemble()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Assemble

Assembles the vector.

Warning
If you use the method AddInteraction, you don't need to call that method.

Definition at line 509 of file SparseVector.cxx.

◆ Clear()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Clear

Clears the vector.

Destructs the vector.

Warning
On exit, the vector is an empty vector.

Definition at line 80 of file SparseVector.cxx.

◆ Copy() [1/3]

template<class T , class Allocator >
Vector< T, VectFull, Allocator > Seldon::Vector< T, VectFull, Allocator >::Copy
inlineinherited

Duplicates a vector.

Returns
A copy of the vector.
Note
Memory is duplicated: the returned vector is therefore independent from the current instance after the copy.

Definition at line 600 of file VectorInline.cxx.

◆ Copy() [2/3]

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Copy ( const Vector< T, VectFull, Allocator > &  X)
inlineinherited

Duplicates a vector.

Parameters
Xvector to be copied.
Note
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 584 of file VectorInline.cxx.

◆ Copy() [3/3]

template<class T , class Allocator >
template<class T2 , class Alloc2 >
void Seldon::Vector< T, VectSparse, Allocator >::Copy ( const Vector< T2, VectSparse, Alloc2 > &  X)

Duplicates a vector.

Parameters
Xvector to be copied.
Note
Memory is duplicated: X is therefore independent from the current instance after the copy.

Definition at line 465 of file SparseVector.cxx.

◆ Fill()

template<class T , class Allocator >
template<class T0 >
void Seldon::Vector< T, VectFull, Allocator >::Fill ( const T0 &  x)
inlineinherited

Fills the vector with a given value.

Parameters
xvalue to fill the vector with.

Definition at line 749 of file VectorInline.cxx.

◆ FillRand()

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::FillRand
inlineinherited

Fills the vector randomly.

Note
The random generator is very basic.

Definition at line 777 of file VectorInline.cxx.

◆ Get() [1/4]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::reference Seldon::Vector< T, VectSparse, Allocator >::Get ( int  i)

Access method.

Returns the value of element i.

Parameters
[in]iindex.
Returns
Element i of the vector.
Exceptions
WrongArgumentNo reference can be returned because the element is a zero entry (not stored in the vector).

Definition at line 366 of file SparseVector.cxx.

◆ Get() [2/4]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::const_reference Seldon::Vector< T, VectSparse, Allocator >::Get ( int  i) const

Access method.

Returns the value of element i.

Parameters
[in]iindex.
Returns
Element i of the vector.
Exceptions
WrongArgumentNo reference can be returned because the element is a zero entry (not stored in the vector).

Definition at line 392 of file SparseVector.cxx.

◆ Get() [3/4]

template<class T , class Allocator >
Vector< T, VectFull, Allocator >::reference Seldon::Vector< T, VectFull, Allocator >::Get ( long  i)
inlineinherited

Access to element i.

Parameters
iindex.
Returns
The value of the vector at i.

Definition at line 513 of file VectorInline.cxx.

◆ Get() [4/4]

template<class T , class Allocator >
Vector< T, VectFull, Allocator >::const_reference Seldon::Vector< T, VectFull, Allocator >::Get ( long  i) const
inlineinherited

Access to element i.

Parameters
iindex.
Returns
The value of the vector at i.

Definition at line 549 of file VectorInline.cxx.

◆ GetData()

template<class T , class Allocator >
Vector_Base< T, Allocator >::pointer Seldon::Vector_Base< T, Allocator >::GetData
inlineinherited

Returns a pointer to data_ (stored data).

Returns
A pointer to the data_, i.e. the data array.

Definition at line 177 of file VectorInline.cxx.

◆ GetDataConst()

template<class T , class Allocator >
Vector_Base< T, Allocator >::const_pointer Seldon::Vector_Base< T, Allocator >::GetDataConst
inlineinherited

Returns a const pointer to data_ (stored data).

Returns
A const pointer to the data_, i.e. the data array.

Definition at line 189 of file VectorInline.cxx.

◆ GetDataConstVoid()

template<class T , class Allocator >
const void * Seldon::Vector_Base< T, Allocator >::GetDataConstVoid
inlineinherited

Returns a pointer of type "const void*" to the data array (data_).

Returns
A pointer of type "const void*" to the data array.

Definition at line 212 of file VectorInline.cxx.

◆ GetDataSize()

template<class T , class Allocator >
size_t Seldon::Vector< T, VectFull, Allocator >::GetDataSize
inlineinherited

Returns the number of elements stored.

Returns
The number of elements stored in memory.

Definition at line 710 of file VectorInline.cxx.

◆ GetDataVoid()

template<class T , class Allocator >
void * Seldon::Vector_Base< T, Allocator >::GetDataVoid
inlineinherited

Returns a pointer of type "void*" to the data array (data_).

Returns
A pointer of type "void*" to the data array.

Definition at line 201 of file VectorInline.cxx.

◆ GetIndex()

template<class T , class Allocator >
int * Seldon::Vector< T, VectSparse, Allocator >::GetIndex
inline

Returns a pointer to the array containing the indices of the non-zero entries.

Returns
A pointer to the array of the indices of the non-zero entries.

Definition at line 189 of file SparseVectorInline.cxx.

◆ GetLength()

template<class T , class Allocator >
size_t Seldon::Vector_Base< T, Allocator >::GetLength
inlineinherited

Returns the number of elements.

Returns
The length of the vector.

Definition at line 142 of file VectorInline.cxx.

◆ GetM()

template<class T , class Allocator >
long Seldon::Vector_Base< T, Allocator >::GetM
inlineinherited

Returns the number of elements.

Returns
The length of the vector.

Definition at line 131 of file VectorInline.cxx.

◆ GetMemorySize()

template<class T , class Allocator >
size_t Seldon::Vector< T, VectSparse, Allocator >::GetMemorySize
inline

Returns the memory used by the object in bytes.

In this method, the type T is assumed to be "static" such that sizeof(T) provides the correct size

Definition at line 201 of file SparseVectorInline.cxx.

◆ GetNormInf()

template<class T , class Allocator >
ClassComplexType< T >::Treal Seldon::Vector< T, VectSparse, Allocator >::GetNormInf

Returns the infinite norm.

Returns
The infinite norm.

Definition at line 736 of file SparseVector.cxx.

◆ GetNormInfIndex()

template<class T , class Allocator >
int Seldon::Vector< T, VectSparse, Allocator >::GetNormInfIndex

Returns the index of the highest absolute value.

Returns
The index of the element that has the highest absolute value.

Definition at line 751 of file SparseVector.cxx.

◆ GetSize()

template<class T , class Allocator >
size_t Seldon::Vector_Base< T, Allocator >::GetSize
inlineinherited

Returns the number of elements stored.

Returns
The length of the vector stored.

Definition at line 153 of file VectorInline.cxx.

◆ Index() [1/2]

template<class T , class Allocator >
int & Seldon::Vector< T, VectSparse, Allocator >::Index ( int  i)
inline

Access operator.

Parameters
iindex.
Returns
The index of the non-zero element #i.

Definition at line 134 of file SparseVectorInline.cxx.

◆ Index() [2/2]

template<class T , class Allocator >
int Seldon::Vector< T, VectSparse, Allocator >::Index ( int  i) const
inline

Access operator.

Parameters
iindex.
Returns
The row number of the non-zero element #i.

Definition at line 151 of file SparseVectorInline.cxx.

◆ Nullify()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Nullify

Clears the vector without releasing memory.

On exit, the vector is empty and the memory has not been released. It is useful for low level manipulations on a Vector instance.

Warning
Memory is not released.

Definition at line 294 of file SparseVector.cxx.

◆ operator()() [1/4]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::value_type Seldon::Vector< T, VectSparse, Allocator >::operator() ( int  i)

Access method.

Returns the value of element i.

Parameters
[in]iindex.
Returns
Element i of the vector.
Exceptions
WrongArgumentNo reference can be returned because the element is a zero entry (not stored in the vector).

Definition at line 340 of file SparseVector.cxx.

◆ operator()() [2/4]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::value_type Seldon::Vector< T, VectSparse, Allocator >::operator() ( int  i) const

Access operator.

Parameters
iindex.
Returns
The value of the vector at i.

Definition at line 314 of file SparseVector.cxx.

◆ operator()() [3/4]

template<class T , class Allocator >
Vector< T, VectFull, Allocator >::reference Seldon::Vector< T, VectFull, Allocator >::operator() ( long  i)
inlineinherited

Access operator.

Parameters
iindex.
Returns
The value of the vector at 'i'.

Definition at line 495 of file VectorInline.cxx.

◆ operator()() [4/4]

template<class T , class Allocator >
Vector< T, VectFull, Allocator >::const_reference Seldon::Vector< T, VectFull, Allocator >::operator() ( long  i) const
inlineinherited

Access operator.

Parameters
iindex.
Returns
The value of the vector at 'i'.

Definition at line 531 of file VectorInline.cxx.

◆ operator*=()

template<class T , class Allocator >
template<class T0 >
Vector< T, VectFull, Allocator > & Seldon::Vector< T, VectFull, Allocator >::operator*= ( const T0 &  alpha)
inlineinherited

Multiplies a vector by a scalar.

Parameters
alphascalar.

Definition at line 612 of file VectorInline.cxx.

◆ operator=() [1/2]

template<class T , class Allocator >
template<class T0 >
Vector< T, VectSparse, Allocator > & Seldon::Vector< T, VectSparse, Allocator >::operator= ( const T0 &  x)

Fills the vector with a given value.

Parameters
xvalue to fill the vector with.

Definition at line 486 of file SparseVector.cxx.

◆ operator=() [2/2]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator > & Seldon::Vector< T, VectSparse, Allocator >::operator= ( const Vector< T, VectSparse, Allocator > &  X)
inline

Duplicates a vector (assignment operator).

Parameters
Xvector to be copied.
Note
Memory is duplicated: X is therefore independent from the current instance after the copy.

Definition at line 170 of file SparseVectorInline.cxx.

◆ PushBack() [1/2]

template<class T , class Allocator >
template<class T0 >
void Seldon::Vector< T, VectFull, Allocator >::PushBack ( const T0 &  x)
inlineinherited

Appends an element at the end of the vector.

Parameters
xelement to be appended.

Definition at line 678 of file VectorInline.cxx.

◆ PushBack() [2/2]

template<class T , class Allocator >
template<class Allocator0 >
void Seldon::Vector< T, VectFull, Allocator >::PushBack ( const Vector< T, VectFull, Allocator0 > &  X)
inlineinherited

Appends a vector X at the end of the vector.

Parameters
Xvector to be appended.

Definition at line 691 of file VectorInline.cxx.

◆ Read() [1/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Read ( istream &  stream)

Sets the vector from a file stream, in binary format.

Sets the vector according to a binary stream that stores the data like method Write(ostream&).

Parameters
streamstream from which to read the vector values.

Definition at line 928 of file SparseVector.cxx.

◆ Read() [2/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Read ( istream &  FileStream,
bool  with_size = true 
)
inherited

Sets the vector from a file stream.

Sets the vector according to a binary file stream that stores the length of the vector (integer) and all elements.

Parameters
FileStreamfile stream.
with_sizeif set to 'false', the length of the vector is not available in the stream. In this case, the current size N of the vector is unchanged, and N elements are read in the stream.

Definition at line 370 of file Vector.cxx.

◆ Read() [3/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Read ( string  FileName)

Sets the vector from a file in binary format.

Sets the vector according to a binary file that stores the data like method Write(string).

Parameters
FileNamefile name.

Definition at line 904 of file SparseVector.cxx.

◆ Read() [4/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Read ( string  FileName,
bool  with_size = true 
)
inherited

Sets the vector from a file.

Sets the vector according to a binary file that stores the length of the vector (integer) and all elements.

Parameters
FileNamefile name.
with_sizeif set to 'false', the length of the vector is not available in the file. In this case, the current size N of the vector is unchanged, and N elements are read in the file.

Definition at line 341 of file Vector.cxx.

◆ ReadText() [1/2]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::ReadText ( istream &  stream)

Sets the vector from a file stream, in text format.

Sets the vector according to a stream, in text format, that stores the data like method WriteText(ostream&).

Parameters
streamstream from which to read the vector values.

Definition at line 987 of file SparseVector.cxx.

◆ ReadText() [2/2]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::ReadText ( string  FileName)

Sets the vector from a text file.

Sets the vector according to a text file that stores the data like method WriteText(string).

Parameters
FileNamefile name.

Definition at line 963 of file SparseVector.cxx.

◆ Reallocate()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Reallocate ( size_t  i)
inline

Vector reallocation.

The vector is resized.

Parameters
inew length of the vector.
Warning
Depending on your allocator, previous non-zero entries may be lost.

Definition at line 68 of file SparseVectorInline.cxx.

◆ ReallocateVector()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::ReallocateVector ( size_t  i)

Vector reallocation.

The vector is resized.

Parameters
inew length of the vector.
Warning
Depending on your allocator, previous non-zero entries may be lost.

Definition at line 123 of file SparseVector.cxx.

◆ RemoveSmallEntry()

template<class T , class Allocator >
template<class T0 >
void Seldon::Vector< T, VectSparse, Allocator >::RemoveSmallEntry ( const T0 &  epsilon)

Removes small entries.

Any number whose absolute value is below (or equal) to epsilon is removed.

Parameters
epsilonthe threshold value.

Definition at line 533 of file SparseVector.cxx.

◆ Resize()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Resize ( size_t  n)

Changes the number of non-zero entries of the vector.

Changes the number of non-zero entries to n. If n non-zero entries are available before resizing, they are all kept. Otherwise, only the first
non-zero entries are kept.

Parameters
nnew number of non-zero entries of the vector.

Definition at line 173 of file SparseVector.cxx.

◆ ResizeVector()

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::ResizeVector ( size_t  n)

Changes the number of non-zero entries of the vector.

Changes the number of non-zero entries to n. If n non-zero entries are available before resizing, they are all kept. Otherwise, only the first
non-zero entries are kept.

Parameters
nnew number of non-zero entries of the vector.

Definition at line 186 of file SparseVector.cxx.

◆ SetData() [1/4]

template<class T , class Allocator >
template<class Allocator0 >
void Seldon::Vector< T, VectFull, Allocator >::SetData ( const Vector< T, VectFull, Allocator0 > &  V)
inlineinherited

Lets the current vector point to the data of another vector.

Deallocates memory allocated for the current data array. Then sets the length and the data of the current vector to that of V. On exit, the current vector shares it data array with V.

Parameters
Vvector whose data should be shared with current instance.
Warning
On exit, V and the current instance share the same data array, and they are likely to free it. As a consequence, before the vectors are destructed, it is necessary to call 'Nullify' on either V or the current instance. In addition, if the current instance is to deallocate the data array, its allocator should be compatible with the allocator that allocated the data array (probably the allocator of V).
Note
This method should only be used by advanced users.

Definition at line 463 of file VectorInline.cxx.

◆ SetData() [2/4]

template<class T , class Allocator >
template<class Allocator2 >
void Seldon::Vector< T, VectSparse, Allocator >::SetData ( const Vector< T, VectSparse, Allocator2 > &  V)

Lets the current vector point to the data of a second vector (low level method).

Reallocates the current vector and lets its data point to those of V.

Parameters
Vthe vector to which the current vector points to (on exit).
Warning
On exit, both V and the current vector point to the same arrays in memory. Only one of them should eventually deallocate the memory blocks. The other one should be nullified by the user. In case the current vector is responsible for the deallocations, its allocator should be compatible with the allocator that created the memory blocks (which is probably the allocator of V).

Definition at line 281 of file SparseVector.cxx.

◆ SetData() [3/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::SetData ( size_t  i,
T *  data,
int *  index 
)

Changes the length of the vector and sets its data array (low level method).

Reallocates a vector and sets the new data array. It is useful to create a vector from pre-existing data.

Parameters
inew length of the vector.
datathe new data array. data contains the new elements of the vector and must therefore contain i elements.
indexthe new index array. index contains the new indices of the non-zero entries and it must therefore contain i elements.
Warning
data has to be used carefully outside the object. Unless you use 'Nullify', data will be freed by the destructor, which means that data must have been allocated carefully. The vector allocator should be compatible.
Note
This method should only be used by advanced users.

Definition at line 224 of file SparseVector.cxx.

◆ SetData() [4/4]

template<class T , class Allocator >
template<class Allocator2 >
void Seldon::Vector< T, VectSparse, Allocator >::SetData ( Vector< T, VectFull, Allocator2 > &  data,
Vector< int > &  index 
)

Changes the length of the vector and sets its data array (low level method).

Reallocates a vector and sets the new data array. It is useful to create a vector from pre-existing data.

Parameters
datathe new data array. data contains the new elements of the vector and must therefore contain i elements.
indexthe new index array. index contains the new indices of the non-zero entries and it must therefore contain i elements.
Note
Vectors data and index are empty vector on exit.

Definition at line 249 of file SparseVector.cxx.

◆ Val() [1/2]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::reference Seldon::Vector< T, VectSparse, Allocator >::Val ( int  i)

Access method.

Returns the value of element i.

Parameters
[in]iindex.
Returns
Element i of the vector.
Exceptions
WrongArgumentif i does not belong to the sparsity pattern

Definition at line 416 of file SparseVector.cxx.

◆ Val() [2/2]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::const_reference Seldon::Vector< T, VectSparse, Allocator >::Val ( int  i) const

Access method.

Returns the value of element i.

Parameters
[in]iindex.
Returns
Element i of the vector.
Exceptions
WrongArgumentif i does not belong to the sparsity pattern

Definition at line 441 of file SparseVector.cxx.

◆ Value() [1/2]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::reference Seldon::Vector< T, VectSparse, Allocator >::Value ( int  i)
inline

Access operator.

Parameters
iindex.
Returns
The value of the non-zero element #i.

Definition at line 99 of file SparseVectorInline.cxx.

◆ Value() [2/2]

template<class T , class Allocator >
Vector< T, VectSparse, Allocator >::const_reference Seldon::Vector< T, VectSparse, Allocator >::Value ( int  i) const
inline

Access operator.

Parameters
iindex.
Returns
The value of the non-zero element #i.

Definition at line 117 of file SparseVectorInline.cxx.

◆ Write() [1/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Write ( ostream &  stream) const

Writes the vector in a stream, in binary format.

It writes in binary format: (1) the number of non-zero entries in the vector (integer), (2) the indices of the non-zero entries (integers), and (3) the non-zero values of the vector.

Parameters
streamstream in which the vector is to be written.

Definition at line 810 of file SparseVector.cxx.

◆ Write() [2/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Write ( ostream &  FileStream,
bool  with_size = true 
) const
inherited

Writes the vector in a file stream.

The length of the vector (integer) and all elements of the vector are stored in binary format.

Parameters
FileStreamfile stream.
with_sizeif set to 'false', the length of the vector is not saved.

Definition at line 152 of file Vector.cxx.

◆ Write() [3/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::Write ( string  FileName) const

Writes the vector in a file.

It stores in binary format: (1) the number of non-zero entries in the vector (integer), (2) the indices of the non-zero entries (integers), and (3) the non-zero values of the vector.

Parameters
FileNamefile name.

Definition at line 785 of file SparseVector.cxx.

◆ Write() [4/4]

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Write ( string  FileName,
bool  with_size = true 
) const
inherited

Writes the vector in a file.

The length of the vector (integer) and all elements of the vector are stored in binary format.

Parameters
FileNamefile name.
with_sizeif set to 'false', the length of the vector is not saved.

Definition at line 124 of file Vector.cxx.

◆ WriteText() [1/2]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::WriteText ( ostream &  stream) const

Writes the vector in a stream, in text format.

All non-zero elements of the vector are stored in text format: every line of the text file contains one index and one value. The length is not stored.

Parameters
streamstream in which the vector is to be written.

Definition at line 874 of file SparseVector.cxx.

◆ WriteText() [2/2]

template<class T , class Allocator >
void Seldon::Vector< T, VectSparse, Allocator >::WriteText ( string  FileName) const

Writes the vector in a text file.

All non-zero elements of the vector are stored in text format: every line of the text file contains one index and one value. The length is not stored.

Parameters
FileNamefile name.

Definition at line 847 of file SparseVector.cxx.

◆ Zero()

template<class T , class Allocator >
void Seldon::Vector< T, VectFull, Allocator >::Zero
inlineinherited

Sets all elements to zero.

Warning
It fills the memory with zeros. If the vector stores complex structures, use 'Fill' instead.

Definition at line 727 of file VectorInline.cxx.


The documentation for this class was generated from the following files: