Loading...
Searching...
No Matches
casacore::ArraySampledFunctional< T > Class Template Reference
scimath package (libcasa_scimath) » Functionals_module

More...

`#include <ArraySampledFunctional.h>`

## Public Member Functions

| ArraySampledFunctional ()
| These constructors copy the array that is passed to them.
| ArraySampledFunctional (const T &data)
| ArraySampledFunctional (ArraySampledFunctional< T > &other)
| The standard copy constructor and assignment operator.
ArraySampledFunctional< T > & | operator= (ArraySampledFunctional< T > &other)
virtual T | operator() (const uInt &index) const
| Define the functions for the SampledFunction interface.
virtual uInt | nelements () const
| Return the total size of the data set.
virtual | ~ArraySampledFunctional ()
const T | operator() (const uInt &index)
| An alternate version of the sampling function which is more effecient because it does not need to create as many temporary objects or copy the Array data.
Public Member Functions inherited from casacore::SampledFunctional< T >
virtual | ~SampledFunctional ()
| The virtual destructor does nothing.
Public Member Functions inherited from casacore::Functional< uInt, T >
virtual | ~Functional ()
| Destructor.

## Private Attributes

T | theRefData
IPosition | theEnd
uInt | theLastAxis
uInt | theNelements

## Detailed Description

template<class T>
class casacore::ArraySampledFunctional< T >

Index into an array using the longest axis

### Intended use:

Public interface

### Review Status

Reviewed By:
  wyoung
Date Reviewed:
  1996/10/19
Test programs:
  tSampledFunctional

### Prerequisite

- SampledFunctional
- Array

### Etymology

A SampledFunctional is an interface that allows random access to a fixed size data set. An ArraySampledFunctional allows you to access slices of an an Array<T> object.

### Synopsis

An ArraySampledFunctional allows an Array<T> object to be sliced up with each sample being one slice of the original Array. The slices are always the same size and the indexing is always done along the last non-degenerate dimension. For example a(4,3,20,1) is interpreted as a SampledFunctional with 20 elements, each one being a 4 by 3 matrix.

The Array that is passed to the constructor is copied by this class but because Arrays themselves use reference symantics, the actual data is not copied but referenced. This means that modifying the data in the original array will correspondingly modify the data accessed by this class.

Similarly the Array that is returned for each Slice is a reference to the actual data so that modifying this array really modifies the original data. This is not recommended as the operator() function is not supposed to be used to get a modifiable portion of the data.

### Example

Constructing and using ArraySampledFunctionals

Array<Float> a(IPosition(4,4,3,20,1)); // Create an array
... Fill the array any way you like..\.
ArraySampledFunctional<Array<Float> >fa(a);
for(uInt i = 0; i < 20; i++)
cout << "f(" << i << ") = " << fa(i) << endl;
// Each 'slice' is a 4 by 3 Matrix
casacore::ArraySampledFunctional::ArraySampledFunctional
ArraySampledFunctional()
These constructors copy the array that is passed to them.
casacore::Array
Definition Array.h:155
casacore::IPosition
Definition IPosition.h:117
casacore::array
TYPE * array
the allocated array
Definition hdu.h:491
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::any
LatticeExprNode any(const LatticeExprNode &expr)
Functions operating on a logical expression resulting in a scalar; Functions "any" (are any pixels "T...

### Motivation

I needed a SampledFunctional which could return Arrays of arbitrary (but fixed) size for each index. This could be done using a ScalarSampledFunctional<Array<T> > but is ineffecient as each element is stored as a separate Array. This class is a more efficient way to solve this problem.

### Template Type Argument Requirements (T)

- The template type MUST be an Array of some arbitrary type. This is because this class will return a slice of this Array. The Array template type cannot be subsumed into the class definition because the definition of the inherited operator() function means that the return type must be the template type

### Thrown Exceptions

- Exceptions are not thrown directly by this class.

### To Do

- Nothing I can think of.

Definition at line 109 of file ArraySampledFunctional.h.

## Constructor & Destructor Documentation

## ArraySampledFunctional() [1/3]

template<class T>

casacore::ArraySampledFunctional< T >::ArraySampledFunctional | ( |  | ) |

These constructors copy the array that is passed to them.

But because arrays use reference symantics the data is not copied. The default constructor is basically useless, as there is no way to add the data once the class has been constructed.

Referenced by ArraySampledFunctional(), and operator=().

## ArraySampledFunctional() [2/3]

template<class T>

casacore::ArraySampledFunctional< T >::ArraySampledFunctional | ( | const T & | data | ) |

## ArraySampledFunctional() [3/3]

template<class T>

casacore::ArraySampledFunctional< T >::ArraySampledFunctional | ( | ArraySampledFunctional< T > & | other | ) |

The standard copy constructor and assignment operator.

References ArraySampledFunctional().

## ~ArraySampledFunctional()

template<class T>

virtual casacore::ArraySampledFunctional< T >::~ArraySampledFunctional | ( |  | ) |

virtual

## Member Function Documentation

## nelements()

template<class T>

virtual uInt casacore::ArraySampledFunctional< T >::nelements | ( |  | ) | const

virtual

Return the total size of the data set.

Implements casacore::SampledFunctional< T >.

## operator()() [1/2]

template<class T>

const T casacore::ArraySampledFunctional< T >::operator() | ( | const uInt & | index | ) |

An alternate version of the sampling function which is more effecient because it does not need to create as many temporary objects or copy the Array data.

## operator()() [2/2]

template<class T>

virtual T casacore::ArraySampledFunctional< T >::operator() | ( | const uInt & | index | ) | const

virtual

Define the functions for the SampledFunction interface.

Implements casacore::SampledFunctional< T >.

## operator=()

template<class T>

ArraySampledFunctional< T > & casacore::ArraySampledFunctional< T >::operator= | ( | ArraySampledFunctional< T > & | other | ) |

References ArraySampledFunctional().

## Member Data Documentation

## theEnd

template<class T>

IPosition casacore::ArraySampledFunctional< T >::theEnd

private

Definition at line 144 of file ArraySampledFunctional.h.

## theLastAxis

template<class T>

uInt casacore::ArraySampledFunctional< T >::theLastAxis

private

Definition at line 145 of file ArraySampledFunctional.h.

## theNelements

template<class T>

uInt casacore::ArraySampledFunctional< T >::theNelements

private

Definition at line 146 of file ArraySampledFunctional.h.

## theRefData

template<class T>

T casacore::ArraySampledFunctional< T >::theRefData

private

Definition at line 143 of file ArraySampledFunctional.h.

The documentation for this class was generated from the following file:

- scimath/Functionals/ArraySampledFunctional.h