Composite.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2004 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/MEAL/MEAL/Composite.h
10
11#ifndef __Composite_H
12#define __Composite_H
13
14#include "MEAL/Function.h"
15#include "MEAL/Projection.h"
16
17namespace MEAL {
18
20 class Composite : public ParameterPolicy {
21
22 public:
23
25 Composite (Function* context);
26
28 Composite* clone (Function* context) const { return 0; }
29
31 unsigned get_nmodel () const;
32
34 std::string class_name() const;
35
36 // ///////////////////////////////////////////////////////////////////
37 //
38 // ParameterPolicy implementation
39 //
40 // ///////////////////////////////////////////////////////////////////
41
43 unsigned get_nparam () const;
44
46 std::string get_name (unsigned index) const;
47
49 std::string get_description (unsigned index) const;
50
52 double get_param (unsigned index) const;
53
55 void set_param (unsigned index, double value);
56
58 double get_variance (unsigned index) const;
59
61 void set_variance (unsigned index, double variance);
62
64 bool get_infit (unsigned index) const;
65
67 void set_infit (unsigned index, bool flag);
68
69 // ///////////////////////////////////////////////////////////////////
70 //
71 // ArgumentPolicy implementation
72 //
73 // ///////////////////////////////////////////////////////////////////
74
76 void set_argument (unsigned dimension, Argument* axis);
77
79 template <class Type>
80 void map (Project<Type>& model)
81 {
83 std::cerr << class_name() + "map (Project<Type>)" << std::endl;
84 map (model.get_map());
85 }
86
88 template <class Type>
89 void unmap (Project<Type>& model)
90 {
92 std::cerr << class_name() + "unmap (Project<Type>)" << std::endl;
93 unmap (model.get_map());
94 }
95
97 void map (Projection* model);
98
100 void unmap (Projection* model);
101
103 void clear ();
104
106 void get_imap (const Function* model,
107 std::vector<unsigned>::iterator& imap) const;
108
110 void attribute_changed (Function::Attribute attribute);
111
112 protected:
113
115 friend class Projection;
116
118 unsigned find_Function (Function* model) const;
119
121 unsigned find_Projection (Projection* model) const;
122
123 private:
124
126 std::vector< Reference::To<Projection> > maps;
127
129 std::vector< Reference::To<Function> > models;
130
132 mutable unsigned nparameters;
133
135 mutable unsigned current_model;
136
138 mutable unsigned current_index;
139
141 mutable bool remap_needed;
142
144 mutable bool disable_callbacks;
145
147 mutable bool component_shares_this;
148
150 void init ();
151
153 void add_component (Function*, std::vector<unsigned>& imap);
154
156 void remove_component (Function*);
157
159 void remap ();
160
162 void remap_later ();
163
165 void callbacks ();
166
168 void recount () const;
169
171 const Function* get_Function (unsigned& index) const;
172
174 Function* get_Function (unsigned& index);
175
177 void reference_check (unsigned imodel, const char* method) const;
178
179 };
180
181 void get_imap (const Function* composite, const Function* component,
182 std::vector<unsigned>& imap);
183
184}
185
186
187#endif
188
Pure virtual base class of function arguments.
Definition Argument.h:25
unsigned get_nmodel() const
Get the number of models mapped into this model.
Definition Composite.C:133
std::string get_description(unsigned index) const
Return the name of the specified parameter.
Definition Composite.C:59
void attribute_changed(Function::Attribute attribute)
Method called when a Function attribute has changed.
Definition Composite.C:479
unsigned find_Projection(Projection *model) const
Return the index for the specified model.
Definition Composite.C:573
unsigned get_nparam() const
Return the number of parameters.
Definition Composite.C:43
Composite(Function *context)
Default constructor.
Definition Composite.C:18
Composite * clone(Function *context) const
Clone constructor.
Definition Composite.h:28
std::string class_name() const
Get the name used in verbose output.
Definition Composite.C:127
void set_infit(unsigned index, bool flag)
Set flag for parameter at index to be fitted.
Definition Composite.C:101
unsigned find_Function(Function *model) const
Return the index for the specified model.
Definition Composite.C:558
void clear()
Clear all models.
Definition Composite.C:35
void set_argument(unsigned dimension, Argument *axis)
Set the independent variable of the specified dimension.
Definition Composite.C:109
std::string get_name(unsigned index) const
Return the name of the specified parameter.
Definition Composite.C:52
void set_variance(unsigned index, double variance)
Set the variance of the specified parameter.
Definition Composite.C:87
void unmap(Project< Type > &model)
Convenience interface to unmap (Projection*)
Definition Composite.h:89
double get_variance(unsigned index) const
Return the variance of the specified parameter.
Definition Composite.C:80
bool get_infit(unsigned index) const
Return true if parameter at index is to be fitted.
Definition Composite.C:94
friend class Projection
Provide access to Projection base class.
Definition Composite.h:115
void get_imap(const Function *model, std::vector< unsigned >::iterator &imap) const
Get the mapping for the given Function.
Definition Composite.C:591
void map(Project< Type > &model)
Convenience interface to map (Projection*)
Definition Composite.h:80
void set_param(unsigned index, double value)
Set the value of the specified parameter.
Definition Composite.C:73
double get_param(unsigned index) const
Return the value of the specified parameter.
Definition Composite.C:66
Pure virtual base class of all functions.
Definition Function.h:49
static bool very_verbose
Low-level verbosity flag.
Definition Function.h:57
Attribute
Function attributes that require the attention of Composite models.
Definition Function.h:167
ParameterPolicy(Function *context)
Default destructor.
Definition ParameterPolicy.C:14
Template combines a reference to a Component and its Projection.
Definition Projection.h:60
Projection * get_map()
Return the Projection.
Definition Projection.h:80
Manages a Function and the mapping of its parameters into a Composite.
Definition Projection.h:22
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16

Generated using doxygen 1.14.0