Templated one-dimensional, numerical array which looks like a conventional C array. Elements are accessed via the familiar A[i] 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] notation. This includes numerous textbooks, such as Numercial Recipes, and various public domain codes.
Member Typedef Documentation
template<class T>
typedef T TNT::Array1D<T>::value_type
Constructor & Destructor Documentation
template<class T>
TNT::Array1D<T>::Array1D<T> (
)
Null constructor. Creates a 0-length (NULL) array. (Reference count is also zero.)
template<class T>
TNT::Array1D<T>::Array1D<T> (
int n ) [explicit]
Create a new array (vector) of length n, WIHOUT initializing array elements. To create an initialized array of constants, see Array1D(n,value).
This version avoids the O(n) initialization overhead and is used just before manual assignment.
Parameters:
n
the dimension (length) of the new matrix.
template<class T>
TNT::Array1D<T>::Array1D<T> (
int n,
const T & a )
Create a new array of length n, initializing array elements to constant specified by argument. Most often used to create an array of zeros, as in A(n, 0.0).
Parameters:
n
the dimension (length) of the new matrix.
val
the constant value to set all elements of the new array to.
template<class T>
TNT::Array1D<T>::Array1D<T> (
int n,
T * a )
Create an n-length array, as a view of an existing one-dimensional C array. (Note that the storage for this pre-existing array will never be destroyed by the Aray1DRef class.)
Parameters:
n
the dimension (length) of the new matrix.
a
the one dimensional C array to use as data storage for the array.
template<class T>
TNT::Array1D<T>::Array1D<T> (
const Array1D<T> & A ) [inline]
Copy constructor. Array data is NOT copied, but shared. Thus, in Array1D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Array1D B(A.copy()), or B = A.copy(), instead.
template<class T>
TNT::Array1D<T>::~Array1D<T> (
)
Destructor: reclaims all memory possible associated with this array.
Member Function Documentation
template<class T>
Array1D<T> TNT::Array1D<T>::copy (
) const
Create a new of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Array1D B(A.copy()), to create a new array that does not share data.
template<class T>
int TNT::Array1D<T>::dim (
) const [inline]
Returns:
the dimension (number of elements) of the array. This is equivalent to dim1().
template<class T>
int TNT::Array1D<T>::dim1 (
) const [inline]
Returns:
the dimension (number of elements) of the array. This is equivalent to dim().
template<class T>
Array1D<T> & TNT::Array1D<T>::inject (
const Array1D<T> & A )
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 row and column dimensions).
This differs from B = A.copy() in that references to B before this assignment are also affected. That is, if we have
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 which 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 is made.
template<class T>
TNT::Array1D<T>::operator T * (
) [inline]
Automatic conversion to a one-dimensional pointer. Useful for integrating with numerical codes that utilize pointer interface interface. Thus, if a function declared as
Automatic conversion to a const one-dimensional pointer. Useful for integrating with numerical codes that utilize pointer interface interface. Thus, if a function declared as
A[i] indexes the ith element of A. The first element is A[0]. If TNT_BOUNDS_CHECK is defined, then the index is checked that it fall within the array bounds.
template<class T>
T & TNT::Array1D<T>::operator[] (
int i ) [inline]
A[i] indexes the ith element of A. The first element is A[0]. If TNT_BOUNDS_CHECK is defined, then the index is checked that it falls within the array bounds.
template<class T>
Array1D<T> & TNT::Array1D<T>::ref (
const Array1D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
The documentation for this class was generated from the following file:
Templated two-dimensional, numerical array which looks like a conventional C multiarray. Storage corresponds to C (row-major) ordering. Elements are accessed via A[i][j] 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] notation. This includes numerous textbooks, such as Numercial Recipes, and various public domain codes.
Member Typedef Documentation
template<class T>
typedef T TNT::Array2D<T>::value_type
Used to determined the data type of array entries. This is most commonly used when requiring scalar temporaries in templated algorithms that have TNT arrays as input. For example,
Create a null array. This is not the same as Array2D(0,0), which consumes some memory overhead.
template<class T>
TNT::Array2D<T>::Array2D<T> (
int m,
int n )
Copy constructor. Array data is NOT copied, but shared. Thus, in Array2D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Array2D B(A.copy()), or B = A.copy(), instead.
template<class T>
TNT::Array2D<T>::Array2D<T> (
int m,
int n,
T * a )
Create a new (m x n) array, WIHOUT initializing array elements. To create an initialized array of constants, see Array2D(m,n,value).
This version avoids the O(m*n) initialization overhead and is used just before manual assignment.
Parameters:
m
the first (row) dimension of the new matrix.
n
the second (column) dimension of the new matrix.
template<class T>
TNT::Array2D<T>::Array2D<T> (
int m,
int n,
const T & a )
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, 0.0).
Parameters:
m
the first (row) dimension of the new matrix.
n
the second (column) dimension of the new matrix.
val
the constant value to set all elements of the new array to.
template<class T>
TNT::Array2D<T>::Array2D<T> (
const Array2D<T> & A ) [inline]
Create a new (m x n) 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 Array2D class.
Parameters:
m
the first (row) dimension of the new matrix.
n
the second (column) dimension of the new matrix.
a
the one dimensional C array to use as data storage for the array.
template<class T>
TNT::Array2D<T>::~Array2D<T> (
)
Destructor. Reclaim resouces associated with this view of the array data. Note that elements are still intact if other array views of this data exist.
Member Function Documentation
template<class T>
Array2D<T> TNT::Array2D<T>::copy (
) const
Create a new copy of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Array2D B(A.copy()), to create a new array that does not share data.
template<class T>
int TNT::Array2D<T>::dim1 (
) const [inline]
Returns:
the size of the first dimension of the array, i.e. the number of rows.
template<class T>
int TNT::Array2D<T>::dim2 (
) const [inline]
Returns:
the size of the second dimension of the array, i.e. the number of columns.
template<class T>
Array2D<T> & TNT::Array2D<T>::inject (
const Array2D<T> & A )
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 row and column dimensions).
This differs from B = A.copy() in that references to B before this assignment are also affected. That is, if we have
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.
template<class T>
TNT::Array2D<T>::operator T ** (
) [inline]
Automatic conversion to a two-dimensional C array. Useful for integrating with numerical codes that utilize the A[i][j] interface. Thus, if a function declared as
Automatic conversion to a const two-dimensional C array. Useful for integrating with numerical codes that utilize the A[i][j] interface. Thus, if a function declared as
Used for A[i][j] indexing. The first [] operator returns a conventional pointer which can be dereferenced using the same [] notation.
If TNT_BOUNDS_CHECK macro is define, the left-most index (row index) is checked that it falls within the array bounds (via the assert() macro.) Note that bounds checking can occur in the row dimension, but the not column, since this is just a C pointer.
template<class T>
Array2D<T> & TNT::Array2D<T>::ref (
const Array2D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
The documentation for this class was generated from the following file:
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.
Member Typedef Documentation
template<class T>
typedef T TNT::Array3D<T>::value_type
Constructor & Destructor Documentation
template<class T>
TNT::Array3D< T >::Array3D<T> (
)
Create a null (0x0x0) array.
template<class T>
TNT::Array3D< T >::Array3D<T> (
int m,
int n,
int k )
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.
template<class T>
TNT::Array3D< T >::Array3D<T> (
int m,
int n,
int k,
T * a )
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.
template<class T>
TNT::Array3D< T >::Array3D<T> (
int m,
int n,
int k,
const T & val )
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.
template<class T>
TNT::Array3D< T >::Array3D<T> (
const Array3D<T> & A ) [inline]
Copy constructor. Array data is NOT copied, but shared. Thus, in Array3D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Array3D B(A.copy()), or B = A.copy(), instead.
template<class T>
TNT::Array3D<T>::~Array3D<T> (
)
Member Function Documentation
template<class T>
Array3D< T > TNT::Array3D< T >::copy (
) const
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.
template<class T>
int TNT::Array3D< T >::dim1 (
) const [inline]
Returns:
the size of the first dimension of the array.
template<class T>
int TNT::Array3D< T >::dim2 (
) const [inline]
Returns:
the size of the second dimension of the array.
template<class T>
int TNT::Array3D< T >::dim3 (
) const [inline]
Returns:
the size of the third (right-most) dimension of the array.
template<class T>
Array3D< T > & TNT::Array3D< T >::inject (
const Array3D<T> & A )
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.
template<class T>
Array3D< T > & TNT::Array3D< T >::operator= (
const Array3D<T> & A ) [inline]
B = A is shorthand notation for B.ref(A).
template<class T>
Array3D< T > & TNT::Array3D< T >::operator= (
const T & a ) [inline]
Assign all elemnts of A to a constant scalar.
template<class T>
const T *const * TNT::Array3D< T >::operator[] (
int i ) const [inline]
template<class T>
T ** TNT::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 TNT_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>
Array3D< T > & TNT::Array3D< T >::ref (
const Array3D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
The documentation for this class was generated from the following file:
Templated one-dimensional, numerical array which looks like a conventional Fortran array. This is useful when integrating with C/C++ codes translated from Fortran. Indexing is via the A(i) notation and A(1) is the first element.
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.
Member Typedef Documentation
template<class T>
typedef T TNT::Fortran_Array1D<T>::value_type
Constructor & Destructor Documentation
template<class T>
TNT::Fortran_Array1D< T >::Fortran_Array1D<T> (
)
Create a null (0-length) array.
template<class T>
TNT::Fortran_Array1D< T >::Fortran_Array1D<T> (
int n )
Create a new (n) array, WIHOUT initializing array elements. To create an initialized array of constants, see Fortran_Array1D(n, value).
This version avoids the O(n) initialization overhead and is used just before manual assignment.
Parameters:
m
the dimension of the new matrix.
template<class T>
TNT::Fortran_Array1D< T >::Fortran_Array1D<T> (
int n,
T * a )
Create a new n-length array, as a view of an existing one-dimensional C array. (Note that the storage for this pre-existing array will never be garbage collected by the Fortran_Array1D class.)
Parameters:
m
the first dimension of the new matrix.
n
the second dimension of the new matrix.
a
the one dimensional C array to use as data storage for the array.
template<class T>
TNT::Fortran_Array1D< T >::Fortran_Array1D<T> (
int n,
const T & val )
Create a new n-length array, initializing array elements to constant specified by argument. Most often used to create an array of zeros, as in A(n, 0.0).
Parameters:
m
the dimension of the new matrix.
val
the constant value to set all elements of the new array to.
template<class T>
TNT::Fortran_Array1D< T >::Fortran_Array1D<T> (
const Fortran_Array1D<T> & A ) [inline]
Copy constructor. Array data is NOT copied, but shared. Thus, in Fortran_Array1D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Fortran_Array1D B(A.copy()), or B = A.copy(), instead.
template<class T>
TNT::Fortran_Array1D<T>::~Fortran_Array1D<T> (
)
Member Function Documentation
template<class T>
Fortran_Array1D< T > TNT::Fortran_Array1D< T >::copy (
) const
Create a new of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Fortran_Array1D B(A.copy()), to create a new array that does not share data.
template<class T>
int TNT::Fortran_Array1D< T >::dim (
) const [inline]
Returns:
the size (dimension of) the array.
template<class T>
int TNT::Fortran_Array1D< T >::dim1 (
) const [inline]
Returns:
the size (dimension of) the array.
template<class T>
Fortran_Array1D< T > & TNT::Fortran_Array1D< T >::inject (
const Fortran_Array1D<T> & A )
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
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.
template<class T>
const T & TNT::Fortran_Array1D< T >::operator() (
int i ) const [inline]
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.)
template<class T>
T & TNT::Fortran_Array1D< T >::operator() (
int i ) [inline]
Elements are accessed via A(i) indexing.
If TNT_BOUNDS_CHECK macro is defined, the indices are checked that they falls within the array bounds (via the assert() macro.)
template<class T>
Fortran_Array1D< T > & TNT::Fortran_Array1D< T >::operator= (
const Fortran_Array1D<T> & A ) [inline]
B = A is shorthand notation for B.ref(A).
template<class T>
Fortran_Array1D< T > & TNT::Fortran_Array1D< T >::operator= (
const T & a ) [inline]
Assign all elemnts of A to a constant scalar.
template<class T>
Fortran_Array1D< T > & TNT::Fortran_Array1D< T >::ref (
const Fortran_Array1D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
template<class T>
int TNT::Fortran_Array1D<T>::ref_count (
) const [inline]
The documentation for this class was generated from the following file:
Templated two-dimensional, numerical array which looks like a conventional Fortran array. This is useful when integrating with C/C++ codes translated from Fortran. Storage corresponds to conventional Fortran ordering. That is, the left-most dimension varies fastest. Indexing is via the A(i,j) notation and A(1,1) is the first element.
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.
Member Typedef Documentation
template<class T>
typedef T TNT::Fortran_Array2D<T>::value_type
Constructor & Destructor Documentation
template<class T>
TNT::Fortran_Array2D< T >::Fortran_Array2D<T> (
)
Create a null (0x0x0) array.
template<class T>
TNT::Fortran_Array2D< T >::Fortran_Array2D<T> (
int m,
int n )
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.
Parameters:
m
the first dimension of the new matrix.
n
the second dimension of the new matrix.
template<class T>
TNT::Fortran_Array2D< T >::Fortran_Array2D<T> (
int m,
int n,
T * a )
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.
Parameters:
m
the first dimension of the new matrix.
n
the second dimension of the new matrix.
a
the one dimensional C array to use as data storage for the array.
template<class T>
TNT::Fortran_Array2D< T >::Fortran_Array2D<T> (
int m,
int n,
const T & val )
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).
Parameters:
m
the first dimension of the new matrix.
n
the second dimension of the new matrix.
val
the constant value to set all elements of the new array to.
template<class T>
TNT::Fortran_Array2D< T >::Fortran_Array2D<T> (
const Fortran_Array2D<T> & A ) [inline]
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.
template<class T>
TNT::Fortran_Array2D<T>::~Fortran_Array2D<T> (
)
Member Function Documentation
template<class T>
Fortran_Array2D< T > TNT::Fortran_Array2D< T >::copy (
) const
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.
template<class T>
int TNT::Fortran_Array2D< T >::dim1 (
) const [inline]
Returns:
the size of the first dimension of the array.
template<class T>
int TNT::Fortran_Array2D< T >::dim2 (
) const [inline]
Returns:
the size of the second dimension of the array.
template<class T>
Fortran_Array2D< T > & TNT::Fortran_Array2D< T >::inject (
const Fortran_Array2D<T> & A )
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
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.
template<class T>
const T & TNT::Fortran_Array2D< T >::operator() (
int i,
int j ) const [inline]
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.)
template<class T>
T & TNT::Fortran_Array2D< T >::operator() (
int i,
int j ) [inline]
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.)
template<class T>
Fortran_Array2D< T > & TNT::Fortran_Array2D< T >::operator= (
const Fortran_Array2D<T> & A ) [inline]
B = A is shorthand notation for B.ref(A).
template<class T>
Fortran_Array2D< T > & TNT::Fortran_Array2D< T >::operator= (
const T & a ) [inline]
Assign all elemnts of A to a constant scalar.
template<class T>
Fortran_Array2D< T > & TNT::Fortran_Array2D< T >::ref (
const Fortran_Array2D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
template<class T>
int TNT::Fortran_Array2D<T>::ref_count (
) const [inline]
The documentation for this class was generated from the following file:
Templated three-dimensional, numerical array which looks like a conventional Fortran array. This is useful when integrating with C/C++ codes translated from Fortran. Storage corresponds to conventional Fortran ordering. That is, the left-most dimension varies fastest. Indexing is via the A(i,j,k) notation and A(1,1,1) is the first element.
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.
Member Typedef Documentation
template<class T>
typedef T TNT::Fortran_Array3D<T>::value_type
Constructor & Destructor Documentation
template<class T>
TNT::Fortran_Array3D< T >::Fortran_Array3D<T> (
)
Create a null (0x0x0) array.
template<class T>
TNT::Fortran_Array3D< T >::Fortran_Array3D<T> (
int m,
int n,
int k )
Create a new (m x n x k) array, WIHOUT initializing array elements. To create an initialized array of constants, see Fortran_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.
template<class T>
TNT::Fortran_Array3D< T >::Fortran_Array3D<T> (
int m,
int n,
int k,
T * a )
Create a new (m x n x k) 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_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.
template<class T>
TNT::Fortran_Array3D< T >::Fortran_Array3D<T> (
int m,
int n,
int k,
const T & val )
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.
template<class T>
TNT::Fortran_Array3D< T >::Fortran_Array3D<T> (
const Fortran_Array3D<T> & A ) [inline]
Copy constructor. Array data is NOT copied, but shared. Thus, in Fortran_Array3D B(A), subsequent changes to A will be reflected in B. For an indepent copy of A, use Fortran_Array3D B(A.copy()), or B = A.copy(), instead.
template<class T>
TNT::Fortran_Array3D<T>::~Fortran_Array3D<T> (
)
Member Function Documentation
template<class T>
Fortran_Array3D< T > TNT::Fortran_Array3D< T >::copy (
) const
Create a new of existing matrix. Used in B = A.copy() or in the construction of B, e.g. Fortran_Array3D B(A.copy()), to create a new array that does not share data.
template<class T>
int TNT::Fortran_Array3D< T >::dim1 (
) const [inline]
Returns:
the size of the first dimension of the array.
template<class T>
int TNT::Fortran_Array3D< T >::dim2 (
) const [inline]
Returns:
the size of the second dimension of the array.
template<class T>
int TNT::Fortran_Array3D< T >::dim3 (
) const [inline]
Returns:
the size of the third (right-most) dimension of the array.
template<class T>
Fortran_Array3D< T > & TNT::Fortran_Array3D< T >::inject (
const Fortran_Array3D<T> & A )
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
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.
template<class T>
const T & TNT::Fortran_Array3D< T >::operator() (
int i,
int j,
int k ) const [inline]
Read-only version of A(i,j,k) indexing.
If TNT_BOUNDS_CHECK macro is defined, the indices are checked that they falls within the array bounds (via the assert() macro.)
template<class T>
T & TNT::Fortran_Array3D< T >::operator() (
int i,
int j,
int k ) [inline]
Elements are accessed via A(i,j,k) indexing.
If TNT_BOUNDS_CHECK macro is defined, the indices are checked that they falls within the array bounds (via the assert() macro.)
template<class T>
Fortran_Array3D< T > & TNT::Fortran_Array3D< T >::operator= (
const Fortran_Array3D<T> & A ) [inline]
B = A is shorthand notation for B.ref(A).
template<class T>
Fortran_Array3D< T > & TNT::Fortran_Array3D< T >::operator= (
const T & a ) [inline]
Assign all elemnts of A to a constant scalar.
template<class T>
Fortran_Array3D< T > & TNT::Fortran_Array3D< T >::ref (
const Fortran_Array3D<T> & A ) [inline]
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.
Returns:
The new referenced array: in B.ref(A), it returns B.
template<class T>
int TNT::Fortran_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:
[Deprecatred] Value-based Matrix class from pre-1.0 TNT version. Provides a row-oriented, 0-based [i][j] and 1-based (i,j) indexing. Kept here for backward compatiblity, but should use the newer TNT::Array2D classes instead.
template<class T> class TNT::Sparse_Matrix_CompRow
Read-only view of a sparse matrix in compressed-row storage format. Neither array elements (nonzeros) nor sparsity structure can be modified. If modifications are required, create a new view.
Index values begin at 0.
Storage requirements: An (m x n) matrix with nz nonzeros requires no more than ((T+I)*nz + M*I) bytes, where T is the size of data elements and I is the size of integers.
Performance Stopwatch used for benchmarking codes. Measures seconds elapsed as a floating point number. Resolution of the clock is determined by CLOCKS_PER_SEC in time.h. Typical use is given by
[Deprecatred] Value-based vector class from pre-1.0 TNT version. Kept here for backward compatiblity, but should use the newer TNT::Array1D classes instead.