4D array. More...
#include <Array4D.hxx>
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_ |
4D array.
This class implements 4D arrays.
Definition at line 39 of file Array4D.hxx.
|
explicit |
Default constructor.
On exit, the array is an empty 0x0x0x0 4D array.
Definition at line 39 of file Array4D.cxx.
|
explicit |
Main constructor.
Builds a i x j x k x l 4D array, but data is not initialized.
i | length in dimension #1. |
j | length in dimension #2. |
k | length in dimension #3. |
l | length in dimension #4. |
Definition at line 61 of file Array4D.cxx.
void Seldon::Array4D< T, Allocator >::Clear |
Clears the array.
Destructs the array.
Definition at line 196 of file Array4D.cxx.
|
inline |
Duplicates a 4D array.
A | 4D array to be copied. |
Definition at line 221 of file Array4D_Inline.cxx.
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.
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'.
x | the value to fill the 4D array with. |
Definition at line 282 of file Array4D.cxx.
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.
|
inline |
Returns a pointer to the data array.
Returns a pointer to data, i.e. the data array 'data_' which stores the values.
Definition at line 126 of file Array4D_Inline.cxx.
|
inline |
Returns a pointer to an element of data array.
Returns a pointer to an element of data array.
i | index along dimension #1. |
j | index along dimension #2. |
k | index along dimension #3. |
l | index along dimension #4. |
Definition at line 143 of file Array4D_Inline.cxx.
|
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.
Definition at line 112 of file Array4D_Inline.cxx.
|
inline |
Returns the length in dimension #1.
Definition at line 52 of file Array4D_Inline.cxx.
|
inline |
Returns the length in dimension #2.
Definition at line 63 of file Array4D_Inline.cxx.
|
inline |
Returns the length in dimension #3.
Definition at line 74 of file Array4D_Inline.cxx.
|
inline |
Returns the length in dimension #4.
Definition at line 85 of file Array4D_Inline.cxx.
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.
|
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.
Definition at line 98 of file Array4D_Inline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j, k, l).
i | index along dimension #1. |
j | index along dimension #2. |
k | index along dimension #3. |
l | index along dimension #4. |
Definition at line 165 of file Array4D_Inline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j, k, l).
i | index along dimension #1. |
j | index along dimension #2. |
k | index along dimension #3. |
k | index along dimension #4. |
Definition at line 188 of file Array4D_Inline.cxx.
|
inline |
Duplicates a 4D array (assignment operator).
A | 4D array to be copied. |
Definition at line 207 of file Array4D_Inline.cxx.
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.
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
FileStream | input stream. |
Definition at line 448 of file Array4D.cxx.
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
FileName | input file name. |
Definition at line 420 of file Array4D.cxx.
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.
i | length in dimension #1. |
j | length in dimension #2. |
k | length in dimension #3. |
k | length in dimension #4. |
Definition at line 139 of file Array4D.cxx.
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
FileStream | output stream. |
Definition at line 374 of file Array4D.cxx.
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
FileName | output file name. |
Definition at line 347 of file Array4D.cxx.
void Seldon::Array4D< T, Allocator >::Zero |
Sets all elements to zero.
Definition at line 254 of file Array4D.cxx.