#include "CH_Timer.H"
#include "SPACE.H"
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <iostream>
Go to the source code of this file.
Functions | |
template<class T, unsigned int C0, unsigned int C1> | |
RectMDArray< T, C1 > | slice (RectMDArray< T, C0 > &a_original, const Interval &a_interval) |
Slice into a RectMDArray with vector valued (single index) data. Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int C0, unsigned int C1> | |
const RectMDArray< T, C1 > | slice (const RectMDArray< T, C0 > &a_original, const Interval &a_interval) |
Slice into a constant RectMDArray with vector valued (single index) data. Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int C, unsigned char D0, unsigned char D1> | |
RectMDArray< T, C, D1 > | slice (RectMDArray< T, C, D0 > &a_original, const Interval &a_interval) |
Slice into a RectMDArray with matrix valued (doubly indexed) data. Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int C, unsigned char D0, unsigned char D1> | |
const RectMDArray< T, C, D1 > | slice (const RectMDArray< T, C, D0 > &a_original, const Interval &a_interval) |
Slice into a constant RectMDArray with matrix valued (doubly indexed) data. Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int C, unsigned char D, unsigned char E0, unsigned char E1> | |
RectMDArray< T, C, D, E1 > | slice (RectMDArray< T, C, D, E0 > &a_original, const Interval &a_interval) |
Slice into a RectMDArray with three sets of components (three indices). Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int C, unsigned char D, unsigned char E0, unsigned char E1> | |
const RectMDArray< T, C, D, E1 > | slice (const RectMDArray< T, C, D, E0 > &a_original, const Interval &a_interval) |
Slice into a constant RectMDArray with three sets of components (three indices). Output is an alias to a subset of the input (shallow copy). | |
template<class T, unsigned int Cdest, unsigned int Csrc, typename Func> | |
void | forall (RectMDArray< T, Cdest > &a_dest, const RectMDArray< T, Csrc > &a_src, const Func &F, const Box &a_box) |
Pointwise operator. Applies F to the single indexed RectMDArray a_src in the domain a_box and stores the result in the singly indexed RectMDArray a_dest. | |
template<class T, unsigned int Cdest, unsigned int Csrc, typename Func> | |
T | forall_vect_max (RectMDArray< T, Cdest > &a_dest, const RectMDArray< T, Csrc > &a_src, const Func &F, const Box &a_box) |
template<class T, unsigned int Cdest, unsigned int Csrc, typename Func> | |
T | forall_vect (RectMDArray< T, Cdest > &a_dest, const RectMDArray< T, Csrc > &a_src, const Func &F, const Box &a_box) |
template<class T, unsigned int C, unsigned char D, unsigned char E, typename Func> | |
void | forall (RectMDArray< T, C > &a_dest, const RectMDArray< T, C, D, E > &a_src, const Func &F, const Box &a_box) |
Pointwise operator. Applies F to the triple indexed RectMDArray a_src in the domain a_box and stores the result in the singly indexed RectMDArray a_dest. | |
template<class T, unsigned int Cdest, unsigned int Csrc, unsigned char D, typename Func> | |
void | forall (RectMDArray< T, Cdest, D > &a_dest, const RectMDArray< T, Csrc > &a_src, const Func &F, const Box &a_box) |
Pointwise operator. Applies F to the singly indexed RectMDArray a_src in the domain a_box and stores the result in the doubly indexed RectMDArray a_dest. | |
template<class T, unsigned int C, unsigned char D, typename Func> | |
void | forall (RectMDArray< T > &a_dest, const RectMDArray< T, C, D > &a_src, const Func &F, const Box &a_box) |
Pointwise operator. Applies F to the doubly indexed RectMDArray a_src in the domain a_box and stores the result in the scalar RectMDArray a_dest. | |
template<class T, typename Func> | |
void | forall (RectMDArray< T > &a_dest, const Func &F, const Box &a_box) |
In place pointwise operator. Applies F to the (scalar) RectMDArray a_dest for every point in a_box. | |
template<class T, unsigned int C, typename Func> | |
void | forall_CToF (RectMDArray< T, C > &a_destFine, const RectMDArray< T, C > &a_srcCoar, const Func &F, const Box &a_boxCoar, const int &a_refRat) |
template<class T, unsigned int C, typename Func> | |
void | forall_stride (RectMDArray< T, C > &a_dest, const RectMDArray< T, C > &a_src, const Func &F, const Box &a_box, const int &a_stride, const int &a_start) |
but here we add striding mojo | |
template<class T, typename Func> | |
T | forall_max_scal (RectMDArray< T > &a_dest, const RectMDArray< T > &a_src, const Func &F, const Box &a_box) |
template<class T, typename Func> | |
void | forall_scal (RectMDArray< T > &a_dest, const RectMDArray< T > &a_src, const Func &F, const Box &a_box) |
template<class T, unsigned int Cdest, unsigned int Csrc, typename Func> | |
T | forall_max (RectMDArray< T, Cdest > &a_dest, const RectMDArray< T, Csrc > &a_src, const Func &F, const Box &a_box) |
pair pointwise operator with max reduction | |
template<class T> | |
T & | abs_max (RectMDArray< T > &a_src, const Box &a_box) |
Returns the value of a_src in a_box with the largest absolute value. | |
template<class T> | |
tuple< T &, Point > | abs_argmax (const RectMDArray< T > &a_src, const Box &a_box) |
Returns a tuple containing the value of a_src in a_box with the largest absolute value and the Point at which this value is attained. |
RectMDArray<T,C1> slice | ( | RectMDArray< T, C0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a RectMDArray with vector valued (single index) data. Output is an alias to a subset of the input (shallow copy).
Note that only the lower bound of the Interval input is used. The upper bound of a_interval can be any value at all.
To obtain generate an alias to the first component of a vector-valued array, the lower bound of a_interval must be 0 and the output array must have 1 component (see Example 1).
To get the second component, the lower bound of a_interval must be 1 and the output array must have 1 component (see Example 2).
To obtain the first and second components of a 3 component array, the lower bound of a_interval must be 0 and the output data must have 2 components (see Example 3).
Example Usage: Point p1 = getZeros(); Point p2 = getOnes(); Box b = Box(p1,p2); RectMDArray<int,3> source = RectMDArray<int,3>(b);
Example 1: Create alias to first component of source: Interval I1 = Interval(0,1); RectMDArray<int,1> slice1<int,3,1>(source,I1)
Example 2: Create alias to the second component of source: Interval I2 = Interval(1,2); RectMDArray<int,1> slice1<int,3,1>(source,I2)
Example 3: Create alias to the second and third components of source: Interval I23 = Interval(1,3); RectMDArray<int,2> slice1<int,3,2>(source,I23)
T | A Class. Type of data stored by input and output RectMDArrays | |
C0 | Number of components in the input RectMDArray | |
C1 | Number of components in the output RectMDArray |
a_original | The source RectMDArray with data of type T and C0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
const RectMDArray<T,C1> slice | ( | const RectMDArray< T, C0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a constant RectMDArray with vector valued (single index) data. Output is an alias to a subset of the input (shallow copy).
See documentation for the non-constant version of slice for notes and example usage.
T | A Class. Type of data stored by input and output RectMDArrays | |
C0 | Number of components in the input RectMDArray | |
C1 | Number of components in the output RectMDArray |
a_original | The source constant RectMDArray with data of type T and C0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
RectMDArray<T,C,D1> slice | ( | RectMDArray< T, C, D0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a RectMDArray with matrix valued (doubly indexed) data. Output is an alias to a subset of the input (shallow copy).
This version of slice produces alias to a C x D1 dimensional subset of the C x D0 dimensional input RectMDArray. See documentation for the vector valued version of slice() for additional example usage and notes.
T | A Class. Type of data stored by input and output RectMDArrays | |
C | Number of the first set of components of both the input and output RectMDArrays | |
D0 | Number of the second set of components of the input RectMDArray | |
D1 | Number of the second set of components of the output RectMDArray |
a_original | The source constant RectMDArray with data of type T and C x D0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
const RectMDArray<T,C,D1> slice | ( | const RectMDArray< T, C, D0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a constant RectMDArray with matrix valued (doubly indexed) data. Output is an alias to a subset of the input (shallow copy).
See the non-constant input version for notes on usage. See documentation for the vector valued version of slice() for additional example usage and notes.
T | A Class. Type of data stored by input and output RectMDArrays | |
C | Number of the first set of components of both the input and output RectMDArrays | |
D0 | Number of the second set of components of the input RectMDArray | |
D1 | Number of the second set of components of the output RectMDArray |
a_original | The source constant RectMDArray with data of type T and C x D0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
RectMDArray<T,C,D,E1> slice | ( | RectMDArray< T, C, D, E0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a RectMDArray with three sets of components (three indices). Output is an alias to a subset of the input (shallow copy).
This version of slice produces alias to a C x D x E1 dimensional subset of the C x D x E0 dimensional input RectMDArray. See documentation for the vector valued version of slice() for additional example usage and notes.
T | A Class. Type of data stored by input and output RectMDArrays | |
C | Number of the first set of components of both the input and output RectMDArrays | |
D | Number of the second set of components of both the input and output RectMDArrays | |
E0 | Number of the third set of components of the input RectMDArray | |
E1 | Number of the third set of components of the output RectMDArray |
a_original | The source constant RectMDArray with data of type T and C x D x E0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
const RectMDArray<T,C,D,E1> slice | ( | const RectMDArray< T, C, D, E0 > & | a_original, | |
const Interval & | a_interval | |||
) | [inline] |
Slice into a constant RectMDArray with three sets of components (three indices). Output is an alias to a subset of the input (shallow copy).
See the non-constant input version for notes on usage. See documentation for the vector valued version of slice() for additional example usage and notes.
T | A Class. Type of data stored by input and output RectMDArrays | |
C | Number of the first set of components of both the input and output RectMDArrays | |
D | Number of the second set of components of both the input and output RectMDArrays | |
E0 | Number of the third set of components of the input RectMDArray | |
E1 | Number of the third set of components of the output RectMDArray |
a_original | The source constant RectMDArray with data of type T and C x D x E0 components | |
a_interval | An Interval object. The lower bound of a_interval determines which components of a_original will be be sliced into the output. |
References RectMDArray< T, C, D, E >::getBox(), Interval::low, RectMDArray< T, C, D, E >::m_sliceData(), RectMDArray< T, C, D, E >::m_slicePtr(), and Box::sizeOf().
void forall | ( | RectMDArray< T, Cdest > & | a_dest, | |
const RectMDArray< T, Csrc > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
Pointwise operator. Applies F to the single indexed RectMDArray a_src in the domain a_box and stores the result in the singly indexed RectMDArray a_dest.
T | Data type of the RectMDArray arguments | |
Cdest | Number of components in the destination RectMDArray | |
Csrc | Number of components in the source RectMDArray | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with a Tensor and a CTensor as arguments which acts on a_src. F can be any externally defined function that bears the following signature: void F(Tensor<T,Cdest>& a_OUT, CTensor<T, Csrc>& a_IN); | |
a_box | A Box which defines the domain in point space of the operation. |
void PermuteF(Tensor<double,3>& a_OUT, CTensor<double, 3>& a_IN) { //a_IN(i) is the ith component of the vector data at some point, and similarly with a_OUT(i). a_OUT(0) = a_IN(1); a_OUT(1) = a_IN(2); a_OUT(2) = a_IN(0); }
References Box::getLowCorner(), Box::increment(), and Box::notDone().
T forall_vect_max | ( | RectMDArray< T, Cdest > & | a_dest, | |
const RectMDArray< T, Csrc > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
References Box::getLowCorner(), Box::increment(), and Box::notDone().
T forall_vect | ( | RectMDArray< T, Cdest > & | a_dest, | |
const RectMDArray< T, Csrc > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
References Box::getLowCorner(), Box::increment(), and Box::notDone().
void forall | ( | RectMDArray< T, C > & | a_dest, | |
const RectMDArray< T, C, D, E > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
Pointwise operator. Applies F to the triple indexed RectMDArray a_src in the domain a_box and stores the result in the singly indexed RectMDArray a_dest.
In this case, F has a return value. The maximum of this return value over a_box will be returned by this function.
T | Data type of the RectMDArray arguments | |
Cdest | Number of components in the destination RectMDArray | |
Csrc | Number of components in the source RectMDArray | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with two T-type arrays of size Cdest and Csrc respectively. F can be any externally defined function that bears the following signature: // void F(T destv[Cdest], T srcv[Csrc]); // | |
a_box | A Box which defines the domain in point space of the operation. Identical to the forall() function of the same signature except that this version is not implemented with Tensors. |
T | Data type of the RectMDArray arguments | |
Cdest | Number of components in the destination RectMDArray | |
Csrc | Number of components in the source RectMDArray | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with two T-type arrays of size Cdest and Csrc respectively. F can be any externally defined function that bears the following signature: // void F(T destv[Cdest], T srcv[Csrc]); // | |
a_box | A Box which defines the domain in point space of the operation. Alteration of forall() that operates on a triply indexed RectMDArray. Implemented using Tensors. |
T | Data type of the RectMDArray arguments | |
C | Number of components in the first index of BOTH the input and output RectMDArrays. | |
D | Number of components in the second index of the input RectMDArray. | |
E | Number of components in the third index of the input RectMDArray. | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with a Tensor and a CTensor as arguments which acts on a_src. F can be any externally defined function that bears the following signature: void F(Tensor<T,C>& a_OUT, CTensor<T,C,D,E>& a_IN); | |
a_box | A Box which defines the domain in point space of the operation. |
References Box::getLowCorner(), Box::increment(), and Box::notDone().
void forall | ( | RectMDArray< T, Cdest, D > & | a_dest, | |
const RectMDArray< T, Csrc > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
Pointwise operator. Applies F to the singly indexed RectMDArray a_src in the domain a_box and stores the result in the doubly indexed RectMDArray a_dest.
Alteration of forall() that operates on a singly indexed RectMDArray and produces a doubly indexed RectMDArray. Implemented using Tensors.
An example of an F that would do this is the calculation of the velocity gradient (a second order tensor) from the velocity (a first order tensor).
T | Data type of the RectMDArray arguments | |
Cdest | Number of components in the first index of the output RectMDArray | |
Csrc | Number of components in the first index of the input RectMDArray | |
D | Number of components in the second index of the output RectMDArray. | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with a Tensor and a CTensor as arguments which acts on a_src. F can be any externally defined function that bears the following signature: void F(Tensor<T,C>& a_OUT, CTensor<T,C,D,E>& a_IN); | |
a_box | A Box which defines the domain in point space of the operation. |
References Box::getLowCorner(), Box::increment(), and Box::notDone().
void forall | ( | RectMDArray< T > & | a_dest, | |
const RectMDArray< T, C, D > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
Pointwise operator. Applies F to the doubly indexed RectMDArray a_src in the domain a_box and stores the result in the scalar RectMDArray a_dest.
Alteration of forall() that operates on a doubly indexed RectMDArray and produces a scalar RectMDArray. Implemented using Tensors.
An example of an F that would do this is the calculation of the pointwise trace of a 2D matrix valued array.
T | Data type of the RectMDArray arguments | |
C | Number of components in the first index of the input RectMDArray | |
D | Number of components in the second index of the input RectMDArray. | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
a_src | Source RectMDArray. This is the array that F acts on. | |
F | A pointwise function with a scalar T and a CTensor as arguments which acts on a_src. F can be any externally defined function that bears the following signature: void F(T& a_OUT, CTensor<T,C,D>& a_IN); | |
a_box | A Box which defines the domain in point space of the operation. |
References RectMDArray< T, C, D, E >::get(), Box::getLowCorner(), Box::increment(), and Box::notDone().
void forall | ( | RectMDArray< T > & | a_dest, | |
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
In place pointwise operator. Applies F to the (scalar) RectMDArray a_dest for every point in a_box.
Alteration of forall() that applies F in place on a scalar RectMDArray. No Tensors are necessary for this version.
T | Data type of the RectMDArray arguments | |
Func | Function datatype. Usually this parameter will be filled with decltype(F). |
a_dest | Destination RectMDArray. This is where the result of F(a_src) is stored. | |
F | A pointwise function with a Tensor and a CTensor as arguments which acts on a_src. F can be any externally defined function that bears the following signature: void F(T& a_IN);
| |
a_box | A Box which defines the domain in point space of the operation. |
References RectMDArray< T, C, D, E >::get(), Box::getLowCorner(), Box::increment(), and Box::notDone().
void forall_CToF | ( | RectMDArray< T, C > & | a_destFine, | |
const RectMDArray< T, C > & | a_srcCoar, | |||
const Func & | F, | |||
const Box & | a_boxCoar, | |||
const int & | a_refRat | |||
) | [inline] |
void forall_stride | ( | RectMDArray< T, C > & | a_dest, | |
const RectMDArray< T, C > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box, | |||
const int & | a_stride, | |||
const int & | a_start | |||
) | [inline] |
but here we add striding mojo
References RectMDArray< T, C, D, E >::get(), RectMDArray< T, C, D, E >::getConst(), Box::getLowCorner(), getUnitv(), Box::increment(), and Box::notDone().
T forall_max_scal | ( | RectMDArray< T > & | a_dest, | |
const RectMDArray< T > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
void forall_scal | ( | RectMDArray< T > & | a_dest, | |
const RectMDArray< T > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
T forall_max | ( | RectMDArray< T, Cdest > & | a_dest, | |
const RectMDArray< T, Csrc > & | a_src, | |||
const Func & | F, | |||
const Box & | a_box | |||
) | [inline] |
pair pointwise operator with max reduction
References Box::getLowCorner(), Box::increment(), and Box::notDone().
T& abs_max | ( | RectMDArray< T > & | a_src, | |
const Box & | a_box | |||
) | [inline] |
Returns the value of a_src in a_box with the largest absolute value.
T | Data type of a_src |
a_src | Input data | |
a_box | Domain |
References Box::getLowCorner(), Box::increment(), and Box::notDone().
tuple<T&, Point> abs_argmax | ( | const RectMDArray< T > & | a_src, | |
const Box & | a_box | |||
) | [inline] |
Returns a tuple containing the value of a_src in a_box with the largest absolute value and the Point at which this value is attained.
T | Data type of a_src |
a_src | Input data | |
a_box | Domain |
References Box::getLowCorner(), Box::increment(), and Box::notDone().