• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

step/stepcore

  • sources
  • kde-4.12
  • kdeedu
  • step
  • stepcore
gslsolver.h
Go to the documentation of this file.
1 /* This file is part of StepCore library.
2  Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
3 
4  StepCore library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  StepCore library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with StepCore; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
23 #ifndef STEPCORE_GSLSOLVER_H
24 #define STEPCORE_GSLSOLVER_H
25 
26 // HACK: CMake does not passes definitions to moc
27 #if defined(STEPCORE_WITH_GSL) || defined(Q_MOC_RUN)
28 
29 #include "solver.h"
30 #include "object.h"
31 
32 #include <gsl/gsl_odeiv.h>
33 
34 namespace StepCore
35 {
36 
44 class GslGenericSolver: public Solver
45 {
46  STEPCORE_OBJECT(GslGenericSolver)
47 
48 public:
50  GslGenericSolver(double stepSize, bool adaptive, const gsl_odeiv_step_type* gslStepType)
51  : Solver(stepSize), _adaptive(adaptive), _gslStepType(gslStepType) { init(); }
53  GslGenericSolver(int dimension, Function function, void* params, double stepSize,
54  bool adaptive, const gsl_odeiv_step_type* gslStepType)
55  : Solver(dimension, function, params, stepSize),
56  _adaptive(adaptive), _gslStepType(gslStepType) { init(); }
58  GslGenericSolver(const GslGenericSolver& gslSolver)
59  : Solver(gslSolver), _adaptive(gslSolver._adaptive),
60  _gslStepType(gslSolver._gslStepType) { init(); }
61 
62  ~GslGenericSolver() { fini(); }
63 
64  void setDimension(int dimension) { fini(); _dimension = dimension; init(); }
65  void setToleranceAbs(double toleranceAbs) { fini(); _toleranceAbs = toleranceAbs; init(); }
66  void setToleranceRel(double toleranceRel) { fini(); _toleranceRel = toleranceRel; init(); }
67 
68  int doCalcFn(double* t, const VectorXd* y, const VectorXd* yvar,
69  VectorXd* f = 0, VectorXd* fvar = 0);
70  int doEvolve(double* t, double t1, VectorXd* y, VectorXd* yvar);
71 
72 protected:
73  static int gslFunction(double t, const double* y, double* f, void* params);
74  void init();
75  void fini();
76 
77  bool _adaptive;
78 
79  //gsl_odeiv_control* _gslControl;
80  //gsl_odeiv_evolve* _gslEvolve;
81  VectorXd _yerr;
82  VectorXd _ytemp;
83  VectorXd _ydiff;
84  VectorXd _dydt_in;
85  VectorXd _dydt_out;
86 
87  const gsl_odeiv_step_type* _gslStepType;
88  gsl_odeiv_system _gslSystem;
89  gsl_odeiv_step* _gslStep;
90  gsl_odeiv_control* _gslControl;
91  gsl_odeiv_evolve* _gslEvolve;
92 };
93 
97 class GslSolver: public GslGenericSolver
98 {
99  STEPCORE_OBJECT(GslSolver)
100 public:
101  GslSolver(double stepSize, const gsl_odeiv_step_type* gslStepType):
102  GslGenericSolver(stepSize, false, gslStepType) {}
103  GslSolver(int dimension, Function function, void* params, double stepSize,
104  const gsl_odeiv_step_type* gslStepType)
105  : GslGenericSolver(dimension, function, params, stepSize, false, gslStepType) {}
106  GslSolver(const GslSolver& gslSolver): GslGenericSolver(gslSolver) {}
107 };
108 
112 class GslAdaptiveSolver: public GslGenericSolver
113 {
114  STEPCORE_OBJECT(GslAdaptiveSolver)
115 public:
116  GslAdaptiveSolver(const gsl_odeiv_step_type* gslStepType):
117  GslGenericSolver(1, true, gslStepType) {}
118  GslAdaptiveSolver(int dimension, Function function, void* params,
119  const gsl_odeiv_step_type* gslStepType)
120  : GslGenericSolver(dimension, function, params, 1, true, gslStepType) {}
121  GslAdaptiveSolver(const GslAdaptiveSolver& gslSolver): GslGenericSolver(gslSolver) {}
122 };
123 
124 #define STEPCORE_DECLARE_GSLSOLVER(Class, type) \
125 class Gsl##Class##Solver: public GslSolver { \
126  STEPCORE_OBJECT(Gsl##Class##Solver) \
127 public: \
128  Gsl##Class##Solver(double stepSize = 0.01): GslSolver(stepSize, gsl_odeiv_step_##type) {} \
129  Gsl##Class##Solver(int dimension, Function function, void* params, double stepSize) \
130  : GslSolver(dimension, function, params, stepSize, gsl_odeiv_step_##type) {} \
131  Gsl##Class##Solver(const Gsl##Class##Solver& gslSolver): GslSolver(gslSolver) {} \
132 };
133 
134 #define STEPCORE_DECLARE_GSLASOLVER(Class, type) \
135 class GslAdaptive##Class##Solver: public GslAdaptiveSolver { \
136  STEPCORE_OBJECT(GslAdaptive##Class##Solver) \
137 public: \
138  GslAdaptive##Class##Solver(): GslAdaptiveSolver(gsl_odeiv_step_##type) {} \
139  GslAdaptive##Class##Solver(int dimension, Function function, void* params) \
140  : GslAdaptiveSolver(dimension, function, params, gsl_odeiv_step_##type) {} \
141  GslAdaptive##Class##Solver(const GslAdaptive##Class##Solver& gslSolver): GslAdaptiveSolver(gslSolver) {} \
142 };
143 
148 STEPCORE_DECLARE_GSLSOLVER(RK2, rk2)
149 
150 
154 STEPCORE_DECLARE_GSLASOLVER(RK2, rk2)
155 
160 STEPCORE_DECLARE_GSLSOLVER(RK4, rk4)
161 
166 STEPCORE_DECLARE_GSLASOLVER(RK4, rk4)
167 
172 STEPCORE_DECLARE_GSLSOLVER(RKF45, rkf45)
173 
178 STEPCORE_DECLARE_GSLASOLVER(RKF45, rkf45)
179 
184 STEPCORE_DECLARE_GSLSOLVER(RKCK, rkck)
185 
190 STEPCORE_DECLARE_GSLASOLVER(RKCK, rkck)
191 
196 STEPCORE_DECLARE_GSLSOLVER(RK8PD, rk8pd)
197 
202 STEPCORE_DECLARE_GSLASOLVER(RK8PD, rk8pd)
203 
208 STEPCORE_DECLARE_GSLSOLVER(RK2IMP, rk2imp)
209 
214 STEPCORE_DECLARE_GSLASOLVER(RK2IMP, rk2imp)
215 
220 STEPCORE_DECLARE_GSLSOLVER(RK4IMP, rk4imp)
221 
226 STEPCORE_DECLARE_GSLASOLVER(RK4IMP, rk4imp)
227 
228 } // namespace StepCore
229 
230 #endif // defined(STEPCORE_WITH_GSL) || defined(Q_MOC_RUN)
231 
232 #endif // STEPCORE_GSLSOLVER_H
233 
solver.h
Solver interface.
object.h
Object, MetaObject and MetaProperty classes.
STEPCORE_OBJECT
#define STEPCORE_OBJECT(_className)
Definition: object.h:49
StepCore::VectorXd
Eigen::VectorXd VectorXd
Definition: vector.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:43:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal