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

step/stepcore

eulersolver.h

Go to the documentation of this file.
00001 /* This file is part of StepCore library.
00002    Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
00003 
00004    StepCore library is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 2 of the License, or
00007    (at your option) any later version.
00008 
00009    StepCore library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with StepCore; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 */
00018 
00023 #ifndef STEPCORE_EULERSOLVER_H
00024 #define STEPCORE_EULERSOLVER_H
00025 
00026 #include "solver.h"
00027 #include "object.h"
00028 
00029 namespace StepCore {
00030 
00039 class GenericEulerSolver: public Solver
00040 {
00041     STEPCORE_OBJECT(GenericEulerSolver)
00042 
00043 public:
00045     GenericEulerSolver(double stepSize, bool adaptive)
00046         : Solver(stepSize), _adaptive(adaptive) { init(); }
00048     GenericEulerSolver(int dimension, Function function,
00049             void* params, double stepSize, bool adaptive)
00050         : Solver(dimension, function, params, stepSize),
00051             _adaptive(adaptive) { init(); }
00053     GenericEulerSolver(const GenericEulerSolver& eulerSolver)
00054         : Solver(eulerSolver), _adaptive(eulerSolver._adaptive) { init(); }
00055 
00056     ~GenericEulerSolver() { fini(); }
00057 
00058     void setDimension(int dimension) { fini(); _dimension = dimension; init(); }
00059 
00060     int doCalcFn(double* t, const double* y, const double* yvar = 0,
00061                         double* f = 0, double* fvar = 0);
00062     int doEvolve(double* t, double t1, double* y, double* yvar);
00063 
00064 protected:
00065     int doStep(double t, double stepSize, double* y, double* yvar);
00066     void init();
00067     void fini();
00068 
00069     bool    _adaptive;
00070     double* _yerr;
00071     double* _ytemp;
00072     double* _ydiff;
00073     double* _ytempvar;
00074     double* _ydiffvar;
00075 };
00076 
00080 class EulerSolver: public GenericEulerSolver
00081 {
00082     STEPCORE_OBJECT(EulerSolver)
00083 public:
00084     EulerSolver(double stepSize = 0.01): GenericEulerSolver(stepSize, false) {}
00085     EulerSolver(int dimension, Function function, void* params, double stepSize)
00086                     : GenericEulerSolver(dimension, function, params, stepSize, false) {}
00087     EulerSolver(const EulerSolver& eulerSolver): GenericEulerSolver(eulerSolver) {}
00088 };
00089 
00093 class AdaptiveEulerSolver: public GenericEulerSolver
00094 {
00095     STEPCORE_OBJECT(AdaptiveEulerSolver)
00096 public:
00097     AdaptiveEulerSolver(): GenericEulerSolver(1, true) {}
00098     AdaptiveEulerSolver(int dimension, Function function, void* params)
00099                     : GenericEulerSolver(dimension, function, params, 1, true) {}
00100     AdaptiveEulerSolver(const AdaptiveEulerSolver& eulerSolver)
00101                     : GenericEulerSolver(eulerSolver) {}
00102 };
00103 
00104 } // namespace StepCore
00105 
00106 #endif
00107 

step/stepcore

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

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal