HyperspaceExplorer 0.7.1
ComplexFunction.h
00001 /*
00002 Hyperspace Explorer - visualizing higher-dimensional geometry
00003 Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License along
00016 with this program; if not, write to the Free Software Foundation, Inc.,
00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 
00021 #ifndef COMPLEXFUNCTION_H
00022 #define COMPLEXFUNCTION_H 1
00023 
00024 
00025 #include "Surface.h"
00026 
00027 #include <complex>
00028 
00030 
00039 class ComplexFunction: public Surface {
00040 public:
00042   ComplexFunction (): Surface() {
00043     _function = std::shared_ptr< ParametricFunction<4, 2> >(new DefiningFunction(this));
00044   }
00045   ComplexFunction (double _umin, double _umax, double _du,
00046                     double _vmin, double _vmax, double _dv);
00047   virtual ~ComplexFunction ();
00049 
00052   virtual void SetParameters (double = 0, double = 0, double = 0, double = 0) { }
00053 
00055   typedef std::complex<double> function_type(std::complex <double>);
00056 
00057 protected:
00058 
00059   virtual function_type g = 0;    
00060 
00062   const static QString sup2;
00064   const static QString sup3;
00065 
00066 private:
00067 
00069   struct DefiningFunction: public ParametricFunction<4, 2> {
00070 
00071     DefiningFunction(ComplexFunction *parent): _complex_function(parent) { }
00072     virtual return_type f(const argument_type &x);
00073 
00074   private:
00075 
00077     ComplexFunction * _complex_function;
00078   };
00079 
00080 };
00081 
00082 namespace {
00083   static DisplayableClass displayable_class_complex_function(
00084     "ComplexFunction", "Functions C -> C", "Surface"
00085   );
00086 }
00087 
00089 
00090 class z2: public ComplexFunction {
00091 public:
00092   z2 (): ComplexFunction() { }
00093   z2 (double _umin, double _umax, double _du,
00094       double _vmin, double _vmax, double _dv);
00095   virtual ~z2() { }
00096 
00097   virtual std::string getFunctionName() const { return "z2"; } //"z"+ComplexFunction::sup2,
00098 
00099 protected:
00100   virtual function_type g;
00101 };
00102 
00103 namespace {
00104     Displayable *createz2() { return new z2(); }
00105     const bool registered1 = TheFunctionFactory::Instance().registerFunction(createz2, "ComplexFunction");
00106 }
00107 
00109 
00110 class z3: public ComplexFunction {
00111     public:
00112         z3 (): ComplexFunction() { }
00113         z3 (double _umin, double _umax, double _du,
00114             double _vmin, double _vmax, double _dv);
00115         virtual ~z3() { }
00116 
00117         virtual std::string getFunctionName() const { return "z3"; } //"z"+ComplexFunction::sup3,
00118 
00119     protected:
00120         virtual function_type g;
00121 };
00122 
00123 namespace {
00124     Displayable *createz3() { return new z3(); }
00125     const bool registered2 = TheFunctionFactory::Instance().registerFunction(createz3, "ComplexFunction");
00126 }
00127 
00129 
00130 class zA: public ComplexFunction {
00131     public:
00132         zA (): ComplexFunction(), alpha(2) { }
00133         zA (double _umin, double _umax, double _du,
00134             double _vmin, double _vmax, double _dv,
00135             double _alpha = 2);
00136         virtual ~zA () { }
00137 
00138         virtual std::string getFunctionName() const { return "zA"; }
00139 
00141         virtual void SetParameters(const ParameterMap &parms) {
00142 #       if 1
00143             for (ParameterMap::const_iterator i = parms.begin();
00144                  i != parms.end(); ++i) {
00145                 if (i->second->getName() == "a") alpha = i->second->toDouble();
00146             }
00147 #       else
00148             setParameter(parms, this->Phase, "a");
00149 #       endif
00150         }
00151 
00152     protected:
00153         virtual function_type g;
00154 
00155     private:
00156         double alpha;   
00157 };
00158 
00159 namespace {
00160     Displayable *createzA() { return new zA(); }
00161     const bool registered3 = TheFunctionFactory::Instance().registerFunction(createzA, "ComplexFunction");
00162 }
00163 
00165 
00166 class ez: public ComplexFunction {
00167     public:
00168         ez (): ComplexFunction(), _alpha(2) { }
00169         ez (double _umin, double _umax, double _du,
00170             double _vmin, double _vmax, double _dv,
00171             double alpha = 2);
00172         virtual ~ez() { }
00173 
00174         virtual std::string getFunctionName() const { return "e^a*z"; }
00175 
00176         virtual void SetParameters(const ParameterMap &parms) {
00177 #       if 1
00178             for (ParameterMap::const_iterator i = parms.begin();
00179                  i != parms.end(); ++i) {
00180                 if (i->second->getName() == "a") _alpha = i->second->toDouble();
00181             }
00182 #       else
00183             setParameter(parms, this->Phase, "a");
00184 #       endif
00185         }
00186 
00187     protected:
00188         virtual function_type g;
00189 
00190     private:
00191         double _alpha;          
00192 };
00193 
00194 namespace {
00195     Displayable *createez() { return new ez(); }
00196     const bool registered4 = TheFunctionFactory::Instance().registerFunction(createez, "ComplexFunction");
00197 }
00198 
00200 
00201 class emz2: public ComplexFunction {
00202     public:
00203         emz2 (): ComplexFunction(), _alpha(1) { }
00204         emz2 (double _umin, double _umax, double _du,
00205               double _vmin, double _vmax, double _dv,
00206               double alpha = 1);
00207         virtual ~emz2() { }
00208 
00209         virtual std::string getFunctionName() const { return "emz2"; } // "e^-a*z"+ComplexFunction::sup2,
00210 
00211         virtual void SetParameters(const ParameterMap &parms) {
00212 #       if 1
00213             for (ParameterMap::const_iterator i = parms.begin();
00214                  i != parms.end(); ++i) {
00215                 if (i->second->getName() == "a") _alpha = i->second->toDouble();
00216             }
00217 #       else
00218             setParameter(parms, this->Phase, "a");
00219 #       endif
00220         }
00221 
00222     protected:
00223         virtual function_type g;
00224 
00225     private:
00226         double _alpha;          
00227 };
00228 
00229 namespace {
00230     Displayable *createemz2() { return new emz2(); }
00231     const bool registered5 = TheFunctionFactory::Instance().registerFunction(createemz2, "ComplexFunction");
00232 }
00233 
00235 
00236 class zm1: public ComplexFunction {
00237     public:
00238         zm1 (): ComplexFunction() { }
00239         zm1 (double _umin, double _umax, double _du,
00240              double _vmin, double _vmax, double _dv);
00241         virtual ~zm1 () { }
00242 
00243         virtual std::string getFunctionName() const { return "zm1"; }
00244 
00245     protected:
00246         virtual function_type g;
00247 };
00248 
00249 namespace {
00250     Displayable *createzm1() { return new zm1(); }
00251     const bool registered6 = TheFunctionFactory::Instance().registerFunction(createzm1, "ComplexFunction");
00252 }
00253 
00255 
00256 class zm2: public ComplexFunction {
00257     public:
00258         zm2 (): ComplexFunction() { }
00259         zm2 (double _umin, double _umax, double _du,
00260              double _vmin, double _vmax, double _dv);
00261         virtual ~zm2 () { }
00262 
00263         virtual std::string getFunctionName() const { return "zm2"; } // "1/z"+ComplexFunction::sup2,
00264 
00265     protected:
00266         virtual function_type g;
00267 };
00268 
00269 namespace {
00270     Displayable *createzm2() { return new zm2(); }
00271     const bool registered7 = TheFunctionFactory::Instance().registerFunction(createzm2, "ComplexFunction");
00272 }
00273 
00275 
00276 class sqrtz: public ComplexFunction {
00277     public:
00278         sqrtz (): ComplexFunction() { }
00279         sqrtz (double _umin, double _umax, double _du,
00280                double _vmin, double _vmax, double _dv);
00281         virtual ~sqrtz () { }
00282 
00283         virtual std::string getFunctionName() const { return "sqrtz"; }
00284 
00285     protected:
00286         virtual function_type g;
00287 };
00288 
00289 namespace {
00290     Displayable *createsqrtz() { return new sqrtz(); }
00291     const bool registered8 = TheFunctionFactory::Instance().registerFunction(createsqrtz, "ComplexFunction");
00292 }
00293 
00295 
00296 class lnz: public ComplexFunction {
00297     public:
00298         lnz (): ComplexFunction() { }
00299         lnz (double _umin, double _umax, double _du,
00300              double _vmin, double _vmax, double _dv);
00301         virtual ~lnz () { }
00302 
00303         virtual std::string getFunctionName() const { return "lnz"; }
00304 
00305     protected:
00306         virtual function_type g;
00307 };
00308 
00309 namespace {
00310     Displayable *createlnz() { return new lnz(); }
00311     const bool registered9 = TheFunctionFactory::Instance().registerFunction(createlnz, "ComplexFunction");
00312 }
00313 
00315 
00316 class sinz: public ComplexFunction {
00317     public:
00318         sinz (): ComplexFunction() { }
00319         sinz (double _umin, double _umax, double _du,
00320               double _vmin, double _vmax, double _dv);
00321         virtual ~sinz () { }
00322 
00323         virtual std::string getFunctionName() const { return "sinz"; }
00324 
00325     protected:
00326         virtual function_type g;
00327 };
00328 
00329 namespace {
00330     Displayable *createsinz() { return new sinz(); }
00331     const bool registered10 = TheFunctionFactory::Instance().registerFunction(createsinz, "ComplexFunction");
00332 }
00333 
00335 
00336 class cosz: public ComplexFunction {
00337     public:
00338         cosz (): ComplexFunction() { }
00339         cosz (double _umin, double _umax, double _du,
00340               double _vmin, double _vmax, double _dv);
00341         virtual ~cosz () { }
00342 
00343         virtual std::string getFunctionName() const { return "cosz"; }
00344 
00345     protected:
00346         virtual function_type g;
00347 };
00348 
00349 namespace {
00350     Displayable *createcosz() { return new cosz(); }
00351     const bool registered11 = TheFunctionFactory::Instance().registerFunction(createcosz, "ComplexFunction");
00352 }
00353 
00355 
00356 class sinhz: public ComplexFunction {
00357     public:
00358         sinhz (): ComplexFunction() { }
00359         sinhz (double _umin, double _umax, double _du,
00360                double _vmin, double _vmax, double _dv);
00361         virtual ~sinhz () { }
00362 
00363         virtual std::string getFunctionName() const { return "sinhz"; }
00364 
00365     protected:
00366         virtual function_type g;
00367 };
00368 
00369 namespace {
00370     Displayable *createsinhz() { return new sinhz(); }
00371     const bool registered12 = TheFunctionFactory::Instance().registerFunction(createsinhz, "ComplexFunction");
00372 }
00373 
00375 
00376 class coshz: public ComplexFunction {
00377     public:
00378         coshz (): ComplexFunction() { }
00379         coshz (double _umin, double _umax, double _du,
00380                double _vmin, double _vmax, double _dv);
00381         virtual ~coshz () { }
00382 
00383         virtual std::string getFunctionName() const { return "coshz"; }
00384 
00385     protected:
00386         virtual function_type g;
00387 };
00388 
00389 namespace {
00390     Displayable *createcoshz() { return new coshz(); }
00391     const bool registered13 = TheFunctionFactory::Instance().registerFunction(createcoshz, "ComplexFunction");
00392 }
00393 
00395 
00396 class tanz: public ComplexFunction {
00397     public:
00398         tanz (): ComplexFunction() { }
00399         tanz (double _umin, double _umax, double _du,
00400               double _vmin, double _vmax, double _dv);
00401         virtual ~tanz () { }
00402 
00403         virtual std::string getFunctionName() const { return "tanz"; }
00404 
00405     protected:
00406         virtual function_type g;
00407 };
00408 
00409 namespace {
00410     Displayable *createtanz() { return new tanz(); }
00411     const bool registered14 = TheFunctionFactory::Instance().registerFunction(createtanz, "ComplexFunction");
00412 }
00413 
00415 
00416 class Polynomial: public ComplexFunction {
00417     public:
00418         Polynomial(double _umin, double _umax, double _du,
00419                    double _vmin, double _vmax, double _dv,
00420                    double _a1, double _a2, double _a3, double _a4);
00421         virtual ~Polynomial () { }
00422 
00423     protected:
00424         virtual function_type g;    
00425 
00426     private:
00427         double a[5];                
00428 };
00429 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:15 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo