1 |
// -*- C++ -*- |
2 |
// AID-GENERATED |
3 |
// ========================================================================= |
4 |
// This class was generated by AID - Abstract Interface Definition |
5 |
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it. |
6 |
// ========================================================================= |
7 |
#ifndef AIDA_IFUNCTION_H |
8 |
#define AIDA_IFUNCTION_H 1 |
9 |
|
10 |
// This file is part of the AIDA library |
11 |
// Copyright (C) 2002 by the AIDA team. All rights reserved. |
12 |
// This library is free software and under the terms of the |
13 |
// GNU Library General Public License described in the LGPL.txt |
14 |
|
15 |
#include <string> |
16 |
#include <vector> |
17 |
|
18 |
namespace AIDA { |
19 |
|
20 |
class IAnnotation; |
21 |
|
22 |
/** @interface IFunction |
23 |
* |
24 |
* Principal user-level function interface. Function is a self |
25 |
* contained object, which remembers the current value of its parameters |
26 |
* which are simple doubles. IFunction may be directly plotted or fitted. |
27 |
* |
28 |
* The standard convention of referring to variables by name: |
29 |
* "x[0]" corresponds to variable number 0 etc. |
30 |
* |
31 |
* @author The AIDA team (http://aida.freehep.org/) |
32 |
* |
33 |
*/ |
34 |
|
35 |
class IFunction { |
36 |
|
37 |
public: |
38 |
/// Destructor. |
39 |
virtual ~IFunction() { /* nop */; } |
40 |
|
41 |
/** |
42 |
* Get the Function's title. |
43 |
* @return The Function's title. |
44 |
* |
45 |
*/ |
46 |
virtual std::string title() const = 0; |
47 |
|
48 |
/** |
49 |
* Set the histogram title. |
50 |
* @param title The title. |
51 |
* @return false If title cannot be changed. |
52 |
* |
53 |
*/ |
54 |
virtual bool setTitle(const std::string & title) = 0; |
55 |
|
56 |
/** |
57 |
* Scalar value of the function. |
58 |
*/ |
59 |
virtual double value(const std::vector<double> & x) const = 0; |
60 |
|
61 |
/** |
62 |
* Dimensionality of the domain space. |
63 |
*/ |
64 |
virtual int dimension() const = 0; |
65 |
|
66 |
/** |
67 |
* Compare if functions are the same. |
68 |
* PENDING: define exactly what it means ;) |
69 |
*/ |
70 |
virtual bool isEqual(const IFunction & f) const = 0; |
71 |
|
72 |
/** |
73 |
* Gradient of the function. |
74 |
* The result is valid only if providesGradient()==true. |
75 |
* Otherwise the result is some default (empty) vector. |
76 |
*/ |
77 |
virtual const std::vector<double> & gradient(const std::vector<double> & x) const = 0; |
78 |
|
79 |
/** |
80 |
* Determine whether function is able to compute gradient. |
81 |
*/ |
82 |
virtual bool providesGradient() const = 0; |
83 |
|
84 |
/** |
85 |
* Get the symbolic name of i-th variable. |
86 |
*/ |
87 |
virtual std::string variableName(int i) const = 0; |
88 |
|
89 |
/** |
90 |
* Get all the names in a vector. |
91 |
*/ |
92 |
virtual std::vector<std::string> variableNames() const = 0; |
93 |
|
94 |
/** |
95 |
* Set new vector of parameters. |
96 |
*/ |
97 |
virtual bool setParameters(const std::vector<double> & params) = 0; |
98 |
|
99 |
/** |
100 |
* Retrieve current vector of parameters. |
101 |
*/ |
102 |
virtual const std::vector<double> & parameters() const = 0; |
103 |
|
104 |
/** |
105 |
* Number of parameters. |
106 |
*/ |
107 |
virtual int numberOfParameters() const = 0; |
108 |
|
109 |
/** |
110 |
* Names of paramaters. |
111 |
* Names should be unique. Case-insensitive for comparison. |
112 |
* Case-sensitive for storage and output. |
113 |
* All or several names may be left blank "" if the implementation |
114 |
* does not want to provide them. |
115 |
*/ |
116 |
virtual std::vector<std::string> parameterNames() const = 0; |
117 |
|
118 |
/** |
119 |
* Set parameter's value by name. |
120 |
* @param name The name of the parameter. |
121 |
* @param x The new value of the parameter. |
122 |
* @return false If name does not correspond to a parameter. |
123 |
* |
124 |
*/ |
125 |
virtual bool setParameter(const std::string & name, double x) = 0; |
126 |
|
127 |
virtual double parameter(const std::string & name) const = 0; |
128 |
|
129 |
/** |
130 |
* Return -1 if parameter not found (name undefined). |
131 |
* Leave it because there are use cases - some users prefer to use numbers. |
132 |
*/ |
133 |
virtual int indexOfParameter(const std::string & name) const = 0; |
134 |
|
135 |
virtual IAnnotation & annotation() = 0; |
136 |
|
137 |
virtual const IAnnotation & annotation() const = 0; |
138 |
|
139 |
/** |
140 |
* String describing the metatype and implementation of the function. |
141 |
* |
142 |
* Generic format of the string: |
143 |
* |
144 |
* codelet:TYPE:LOCATION |
145 |
* |
146 |
* TYPE part contains only a 'typename' string |
147 |
* which is a metatype identifier (used in plugins and catalogues) |
148 |
* |
149 |
* LOCATION may be: 'file', 'verbatim', or 'catalogue' |
150 |
* |
151 |
* Detailed description: |
152 |
* |
153 |
* codelet:typename - no location specified (using 'catalogue') |
154 |
* |
155 |
* codelet:typename:file:/filename.cpp - a c++ source file |
156 |
* codelet:typename:file:/filename.py - a python source file |
157 |
* codelet:typename:file:/filename.so - a shared library |
158 |
* |
159 |
* codelet:typename:catalogue - entry in a catalogue repository |
160 |
* |
161 |
* codelet:typename:verbatim:cpp \n - c++ source file included verbatim |
162 |
* after \n |
163 |
* |
164 |
* codelet:typename:verbatim:py \n - python source file included |
165 |
* verbatim aftern \n |
166 |
* |
167 |
* |
168 |
* Comments: |
169 |
* |
170 |
* file:/filename is a relative path to $AIDA_FUNCTION_DEFAULT_DIR |
171 |
* file://filename is an absolute path |
172 |
* |
173 |
* Examples: |
174 |
* |
175 |
* codelet:G:catalogue |
176 |
* codelet:userSinus:verbatim:cpp \n { return sin(x); } |
177 |
*/ |
178 |
virtual std::string codeletString() const = 0; |
179 |
|
180 |
/** |
181 |
* See IManagedObject for a description. |
182 |
* @param className The name of the class to cast on. |
183 |
* @return The right pointer. Return 0 if failure. |
184 |
*/ |
185 |
virtual void * cast(const std::string & className) const = 0; |
186 |
|
187 |
/** @link aggregation */ |
188 |
/*# IAnnotation lnkIAnnotation; */ |
189 |
}; // class |
190 |
} // namespace AIDA |
191 |
#endif /* ifndef AIDA_IFUNCTION_H */ |