interface. The principle
advantage of this is that it unifies the different indexing operators
(ie. [] for Blocks and () for Vectors). The disadvantage is that it hides
just about all the other functionality of Vectors and Blocks. If all you
are interested in is random access to various elements of these objects
then this class is a suitable abstraction.
Reference semantics are used (ie. the class does not make a copy of the
data but refers to the original data) whenever possible. It is not
possible to use reference semantics (so a physical copy of the data is
made), in the following cases:
- When constructing the class from a Block
- When constructing the class from a const Vector
Reference semantics are always used for the copy constructor and
assignment operators when the ScalarSampledFunctional is
non-const. Otherwise copy semantics are used.
When reference semantics are used you need to be aware that modifying the
contents of the original Vector will modify the data used by this class.
This class is always more efficient if reference semantics are used, so
avoid using const arguments unless you really need to.
Example
Constructing and using ScalarSampledFunctional's
Block<Float> b(10); // Create a block of ten elements
// ... Fill the block any way you like ...
ScalarSampledFunctional<Float> fb(b);
for(uInt i = 0; i < 10; i++)
cout << "f(" << i << ") = " << fb(i) << endl;
Motivation
The SampledFunctional is a useful interface. But it needs some concrete
classes to back it up. This is the first one that was written.
Template Type Argument Requirements (Range)
Very few assumptions are made on the templating type. So this class
should work for a wide variety of templates types.
Thrown Exceptions
Exceptions are not thrown directly by this class.
To Do
Member Description
See the description above to determine whether a copy or a reference is
made to the original data.
ScalarSampledFunctional(ScalarSampledFunctional<T> & other)
ScalarSampledFunctional(const ScalarSampledFunctional<T> & other)
ScalarSampledFunctional<T> & operator=(ScalarSampledFunctional<T> &other)
ScalarSampledFunctional<T> & operator=(const ScalarSampledFunctional<T> &other)
The standard copy constructor and assignment operator. These functions
use reference semantics when the ScalarSampledFunctional is
non-const, and copy semantics otherwise.
Define the functions for the SampledFunctional interface