3D array. More...
#include <Array3D.hxx>
Public Member Functions | |
Array3D () | |
Default constructor. More... | |
Array3D (int i, int j, int k) | |
Main constructor. More... | |
Array3D (const Array3D< T, Allocator > &A) | |
Copy constructor. | |
~Array3D () | |
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... | |
long | GetSize () const |
Returns the number of elements in the 3D 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) const |
Returns a pointer to an element of data array. More... | |
void | Reallocate (int i, int j, int k) |
Reallocates memory to resize the 3D array. More... | |
void | SetData (int i, int j, int k, pointer data) |
Changes the size of the array and sets its data array (low level method). More... | |
void | Nullify () |
Clears the 3D array without releasing memory. More... | |
void | Clear () |
Clears the array. More... | |
reference | operator() (int i, int j, int k) |
Access operator. More... | |
const_reference | operator() (int i, int j, int k) const |
Access operator. More... | |
Array3D< T, Allocator > & | operator= (const Array3D< T, Allocator > &A) |
Duplicates a 3D array (assignment operator). More... | |
void | Copy (const Array3D< T, Allocator > &A) |
Duplicates a 3D 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 3D array with a given value. More... | |
void | FillRand () |
Fills the 3D 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 3D array in a file. More... | |
void | Write (ofstream &FileStream, bool with_size=true) const |
Writes the 3D array to an output stream. More... | |
void | Read (string FileName, bool with_size=true) |
Reads the 3D array from a file. More... | |
void | Read (ifstream &FileStream, bool with_size=true) |
Reads the 3D array from an input stream. More... | |
Protected Attributes | |
int | length1_ |
int | length2_ |
int | length3_ |
long | length23_ |
pointer | data_ |
3D array.
This class implements 3D arrays.
Definition at line 38 of file Array3D.hxx.
Seldon::Array3D< T, Allocator >::Array3D |
Default constructor.
On exit, the array is an empty 0x0x0 3D array.
Definition at line 38 of file Array3D.cxx.
Seldon::Array3D< T, Allocator >::Array3D | ( | int | i, |
int | j, | ||
int | k | ||
) |
Main constructor.
Builds a i x j x k 3D array, but data is not initialized.
i | length in dimension #1. |
j | length in dimension #2. |
k | length in dimension #3. |
Definition at line 57 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Clear |
Clears the array.
Destructs the array.
Definition at line 228 of file Array3D.cxx.
|
inline |
Duplicates a 3D array.
A | 3D array to be copied. |
Definition at line 204 of file Array3D_Inline.cxx.
void Seldon::Array3D< T, Allocator >::Fill |
Fills the array.
On exit, the 3D array is filled with 1, 2, 3, 4, ... The order of those numbers depends on the storage.
Definition at line 296 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Fill | ( | const T0 & | x | ) |
Fills the 3D array with a given value.
On exit, the 3D array is filled with 'x'.
x | the value to fill the 3D array with. |
Definition at line 311 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::FillRand |
Fills the 3D array randomly.
On exit, the 3D array is filled with random values.
Definition at line 326 of file Array3D.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 114 of file Array3D_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. |
Definition at line 130 of file Array3D_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 100 of file Array3D_Inline.cxx.
|
inline |
Returns the length in dimension #1.
Definition at line 51 of file Array3D_Inline.cxx.
|
inline |
Returns the length in dimension #2.
Definition at line 62 of file Array3D_Inline.cxx.
|
inline |
Returns the length in dimension #3.
Definition at line 73 of file Array3D_Inline.cxx.
size_t Seldon::Array3D< 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 271 of file Array3D.cxx.
|
inline |
Returns the number of elements in the 3D array.
Returns the number of elements stored by the 3D array, i.e. the product of the lengths in the three dimensions.
Definition at line 86 of file Array3D_Inline.cxx.
void Seldon::Array3D< T, Allocator >::Nullify |
Clears the 3D array without releasing memory.
On exit, the 3D array is empty and the memory has not been released. It is useful for low level manipulations on a 3D arrat instance.
Definition at line 212 of file Array3D.cxx.
|
inline |
Access operator.
Returns the value of element (i, j, k).
i | index along dimension #1. |
j | index along dimension #2. |
k | index along dimension #3. |
Definition at line 151 of file Array3D_Inline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j, k).
i | index along dimension #1. |
j | index along dimension #2. |
k | index along dimension #3. |
Definition at line 172 of file Array3D_Inline.cxx.
|
inline |
Duplicates a 3D array (assignment operator).
A | 3D array to be copied. |
Definition at line 190 of file Array3D_Inline.cxx.
void Seldon::Array3D< T, Allocator >::Print |
Displays the array on the standard output.
Displays elements on the standard output, in text format.
Definition at line 342 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Read | ( | ifstream & | FileStream, |
bool | with_size = true |
||
) |
Reads the 3D array from an input stream.
Reads a 3D array in binary format from an input stream. The dimensions of the array are read (i,j, k three integers), and array elements are then read in the same order as it should be in memory
FileStream | input stream. |
Definition at line 472 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Read | ( | string | FileName, |
bool | with_size = true |
||
) |
Reads the 3D array from a file.
Reads a 3D array stored in binary format in a file. The dimensions of the array are read (i,j, k three integers), and array elements are then read in the same order as it should be in memory
FileName | input file name. |
Definition at line 444 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Reallocate | ( | int | i, |
int | j, | ||
int | k | ||
) |
Reallocates memory to resize the 3D array.
On exit, the array is a i x j x k 3D array.
i | length in dimension #1. |
j | length in dimension #2. |
k | length in dimension #3. |
Definition at line 127 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::SetData | ( | int | i, |
int | j, | ||
int | k, | ||
pointer | data | ||
) |
Changes the size of the array and sets its data array (low level method).
The 3D array is first cleared (memory is freed). The 3D array is then resized to a i x j x k, and the data array of the 3D array is set to 'data'. 'data' elements are not duplicated: the new data array of the 3D array is the 'data' array. It is useful to create a 3D array from pre-existing data.
i | length in dimension #1. |
j | length in dimension #2. |
k | length in dimension #3. |
data | new array storing elements. |
Definition at line 192 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Write | ( | ofstream & | FileStream, |
bool | with_size = true |
||
) | const |
Writes the 3D array to an output stream.
Writes the 3D 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 400 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Write | ( | string | FileName, |
bool | with_size = true |
||
) | const |
Writes the 3D array in a file.
Stores the 3D 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 373 of file Array3D.cxx.
void Seldon::Array3D< T, Allocator >::Zero |
Sets all elements to zero.
Definition at line 283 of file Array3D.cxx.