casacore
Loading...
Searching...
No Matches
casa
BasicMath
Functional.h
Go to the documentation of this file.
1
//# Functional.h: Map a domain object into a range object via operator().
2
//# Copyright (C) 1995,1996,1999-2001
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: casa-feedback@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
#ifndef CASA_FUNCTIONAL_H
27
#define CASA_FUNCTIONAL_H
28
29
//# Includes
30
#include <casacore/casa/aips.h>
31
32
namespace
casacore
{
//# NAMESPACE CASACORE - BEGIN
33
34
//# Forward declaration
35
template
<
class
T>
class
Lattice
;
36
37
// <summary> Map a domain object into a range object via operator().
38
// </summary>
39
40
// <use visibility=export>
41
42
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
43
// </reviewed>
44
45
// <etymology> The term ``Functional'' was chosen to follow the usage
46
// in Barton and Nackman's ``Scientific and Engineering C++.''
47
// </etymology>
48
//
49
// <synopsis>
50
// A <src>Functional<Domain,Range></src> is an abstract base class which
51
// encapsulates the mapping of an object of type <src>Domain</src> into an
52
// object of type <src>Range</src>.
53
// This operation is invoked via operator() to make it look like
54
// a function call.
55
//
56
// While these functions are <src>function-like</src>, there is no guarantee
57
// that evaluations of the same parameter will yield the same result
58
// (the implementor of a particular class could, for example, merely choose
59
// to emit a random number).
60
// However implementors of <src>Functional</src> classes are strongly
61
// encouraged to implement (visible) side-effect free semantics in their
62
// classes.
63
//
64
// A <src>Functional</src> object is used in circumstances similar to those
65
// in which a function pointer could be used. An advantage of the
66
// <src>Functional</src> objects is that it is possible to have more than
67
// one of them at the same time.
68
// Another potential advantage (not yet
69
// implemented) is that it will be possible to perform functional
70
// composition at run time, e.g. a=b+c where a,b, and c are
71
// <src>Functionals</src>.
72
// Another advantage is that since the Functional implementations
73
// will in general be templated, the same source code would yield
74
// instantiations for all the numeric types and for specializations like
75
// automatic derivatives.
76
//
77
// To be of greatest utility, a library of functions that do mathematics,
78
// plotting, etc. on Functional objects needs to be developed.
79
// </synopsis>
80
//
81
// <example>
82
// The following simple example shows how you can write a function that uses a
83
// Functional object.
84
// <srcblock>
85
// Double integrate1D(const Functional<Float,Float> &f,
86
// Double x1, Double x2, Double dx) {
87
// uInt n = (xend - xstart) / dx;
88
// Double sum = 0.0;
89
// for (uInt i=0; i < n; i++) sum += f(x1 + i*dx) * dx;
90
// return sum;
91
// }
92
// </srcblock>
93
// Obviously this isn't a very serious algorithm!
94
// </example>
95
//
96
// <motivation>
97
// The specific application that caused the implementation of these
98
// <src>Functional</src>
99
// classes was the creation of the <linkto module="Fitting">Fitting
100
// </linkto> module, which needed classes to represent the fitting functions.
101
// </motivation>
102
//
103
// <templating arg=Domain>
104
// <li> Accessible default and copy constructors, assignment operators,
105
// and destructors will almost always also be required.
106
// </templating>
107
//
108
// <templating arg=Range>
109
// <li> A copy constructor is absolutely required for Range objects because
110
// operator() returns Range objects by value.
111
// <li> Accessible default constructors, assignment operators,
112
// and destructors will almost always also be required.
113
// </templating>
114
//
115
// <todo asof="2001/08/29">
116
// <li> For polymorphic access it could be that a <src>clone()</src> function
117
// is needed at this level.
118
// </todo>
119
120
template
<
class
Domain,
class
Range>
class
Functional
{
121
public
:
122
//# Constructors
123
// Destructor
124
virtual
~Functional
();
125
126
//# Operators
127
// Map a Domain <src>x</src> into a Range <src>y</src> value.
128
virtual
Range
operator()
(
const
Domain &x)
const
= 0;
129
};
130
131
132
}
//# NAMESPACE CASACORE - END
133
134
#ifndef CASACORE_NO_AUTO_TEMPLATES
135
#include <casacore/casa/BasicMath/Functional.tcc>
136
#endif
//# CASACORE_NO_AUTO_TEMPLATES
137
#endif
casacore::Functional
Definition
Functional.h:120
casacore::Functional::~Functional
virtual ~Functional()
Destructor.
casacore::Functional::operator()
virtual Range operator()(const Domain &x) const =0
Map a Domain x into a Range y value.
casacore::Lattice
Definition
Lattice.h:230
casacore
this file contains all the compiler specific defines
Definition
mainpage.dox:28
Generated by
1.15.0