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

Structure for distributed vectors. More...

#include <VectorCollection.hxx>

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

Public Types

typedef T::value_type value_type
 
typedef T::pointer pointer
 
typedef T::const_pointer const_pointer
 
typedef T::reference reference
 
typedef T::const_reference const_reference
 
typedef T vector_type
 
typedef vector_type * vector_pointer
 
typedef vector_type & vector_reference
 
typedef Vector< vector_type, VectFull, NewAlloc< vector_type > > collection_type
 
typedef collection_typecollection_reference
 
typedef Collection storage
 
typedef Allocator allocator
 

Public Member Functions

 Vector ()
 Methods. More...
 
 Vector (int i)
 Main constructor. More...
 
 Vector (const Vector< T, Collection, Allocator > &A)
 Copy constructor. More...
 
 ~Vector ()
 Destructor. More...
 
void Clear ()
 Clears the vector collection. More...
 
void Reallocate (int i)
 Reallocates the vector collection. More...
 
void Deallocate ()
 Clears the vector collection. More...
 
template<class T0 , class Storage0 , class Allocator0 >
void AddVector (const Vector< T0, Storage0, Allocator0 > &vector)
 Adds a vector to the list of vectors. More...
 
template<class T0 , class Storage0 , class Allocator0 >
void AddVector (const Vector< T0, Storage0, Allocator0 > &vector, string name)
 Adds a vector to the list of vectors. More...
 
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (int i, const Vector< T0, Storage0, Allocator0 > &vector)
 Sets a vector in the list of vectors. More...
 
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (int i, const Vector< T0, Storage0, Allocator0 > &vector, string name)
 Sets a vector in the list of vectors. More...
 
template<class T0 , class Storage0 , class Allocator0 >
void SetVector (string name, const Vector< T0, Storage0, Allocator0 > &vector)
 Sets a vector in the list of vectors. More...
 
void SetName (int i, string name)
 Sets the name of a given underlying vector. More...
 
void SetData (const Vector< T, Collection, Allocator > &X)
 Changes the length of the collection and sets its data array. More...
 
void Nullify ()
 Nullifies vectors of the collection without memory deallocation.
 
int GetM () const
 Returns the total number of elements. More...
 
int GetLength () const
 Returns the total number of elements. More...
 
int GetNvector () const
 Returns the number of aggregated vectors. More...
 
const Vector< int, VectFull, MallocAlloc< int > > & GetVectorLength () const
 Returns the length vector of the underlying vectors. More...
 
const Vector< int, VectFull, MallocAlloc< int > > & GetLengthSum () const
 Returns the cumulative sum of the lengths of the underlying vectors. More...
 
int GetVectorIndex (string name) const
 Returns the vector index of the aggregated vector named name. More...
 
int GetIndex (string name) const
 Returns the index of the first element of the aggregated vector named name. More...
 
collection_reference GetVector ()
 Returns the list of vectors. More...
 
const_collection_reference GetVector () const
 
vector_reference GetVector (int i)
 Returns one of the aggregated vectors. More...
 
const_vector_reference GetVector (int i) const
 Returns one of the aggregated vectors. More...
 
vector_reference GetVector (string name)
 Returns one of the aggregated vectors. More...
 
const_vector_reference GetVector (string name) const
 Returns one of the aggregated vectors. More...
 
const_reference operator() (int i) const
 Access operator. More...
 
reference operator() (int i)
 Access operator. More...
 
Vector< T, Collection, Allocator > & operator= (const Vector< T, Collection, Allocator > &X)
 Duplicates a vector collection (assignment operator). More...
 
void Copy (const Vector< T, Collection, Allocator > &X)
 Duplicates a vector collection. More...
 
template<class T0 , class Allocator0 >
void Copy (const Vector< T0, VectFull, Allocator0 > &X)
 Copies the values of a full vector into the current vector. More...
 
template<class T0 >
Vector< T, Collection, Allocator > & operator*= (const T0 &X)
 Multiplies a vector collection by a scalar. More...
 
template<class T0 >
void Fill (const T0 &x)
 Fills the collection with a given value. More...
 
void Print () const
 Displays the vector.
 
void Write (string FileName, bool with_size=true) const
 Writes the inner vectors in a file. More...
 
void Write (ostream &FileStream, bool with_size=true) const
 Writes the vector in a file stream. More...
 
void WriteText (string FileName) const
 Writes the vector in a file. More...
 
void WriteText (ostream &FileStream) const
 Writes the vector in a file stream. More...
 
void Read (string FileName)
 Sets the vector from a file. More...
 
void Read (string FileName, Vector< int, VectFull, MallocAlloc< int > > &length_)
 Sets the vector from a file. More...
 
void Read (istream &FileStream, Vector< int, VectFull, MallocAlloc< int > > &length_)
 Sets the vector from a file stream. More...
 
size_t GetSize () const
 Returns the number of elements stored. More...
 
size_t GetMemorySize () const
 Returns the memory used by the object in bytes. 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...
 

Public Attributes

const typedef vector_type * const_vector_pointer
 
const typedef vector_type & const_vector_reference
 
const typedef collection_type const_collection_type
 
const typedef collection_typeconst_collection_reference
 

Protected Attributes

int Nvector_
 
Vector< int, VectFull, MallocAlloc< int > > length_
 
Vector< int, VectFull, MallocAlloc< int > > length_sum_
 
collection_type vector_
 
map< string, int > label_map_
 Indexes of the inner vectors that have a name.
 
vector< string > label_vector_
 Names associated with the inner vectors.
 
size_t m_
 
pointer data_
 

Detailed Description

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

Structure for distributed vectors.

Definition at line 38 of file VectorCollection.hxx.

Constructor & Destructor Documentation

◆ Vector() [1/3]

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

Methods.

Default constructor.

Nothing is allocated. The vector length is set to zero.

Definition at line 46 of file VectorCollectionInline.cxx.

◆ Vector() [2/3]

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::Vector ( int  i)
inlineexplicit

Main constructor.

Builds a vector collection of a given size.

Parameters
[in]ilength of the vector.

Definition at line 58 of file VectorCollectionInline.cxx.

◆ Vector() [3/3]

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

Copy constructor.

Builds a copy of a vector collection.

Parameters
[in]Vvector collection to be copied.

Definition at line 74 of file VectorCollectionInline.cxx.

◆ ~Vector()

template<class T , class Allocator >
Seldon::Vector< T, Collection, Allocator >::~Vector

Destructor.

The inner vectors are nullified so that their memory blocks should not be deallocated.

Definition at line 46 of file VectorCollection.cxx.

Member Function Documentation

◆ AddVector() [1/2]

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::AddVector ( const Vector< T0, Storage0, Allocator0 > &  vector)

Adds a vector to the list of vectors.

The vector is "appended" to the existing data.

Parameters
[in]vectorvector to be appended.

Definition at line 305 of file VectorCollection.cxx.

◆ AddVector() [2/2]

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::AddVector ( const Vector< T0, Storage0, Allocator0 > &  vector,
string  name 
)

Adds a vector to the list of vectors.

The vector is "appended" to the existing data.

Parameters
[in]vectorvector to be appended.
[in]namename of the vector to be appended.

Definition at line 336 of file VectorCollection.cxx.

◆ Clear()

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

Clears the vector collection.

The inner vectors are nullified so that their memory blocks should not be deallocated.

Definition at line 60 of file VectorCollection.cxx.

◆ Copy() [1/2]

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

Duplicates a vector collection.

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

Definition at line 264 of file VectorCollection.cxx.

◆ Copy() [2/2]

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

Copies the values of a full vector into the current vector.

Parameters
[in]Xfull vector to be copied.
Note
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 283 of file VectorCollection.cxx.

◆ Deallocate()

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Deallocate

Clears the vector collection.

The inner vectors are cleared and the memory blocks are deallocated.

Definition at line 96 of file VectorCollection.cxx.

◆ Fill()

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

Fills the collection with a given value.

Parameters
xvalue to fill the collection with.

Definition at line 473 of file VectorCollection.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.

◆ 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, Collection, Allocator >::GetIndex ( string  name) const

Returns the index of the first element of the aggregated vector named name.

Parameters
[in]namename of the aggregated vector.
Returns
The index of the first element of the aggregated vector.

Definition at line 139 of file VectorCollection.cxx.

◆ GetLength()

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetLength
inline

Returns the total number of elements.

Returns
The total length of the vector.

Definition at line 102 of file VectorCollectionInline.cxx.

◆ GetLengthSum()

template<class T , class Allocator >
const Vector< int, VectFull, MallocAlloc< int > > & Seldon::Vector< T, Collection, Allocator >::GetLengthSum
inline

Returns the cumulative sum of the lengths of the underlying vectors.

Returns
The cumulative sum of the lengths of the underlying vectors.

Definition at line 137 of file VectorCollectionInline.cxx.

◆ GetM()

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetM
inline

Returns the total number of elements.

Returns
The total length of the vector.

Definition at line 91 of file VectorCollectionInline.cxx.

◆ GetMemorySize()

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

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 165 of file VectorInline.cxx.

◆ GetNvector()

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetNvector
inline

Returns the number of aggregated vectors.

Returns
The total number of aggregated vectors.

Definition at line 113 of file VectorCollectionInline.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.

◆ GetVector() [1/5]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_collection_reference Seldon::Vector< T, Collection, Allocator >::GetVector
inline

Returns the list of vectors.

Returns
The list of the aggregated vectors.

Definition at line 149 of file VectorCollectionInline.cxx.

◆ GetVector() [2/5]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( int  i)
inline

Returns one of the aggregated vectors.

Parameters
[in]ithe index of the vector to be returned.
Returns
The i th aggregated vector.

Definition at line 174 of file VectorCollectionInline.cxx.

◆ GetVector() [3/5]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( int  i) const
inline

Returns one of the aggregated vectors.

Parameters
[in]ithe index of the vector to be returned.
Returns
The i th aggregated vector.

Definition at line 188 of file VectorCollectionInline.cxx.

◆ GetVector() [4/5]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( string  name)

Returns one of the aggregated vectors.

Parameters
[in]namethe name of the vector to be returned.
Returns
The aggregated vector named name.

Definition at line 176 of file VectorCollection.cxx.

◆ GetVector() [5/5]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::const_vector_reference Seldon::Vector< T, Collection, Allocator >::GetVector ( string  name) const

Returns one of the aggregated vectors.

Parameters
[in]namethe name of the vector to be returned.
Returns
The aggregated vector named name.

Definition at line 158 of file VectorCollection.cxx.

◆ GetVectorIndex()

template<class T , class Allocator >
int Seldon::Vector< T, Collection, Allocator >::GetVectorIndex ( string  name) const

Returns the vector index of the aggregated vector named name.

Parameters
[in]namename of the aggregated vector.
Returns
The vector index of the aggregated vector.

Definition at line 122 of file VectorCollection.cxx.

◆ GetVectorLength()

template<class T , class Allocator >
const Vector< int, VectFull, MallocAlloc< int > > & Seldon::Vector< T, Collection, Allocator >::GetVectorLength
inline

Returns the length vector of the underlying vectors.

Returns
The lengths of the underlying vectors.

Definition at line 125 of file VectorCollectionInline.cxx.

◆ operator()() [1/2]

template<class T , class Allocator >
Vector< T, Collection, Allocator >::reference Seldon::Vector< T, Collection, Allocator >::operator() ( int  i)

Access operator.

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

Definition at line 199 of file VectorCollection.cxx.

◆ operator()() [2/2]

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

Access operator.

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

Definition at line 223 of file VectorCollection.cxx.

◆ operator*=()

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

Multiplies a vector collection by a scalar.

Parameters
[in]alphascalar.

Definition at line 201 of file VectorCollectionInline.cxx.

◆ operator=()

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

Duplicates a vector collection (assignment operator).

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

Definition at line 249 of file VectorCollection.cxx.

◆ Read() [1/3]

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Read ( istream &  FileStream,
Vector< int, VectFull, MallocAlloc< int > > &  length 
)

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.

Definition at line 678 of file VectorCollection.cxx.

◆ Read() [2/3]

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

Sets the vector from a file.

Sets the vector according to a binary file that stores the length of the collection (number of inner vectors), followed by the inner vectors (i.e., an integer followed by data).

Parameters
FileNamefile name.

Definition at line 623 of file VectorCollection.cxx.

◆ Read() [3/3]

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Read ( string  FileName,
Vector< int, VectFull, MallocAlloc< int > > &  length 
)

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.

Definition at line 652 of file VectorCollection.cxx.

◆ Reallocate()

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::Reallocate ( int  i)

Reallocates the vector collection.

This method first clears the collection. Then it allocates a new vector of size i, and puts this vector in the collection. On exit, the collection is only composed of this vector of size i.

Parameters
[in]inew size.

Definition at line 81 of file VectorCollection.cxx.

◆ SetData()

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::SetData ( const Vector< T, Collection, Allocator > &  X)

Changes the length of the collection and sets its data array.

Parameters
[in]Xcollection with the vectors to which the current collection will point on exit.

Definition at line 441 of file VectorCollection.cxx.

◆ SetName()

template<class T , class Allocator >
void Seldon::Vector< T, Collection, Allocator >::SetName ( int  i,
string  name 
)

Sets the name of a given underlying vector.

Parameters
[in]ia given index.
[in]namename of the underlying vector.

Definition at line 412 of file VectorCollection.cxx.

◆ SetVector() [1/3]

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( int  i,
const Vector< T0, Storage0, Allocator0 > &  vector 
)

Sets a vector in the list of vectors.

Parameters
[in]iindex of the vector to be set.
[in]vectornew value of the vector.

Definition at line 353 of file VectorCollection.cxx.

◆ SetVector() [2/3]

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( int  i,
const Vector< T0, Storage0, Allocator0 > &  vector,
string  name 
)

Sets a vector in the list of vectors.

Parameters
[in]iindex of the vector to be set.
[in]vectorvector to which the i th vector is set.
[in]namenew name of the i th vector.

Definition at line 377 of file VectorCollection.cxx.

◆ SetVector() [3/3]

template<class T , class Allocator >
template<class T0 , class Storage0 , class Allocator0 >
void Seldon::Vector< T, Collection, Allocator >::SetVector ( string  name,
const Vector< T0, Storage0, Allocator0 > &  vector 
)

Sets a vector in the list of vectors.

Parameters
[in]namename of the vector to be set.
[in]vectornew value of the vector.

Definition at line 393 of file VectorCollection.cxx.

◆ Write() [1/2]

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

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 532 of file VectorCollection.cxx.

◆ Write() [2/2]

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

Writes the inner vectors 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 505 of file VectorCollection.cxx.

◆ WriteText() [1/2]

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

Writes the vector in a file stream.

All elements of the vector are stored in text format. The length is not stored.

Parameters
FileStreamfile stream.

Definition at line 594 of file VectorCollection.cxx.

◆ WriteText() [2/2]

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

Writes the vector in a file.

All elements of the vector are stored in text format. The length is not stored.

Parameters
FileNamefile name.

Definition at line 566 of file VectorCollection.cxx.


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