#include <tnt_fortran_array2d.h>
Public Types | |
typedef T | value_type |
Public Methods | |
Fortran_Array2D () | |
Fortran_Array2D (int m, int n) | |
Fortran_Array2D (int m, int n, T *a) | |
Fortran_Array2D (int m, int n, const T &a) | |
Fortran_Array2D (const Fortran_Array2D &A) | |
Fortran_Array2D& | operator= (const T &a) |
Fortran_Array2D& | operator= (const Fortran_Array2D &A) |
Fortran_Array2D& | ref (const Fortran_Array2D &A) |
Fortran_Array2D | copy () const |
Fortran_Array2D& | inject (const Fortran_Array2D &A) |
T& | operator() (int i, int j) |
const T& | operator() (int i, int j) const |
int | dim1 () const |
int | dim2 () const |
int | ref_count () const |
~Fortran_Array2D () |
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.
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.
|
|
|
Create a null (0x0x0) array. |
|
Create a new (m x n) array, WIHOUT initializing array elements. To create an initialized array of constants, see Fortran_Array2D(m,n, value).
This version avoids the O(m*n) initialization overhead and is used just before manual assignment.
|
|
Create a new (m x n) array, as a view of an existing one-dimensional C array, with elements stored in Fortran order, i.e. right-most dimension varying fastest. (Often referred to as "column-major" ordering.) Note that the storage for this pre-existing array will never be garbage collected by the Fortran_Array2D class.
|
|
Create a new (m x n ) 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).
|
|
Copy constructor. Array data is NOT copied, but shared. Thus, in Fortran_Array2D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Fortran_Array2D B(A.copy()), or B = A.copy(), instead. |
|
|
|
Create a new of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Fortran_Array2D B(A.copy()), to create a new array that does not share data. |
|
|
|
|
|
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 Fortran_Array2D A(m,n); Fortran_Array2D C(m,n); Fortran_Array2D 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.
|
|
Read-only version of A(i,j) indexing. If TNT_BOUNDS_CHECK macro is defined, the indices are checked that they falls within the array bounds (via the assert() macro.) |
|
Elements are accessed via A(i,j) indexing. If TNT_BOUNDS_CHECK macro is defined, the indices are checked that they falls within the array bounds (via the assert() macro.) |
|
B = A is shorthand notation for B.ref(A). |
|
Assign all elemnts of A to a constant scalar. |
|
Create a reference (shallow assignment) to another existing array. In B.ref(A), B and A shared the same data and subsequent changes to the array elements of one will be reflected in the other. This is what operator= calls, and B=A and B.ref(A) are equivalent operations.
|
|
|