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

4D array. More...

#include <Array4D.hxx>

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
 

Public Member Functions

 Array4D ()
 Default constructor. More...
 
 Array4D (int i, int j, int k, int l)
 Main constructor. More...
 
 Array4D (const Array4D< T, Allocator > &A)
 Copy constructor.
 
 ~Array4D ()
 Destructor.
 
int GetLength1 () const
 Returns the length in dimension #1. More...
 
int GetLength2 () const
 Returns the length in dimension #2. More...
 
int GetLength3 () const
 Returns the length in dimension #3. More...
 
int GetLength4 () const
 Returns the length in dimension #4. More...
 
long GetSize () const
 Returns the number of elements in the 4D array. More...
 
long GetDataSize () const
 Returns the number of elements stored in memory. More...
 
pointer GetData () const
 Returns a pointer to the data array. More...
 
pointer GetDataPointer (int i, int j, int k, int l) const
 Returns a pointer to an element of data array. More...
 
void Reallocate (int i, int j, int k, int l)
 Reallocates memory to resize the 4D array. More...
 
void Clear ()
 Clears the array. More...
 
reference operator() (int i, int j, int k, int l)
 Access operator. More...
 
const_reference operator() (int i, int j, int k, int l) const
 Access operator. More...
 
Array4D< T, Allocator > & operator= (const Array4D< T, Allocator > &A)
 Duplicates a 4D array (assignment operator). More...
 
void Copy (const Array4D< T, Allocator > &A)
 Duplicates a 4D array. More...
 
size_t GetMemorySize () const
 Returns the memory used by the object in bytes. More...
 
void Zero ()
 Sets all elements to zero. More...
 
void Fill ()
 Fills the array. More...
 
template<class T0 >
void Fill (const T0 &x)
 Fills the 4D array with a given value. More...
 
void FillRand ()
 Fills the 4D array randomly. More...
 
void Print () const
 Displays the array on the standard output. More...
 
void Write (string FileName, bool with_size=true) const
 Writes the 4D array in a file. More...
 
void Write (ofstream &FileStream, bool with_size=true) const
 Writes the 4D array to an output stream. More...
 
void Read (string FileName, bool with_size=true)
 Reads the 4D array from a file. More...
 
void Read (ifstream &FileStream, bool with_size=true)
 Reads the 4D array from an input stream. More...
 

Protected Attributes

int length1_
 
int length2_
 
int length3_
 
int length4_
 
long length34_
 
long length234_
 
pointer data_
 

Detailed Description

template<class T, class Allocator>
class Seldon::Array4D< T, Allocator >

4D array.

This class implements 4D arrays.

Definition at line 39 of file Array4D.hxx.

Constructor & Destructor Documentation

◆ Array4D() [1/2]

template<class T , class Allocator >
Seldon::Array4D< T, Allocator >::Array4D
explicit

Default constructor.

On exit, the array is an empty 0x0x0x0 4D array.

Definition at line 39 of file Array4D.cxx.

◆ Array4D() [2/2]

template<class T , class Allocator >
Seldon::Array4D< T, Allocator >::Array4D ( int  i,
int  j,
int  k,
int  l 
)
explicit

Main constructor.

Builds a i x j x k x l 4D array, but data is not initialized.

Parameters
ilength in dimension #1.
jlength in dimension #2.
klength in dimension #3.
llength in dimension #4.

Definition at line 61 of file Array4D.cxx.

Member Function Documentation

◆ Clear()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Clear

Clears the array.

Destructs the array.

Warning
On exit, the 4D array is empty.

Definition at line 196 of file Array4D.cxx.

◆ Copy()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Copy ( const Array4D< T, Allocator > &  A)
inline

Duplicates a 4D array.

Parameters
A4D array to be copied.
Note
Memory is duplicated: 'A' is therefore independent from the current instance after the copy.

Definition at line 221 of file Array4D_Inline.cxx.

◆ Fill() [1/2]

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Fill

Fills the array.

On exit, the 4D array is filled with 1, 2, 3, 4, ... The order of those numbers depends on the storage.

Definition at line 267 of file Array4D.cxx.

◆ Fill() [2/2]

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

Fills the 4D array with a given value.

On exit, the 4D array is filled with 'x'.

Parameters
xthe value to fill the 4D array with.

Definition at line 282 of file Array4D.cxx.

◆ FillRand()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::FillRand

Fills the 4D array randomly.

On exit, the 4D array is filled with random values.

Definition at line 296 of file Array4D.cxx.

◆ GetData()

template<class T , class Allocator >
Array4D< T, Allocator >::pointer Seldon::Array4D< T, Allocator >::GetData
inline

Returns a pointer to the data array.

Returns a pointer to data, i.e. the data array 'data_' which stores the values.

Returns
A pointer to the data array.

Definition at line 126 of file Array4D_Inline.cxx.

◆ GetDataPointer()

template<class T , class Allocator >
Array4D< T, Allocator >::pointer Seldon::Array4D< T, Allocator >::GetDataPointer ( int  i,
int  j,
int  k,
int  l 
) const
inline

Returns a pointer to an element of data array.

Returns a pointer to an element of data array.

Parameters
iindex along dimension #1.
jindex along dimension #2.
kindex along dimension #3.
lindex along dimension #4.
Returns
A pointer to the data array.

Definition at line 143 of file Array4D_Inline.cxx.

◆ GetDataSize()

template<class T , class Allocator >
long Seldon::Array4D< T, Allocator >::GetDataSize
inline

Returns the number of elements stored in memory.

Returns the number of elements stored in memory by the array, i.e. the product of lengths in the three dimensions.

Returns
The number of elements stored in the array.

Definition at line 112 of file Array4D_Inline.cxx.

◆ GetLength1()

template<class T , class Allocator >
int Seldon::Array4D< T, Allocator >::GetLength1
inline

Returns the length in dimension #1.

Returns
The length in dimension #1.

Definition at line 52 of file Array4D_Inline.cxx.

◆ GetLength2()

template<class T , class Allocator >
int Seldon::Array4D< T, Allocator >::GetLength2
inline

Returns the length in dimension #2.

Returns
The length in dimension #2.

Definition at line 63 of file Array4D_Inline.cxx.

◆ GetLength3()

template<class T , class Allocator >
int Seldon::Array4D< T, Allocator >::GetLength3
inline

Returns the length in dimension #3.

Returns
The length in dimension #3.

Definition at line 74 of file Array4D_Inline.cxx.

◆ GetLength4()

template<class T , class Allocator >
int Seldon::Array4D< T, Allocator >::GetLength4
inline

Returns the length in dimension #4.

Returns
The length in dimension #4.

Definition at line 85 of file Array4D_Inline.cxx.

◆ GetMemorySize()

template<class T , class Allocator >
size_t Seldon::Array4D< T, Allocator >::GetMemorySize

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 242 of file Array4D.cxx.

◆ GetSize()

template<class T , class Allocator >
long Seldon::Array4D< T, Allocator >::GetSize
inline

Returns the number of elements in the 4D array.

Returns the number of elements stored by the 4D array, i.e. the product of the lengths in the three dimensions.

Returns
The number of elements in the 4D array.

Definition at line 98 of file Array4D_Inline.cxx.

◆ operator()() [1/2]

template<class T , class Allocator >
Array4D< T, Allocator >::reference Seldon::Array4D< T, Allocator >::operator() ( int  i,
int  j,
int  k,
int  l 
)
inline

Access operator.

Returns the value of element (i, j, k, l).

Parameters
iindex along dimension #1.
jindex along dimension #2.
kindex along dimension #3.
lindex along dimension #4.
Returns
Element (i, j, k, l) of the 4D array.

Definition at line 165 of file Array4D_Inline.cxx.

◆ operator()() [2/2]

template<class T , class Allocator >
Array4D< T, Allocator >::const_reference Seldon::Array4D< T, Allocator >::operator() ( int  i,
int  j,
int  k,
int  l 
) const
inline

Access operator.

Returns the value of element (i, j, k, l).

Parameters
iindex along dimension #1.
jindex along dimension #2.
kindex along dimension #3.
kindex along dimension #4.
Returns
Element (i, j, k, l) of the 4D array.

Definition at line 188 of file Array4D_Inline.cxx.

◆ operator=()

template<class T , class Allocator >
Array4D< T, Allocator > & Seldon::Array4D< T, Allocator >::operator= ( const Array4D< T, Allocator > &  A)
inline

Duplicates a 4D array (assignment operator).

Parameters
A4D array to be copied.
Note
Memory is duplicated: 'A' is therefore independent from the current instance after the copy.

Definition at line 207 of file Array4D_Inline.cxx.

◆ Print()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Print

Displays the array on the standard output.

Displays elements on the standard output, in text format.

Definition at line 312 of file Array4D.cxx.

◆ Read() [1/2]

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Read ( ifstream &  FileStream,
bool  with_size = true 
)

Reads the 4D array from an input stream.

Reads a 4D array in binary format from an input stream. The dimensions of the array are read (i,j,k,l four integers), and array elements are then read in the same order as it should be in memory

Parameters
FileStreaminput stream.

Definition at line 448 of file Array4D.cxx.

◆ Read() [2/2]

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

Reads the 4D array from a file.

Reads a 4D array stored in binary format in a file. The dimensions of the array are read (i,j,k,l four integers), and array elements are then read in the same order as it should be in memory

Parameters
FileNameinput file name.

Definition at line 420 of file Array4D.cxx.

◆ Reallocate()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Reallocate ( int  i,
int  j,
int  k,
int  l 
)

Reallocates memory to resize the 4D array.

On exit, the array is a i x j x k x l 4D array.

Parameters
ilength in dimension #1.
jlength in dimension #2.
klength in dimension #3.
klength in dimension #4.
Warning
Depending on your allocator, data may be lost.

Definition at line 139 of file Array4D.cxx.

◆ Write() [1/2]

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

Writes the 4D array to an output stream.

Writes the 4D array to an output stream in binary format. The number of rows (integer) and the number of columns (integer) are written, and array elements are then written in the same order as in memory

Parameters
FileStreamoutput stream.

Definition at line 374 of file Array4D.cxx.

◆ Write() [2/2]

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

Writes the 4D array in a file.

Stores the 4D array in a file in binary format. The number of rows (integer) and the number of columns (integer) are written, and matrix elements are then written in the same order as in memory

Parameters
FileNameoutput file name.

Definition at line 347 of file Array4D.cxx.

◆ Zero()

template<class T , class Allocator >
void Seldon::Array4D< T, Allocator >::Zero

Sets all elements to zero.

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

Definition at line 254 of file Array4D.cxx.


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