casacore
scimath
Functionals
SampledFunctional.h
Go to the documentation of this file.
1
//# SampledFunctional.h:
2
//# Copyright (C) 1996,1999
3
//# Associated Universities, Inc. Washington DC, USA.
4
//#
5
//# This library is free software; you can redistribute it and/or modify it
6
//# under the terms of the GNU Library General Public License as published by
7
//# the Free Software Foundation; either version 2 of the License, or (at your
8
//# option) any later version.
9
//#
10
//# This library is distributed in the hope that it will be useful, but WITHOUT
11
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13
//# License for more details.
14
//#
15
//# You should have received a copy of the GNU Library General Public License
16
//# along with this library; if not, write to the Free Software Foundation,
17
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18
//#
19
//# Correspondence concerning AIPS++ should be addressed as follows:
20
//# Internet email: aips2-request@nrao.edu.
21
//# Postal address: AIPS++ Project Office
22
//# National Radio Astronomy Observatory
23
//# 520 Edgemont Road
24
//# Charlottesville, VA 22903-2475 USA
25
//#
26
//# $Id$
27
28
#ifndef SCIMATH_SAMPLEDFUNCTIONAL_H
29
#define SCIMATH_SAMPLEDFUNCTIONAL_H
30
31
#include <casacore/casa/aips.h>
32
#include <casacore/casa/BasicMath/Functional.h>
33
34
namespace
casacore
{
//# NAMESPACE CASACORE - BEGIN
35
36
// <summary> A base class for indexing into arbitrary data types </summary>
37
38
// <use visibility=export>
39
40
// <reviewed reviewer="wyoung" date="1996/10/10" tests="tSampledFunctional.cc">
41
42
// <prerequisite>
43
// <li> Functional
44
// </prerequisite>
45
46
// <etymology>
47
// A Functional is simply a mapping from a Domain type to a Range
48
// type. Experimental data is usually sampled, and is can be represented as
49
// a mapping from the unsigned integers to an arbitrary Domain.
50
// </etymology>
51
52
// <synopsis>
53
// This abstract class defines an interface for functions that map from the
54
// unsigned integers to an arbitrary type. It defines two functions: the
55
// operator() function which it inherits from the Functional class, and the
56
// nelements function which is necessary to know how many data elements.
57
//
58
// This class is useful for freeing the writer of other classes from having
59
// to know how how a linear data set is stored or represented. For example,
60
// four floating point numbers will probably be stored as a Vector<Float>,
61
// and kept in memory for fast access. But 400 million floating point
62
// numbers cannot usually be kept in memory, and may be stored on disk as a
63
// Table. By using a SampledFunctional writers of other classes
64
// (Interpolate1D is an example), can ignore these details if all they are
65
// interested in is random access to individual elements of the data.
66
// </synopsis>
67
68
// <example>
69
// Because this is an abstract class the example will be inside a function
70
// <srcblock>
71
// T sum(SampledFunctional<T> data)
72
// {
73
// T result = 0;
74
// for (uInt i = 0; i < data.nelements(); i++)
75
// result += data(i);
76
// return result;
77
// }
78
// </srcblock>
79
// </example>
80
81
// <motivation>
82
// If all you need to do is random access indexing into arbitrary data sets
83
// this class provides a suitable abstraction of that functionality.
84
// </motivation>
85
86
// <templating arg=Range>
87
// <li> Templating restrictions will depend on the actual derived class that is
88
// used.
89
// </templating>
90
91
// <thrown>
92
// <li> Exceptions will depend on derived classes and the templating
93
// arguements. This abstract class only defines an interface and does not
94
// throw any exceptions.
95
// </thrown>
96
97
// <todo asof="1996/10/19">
98
// <li> I cannot think of anything
99
// </todo>
100
101
template
<
class
Range>
class
SampledFunctional:
102
public
Functional<uInt, Range>
103
{
104
public
:
105
// Access the specified element of the data
106
virtual
Range
operator()
(
const
uInt
&index)
const
= 0;
107
// Return the total size of the data set.
108
virtual
uInt
nelements
()
const
= 0;
109
// The virtual destructor does nothing
110
virtual
~SampledFunctional
(){}
111
};
112
113
114
}
//# NAMESPACE CASACORE - END
115
116
#endif
casacore::uInt
unsigned int uInt
Definition:
aipstype.h:51
casacore
this file contains all the compiler specific defines
Definition:
mainpage.dox:28
casacore::SampledFunctional::~SampledFunctional
virtual ~SampledFunctional()
The virtual destructor does nothing.
Definition:
SampledFunctional.h:110
casacore::SampledFunctional::operator()
virtual Range operator()(const uInt &index) const =0
Access the specified element of the data.
casacore::SampledFunctional::nelements
virtual uInt nelements() const =0
Return the total size of the data set.
Generated by
1.8.17