SPUC::Array3D< T > Class Template Reference
Templated three-dimensional, numerical array which looks like a conventional C multiarray.
More...
#include <array3d.h>
Collaboration diagram for SPUC::Array3D< T >:
[legend]List of all members.
Detailed Description
template<class T>
class SPUC::Array3D< T >
Templated three-dimensional, numerical array which looks like a conventional C multiarray.
Tempplated three-dimensional, numerical array which looks like a conventional C multiarray. Storage corresponds to conventional C ordering. That is the right-most dimension has contiguous elements. Indexing is via the A[i][j][k] notation.
Array assignment is by reference (i.e. shallow assignment). That is, B=A implies that the A and B point to the same array, so modifications to the elements of A will be reflected in B. If an independent copy is required, then B = A.copy() can be used. Note that this facilitates returning arrays from functions without relying on compiler optimizations to eliminate extensive data copying.
The indexing and layout of this array object makes it compatible with C and C++ algorithms that utilize the familiar C[i][j][k] notation. This includes numerous textbooks, such as Numercial Recipes, and various public domain codes.
This class employs its own garbage collection via the use of reference counts. That is, whenever an internal array storage no longer has any references to it, it is destoryed.
Member Typedef Documentation
Constructor & Destructor Documentation
|
Create a null (0x0x0) array. |
|
Create a new (m x n x k) array, WIHOUT initializing array elements. To create an initialized array of constants, see Array3D(m,n,k, value).
This version avoids the O(m*n*k) initialization overhead and is used just before manual assignment.
- Parameters:
-
| m | the first dimension of the new matrix. |
| n | the second dimension of the new matrix. |
| k | the third dimension of the new matrix. |
|
|
Create a new (m x n x k) array, as a view of an existing one-dimensional array stored in C order, i.e. right-most dimension varying fastest. (Often referred to as "row-major" ordering.) Note that the storage for this pre-existing array will never be garbage collected by the Array3D class.
- Parameters:
-
| m | the first dimension of the new matrix. |
| n | the second dimension of the new matrix. |
| k | the third dimension of the new matrix. |
| a | the one dimensional C array to use as data storage for the array. |
|
|
Create a new (m x n x k) array, initializing array elements to constant specified by argument. Most often used to create an array of zeros, as in A(m, n, k, 0.0).
- Parameters:
-
| m | the first dimension of the new matrix. |
| n | the second dimension of the new matrix. |
| k | the third dimension of the new matrix. |
| val | the constant value to set all elements of the new array to. |
|
Member Function Documentation
|
Create a new of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Array3D B(A.copy()), to create a new array that does not share data.
Here is the call graph for this function:
|
template<class T> |
int SPUC::Array3D< T >::dim1 |
( |
|
) |
const [inline] |
|
|
- Returns:
- the size of the first dimension of the array.
|
template<class T> |
int SPUC::Array3D< T >::dim2 |
( |
|
) |
const [inline] |
|
|
- Returns:
- the size of the second dimension of the array.
|
template<class T> |
int SPUC::Array3D< T >::dim3 |
( |
|
) |
const [inline] |
|
|
- Returns:
- the size of the third (right-most) dimension of the array.
|
|
Copy the elements to from one array to another, in place. That is B.inject(A), both A and B must conform (i.e. have identical dimensions).
This differs from B = A.copy() in that references to B before this assignment are also affected. That is, if we have
Array3D A(m,n,k);
Array3D C(m,n,k);
Array3D B(C); // elements of B and C are shared.
then B.inject(A) affects both and C, while B=A.copy() creates a new array B which shares no data with C or A.
- Parameters:
-
| A | the array from elements will be copied |
- Returns:
- an instance of the modifed array. That is, in B.inject(A), it returns B. If A and B are not conformat, no modifications to B are made.
Here is the call graph for this function:
|
|
Assign all elemnts of A to a constant scalar. |
template<class T> |
const T *const * SPUC::Array3D< T >::operator[] |
( |
int |
i |
) |
const [inline] |
|
template<class T> |
T ** SPUC::Array3D< T >::operator[] |
( |
int |
i |
) |
[inline] |
|
|
Used for A[i][j][k] indexing. The first [] operator returns a conventional pointer which can be dereferenced using the same [] notation.
If SPUC_BOUNDS_CHECK macro is define, the left-most index is checked that it falls within the array bounds (via the assert() macro.) |
template<class T> |
int SPUC::Array3D< T >::ref_count |
( |
|
) |
const [inline] |
|
|
- Returns:
- the number of arrays that share the same storage area as this one. (Must be at least one.)
|
The documentation for this class was generated from the following file:
Generated on Fri Sep 16 11:07:22 2005 for spuc by
1.4.4