The Conley-Morse Graphs Software
m_globclog.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file m_globclog.h
4///
5/// Globally coupled logistic maps.
6///
7/// This map defines the transformation for globally coupled logistic maps.
8///
9/// @author Pawel Pilarczyk
10///
11/////////////////////////////////////////////////////////////////////////////
12
13// Copyright (C) 1997-2014 by Pawel Pilarczyk.
14//
15// This file is part of my research software package. This is free software:
16// you can redistribute it and/or modify it under the terms of the GNU
17// General Public License as published by the Free Software Foundation,
18// either version 3 of the License, or (at your option) any later version.
19//
20// This software is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23// GNU General Public License for more details.
24//
25// You should have received a copy of the GNU General Public License
26// along with this software; see the file "license.txt". If not,
27// please, see <https://www.gnu.org/licenses/>.
28
29// Started on April 10, 2008. Last revision: September 13, 2010.
30
31
32#ifndef _CMGRAPHS_GLOBCLOG_H_
33#define _CMGRAPHS_GLOBCLOG_H_
34
35// some standard header files
36#include <cmath>
37
38// the generic class for the type of a map
39#include "maptype.h"
40
41// the interval arithmetic data types
42#include "typeintv.h"
43
44
45// --------------------------------------------------
46// -------- the Leslie population model map ---------
47// --------------------------------------------------
48
49/// This class defines a map which describes a family of globally coupled
50/// logistic maps.
51/// There are only two parameters of this map: 'a' and 'epsilon'.
52/// Warning: This class is not thread-safe!
53class MapGlobCLog: public MapType
54{
55public:
56 /// The default constructor.
57 MapGlobCLog ();
58
59 /// The destructor.
60 ~MapGlobCLog ();
61
62 /// Computes the image of a box whose left and right coordinates
63 /// are given. Fills in the images with the left and right
64 /// coordinates of the image box.
65 void compute (const double *xleft, const double *xright,
66 double *yleft, double *yright, int dim,
67 const spcCoord *coord, int subdiv) const;
68
69private:
70 /// Configuration option: Is this the weighted 2GCM model?
71 static const bool weighted2GCM = true;
72
73 /// Configuration option: Should we change the first two coordinates?
74 static const bool changeCoordinates = false;
75
76 /// The extra weights for the maps (for the weighted 2GCM).
77 mutable int *sigma;
78
79 /// The sum of the sigmas.
80 mutable int sigmaSum;
81
82 /// A temporary array for the variables.
84
85 /// The dimension for which the internal arrays have been allocated.
86 mutable int currentDim;
87
88 /// Rescaling factor for the changed coordinates.
89 double rescaling;
90
91 /// The logistic function f_a (x) = 1 - a x^2.
92 static IntervalType logistic (const IntervalType &x,
93 const IntervalType &a);
94
95 /// Sets the space dimension and (re-)allocates memory
96 /// for the sigma coefficients and variables.
97 void setDimension (int dim) const;
98
99 /// Applies a coordinate change to the input vector.
101 IntervalType *output, int dim) const;
102
103 /// Applies a coordinate change to the output vector.
105 IntervalType *output, int dim) const;
106
107}; /* class MapGlobCLog */
108
109// --------------------------------------------------
110
112 sigma (0), sigmaSum (0), variables (0), currentDim (0),
113 rescaling (std::sqrt (2.0))
114{
115 testIntervals ();
116 return;
117} /* MapGlobCLog::MapGlobCLog */
118
120{
121 if (sigma)
122 delete [] sigma;
123 sigma = 0;
124 if (variables)
125 delete [] variables;
126 variables = 0;
127 return;
128} /* MapGlobCLog::~MapGlobCLog */
129
131 const IntervalType &a)
132{
133 return 1 - a * x * x;
134} /* MapGlobCLog::logistic */
135
136inline void MapGlobCLog::setDimension (int dim) const
137{
138 if (currentDim == dim)
139 return;
140 if (sigma)
141 delete [] sigma;
142 if (variables)
143 delete [] variables;
144 currentDim = dim;
145 sigma = new int [currentDim];
147 sigmaSum = 0;
148 for (int i = 0; i < dim; ++ i)
149 {
150 sigma [i] = 1;
151 if (weighted2GCM && (dim == 2) && (i == 0))
152 sigma [i] = 2;
153 sigmaSum += sigma [i];
154 }
155 return;
156} /* MapGlobCLog::setDimension */
157
159 IntervalType *output, int dim) const
160{
162 return input;
163 output [0] = (input [0] - input [1]) / 2 * rescaling;
164 output [1] = (input [0] + input [1]) / 2 * rescaling;
165 for (int i = 2; i < dim; ++ i)
166 output [i] = input [i];
167 return output;
168} /* MapGlobCLog::changeCoordsIn */
169
171 IntervalType *output, int dim) const
172{
174 return input;
175 output [0] = (input [0] + input [1]) / rescaling;
176 output [1] = (input [1] - input [0]) / rescaling;
177 for (int i = 2; i < dim; ++ i)
178 output [i] = input [i];
179 return output;
180} /* MapGlobCLog::changeCoordsOut */
181
182inline void MapGlobCLog::compute (const double *xleft, const double *xright,
183 double *yleft, double *yright, int dim, const spcCoord *, int) const
184{
185 // set the dimension for the sigmas and other temporary variables
186 setDimension (dim);
187
188 // create the intervals of the argument variables
189 for (int i = 0; i < dim; ++ i)
190 {
191 variables [i] = IntervalType (xleft [i], xright [i]);
192 }
193
194 // apply a coordinate change transformation if necessary
195 IntervalType *newVariables =
196 changeCoordsIn (variables, variables + dim, dim);
197
198 // determine the parameter 'a'
200
201 // compute the logistic maps on all the variables
202 IntervalType *images = variables;
203 for (int i = 0; i < dim; ++ i)
204 {
205 images [i] = logistic (newVariables [i], a);
206 }
207
208 // compute the average of the logistic maps on the domain
209 IntervalType average (0.0, 0.0);
210 for (int i = 0; i < dim; ++ i)
211 {
212 if (sigma [i] == 1)
213 average += variables [i];
214 else
215 average += sigma [i] * variables [i];
216 }
217
218 // determine the epsilon parameter and set 1-eps
219 IntervalType epsilon (getLeftParam (1), getRightParam (1));
220 IntervalType oneminuseps = 1 - epsilon;
221
222 // make a correction to the average that is to be added
223 average *= epsilon;
224 average /= sigmaSum;
225
226 // compute the results
227 IntervalType *results = variables + dim;
228 for (int i = 0; i < dim; ++ i)
229 {
230 results [i] = oneminuseps * images [i] + average;
231 }
232
233 // apply a coordinate change transformation if necessary
234 IntervalType *newResults =
235 changeCoordsOut (variables + dim, variables, dim);
236
237 // extract the images from the intervals
238 for (int i = 0; i < dim; ++ i)
239 {
240 yleft [i] = newResults [i]. leftBound ();
241 yright [i] = newResults [i]. rightBound ();
242 }
243
244 // swich the rounding direction to the neutral one
245 resetRounding ();
246 return;
247} /* MapGlobCLog::compute */
248
249
250#endif // _CMGRAPHS_GLOBCLOG_H_
251
This class defines a map which describes a family of globally coupled logistic maps.
Definition: m_globclog.h:54
int currentDim
The dimension for which the internal arrays have been allocated.
Definition: m_globclog.h:86
double rescaling
Rescaling factor for the changed coordinates.
Definition: m_globclog.h:89
IntervalType * variables
A temporary array for the variables.
Definition: m_globclog.h:83
IntervalType * changeCoordsOut(IntervalType *input, IntervalType *output, int dim) const
Applies a coordinate change to the output vector.
Definition: m_globclog.h:170
~MapGlobCLog()
The destructor.
Definition: m_globclog.h:119
void setDimension(int dim) const
Sets the space dimension and (re-)allocates memory for the sigma coefficients and variables.
Definition: m_globclog.h:136
static const bool weighted2GCM
Configuration option: Is this the weighted 2GCM model?
Definition: m_globclog.h:71
IntervalType * changeCoordsIn(IntervalType *input, IntervalType *output, int dim) const
Applies a coordinate change to the input vector.
Definition: m_globclog.h:158
static IntervalType logistic(const IntervalType &x, const IntervalType &a)
The logistic function f_a (x) = 1 - a x^2.
Definition: m_globclog.h:130
MapGlobCLog()
The default constructor.
Definition: m_globclog.h:111
int * sigma
The extra weights for the maps (for the weighted 2GCM).
Definition: m_globclog.h:77
int sigmaSum
The sum of the sigmas.
Definition: m_globclog.h:80
static const bool changeCoordinates
Configuration option: Should we change the first two coordinates?
Definition: m_globclog.h:74
void compute(const double *xleft, const double *xright, double *yleft, double *yright, int dim, const spcCoord *coord, int subdiv) const
Computes the image of a box whose left and right coordinates are given.
Definition: m_globclog.h:182
This is an abstract class which defines the interface to other classes that describe maps for the use...
Definition: maptype.h:59
const double & getLeftParam(int n) const
Returns the left value of the given parameter.
Definition: maptype.h:196
const double & getRightParam(int n) const
Returns the right value of the given parameter.
Definition: maptype.h:203
An abstract map type.
Data types for interval arithmetic.
void resetRounding()
This function resets rounding switches of the processor and sets rounding to the nearest.
Definition: typeintv.h:65
bool testIntervals(bool throwException=false)
Testing interval arithmetic.
Definition: typeintv.h:82
capd::DInterval IntervalType
The type of an interval (from the CAPD library 2.9/3.0 beta).
Definition: typeintv.h:49
int spcCoord
The type of coordinates of cubes in the phase space.
Definition: typespace.h:50