StemFunction.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_STEM_FUNCTION
00011 #define EIGEN_STEM_FUNCTION
00012 
00013 namespace Eigen { 
00014 
00018 template <typename Scalar>
00019 class StdStemFunctions
00020 {
00021   public:
00022 
00024     static Scalar exp(Scalar x, int)
00025     {
00026       return std::exp(x);
00027     }
00028 
00030     static Scalar cos(Scalar x, int n)
00031     {
00032       Scalar res;
00033       switch (n % 4) {
00034       case 0: 
00035         res = std::cos(x);
00036         break;
00037       case 1:
00038         res = -std::sin(x);
00039         break;
00040       case 2:
00041         res = -std::cos(x);
00042         break;
00043       case 3:
00044         res = std::sin(x);
00045         break;
00046       }
00047       return res;
00048     }
00049 
00051     static Scalar sin(Scalar x, int n)
00052     {
00053       Scalar res;
00054       switch (n % 4) {
00055       case 0:
00056         res = std::sin(x);
00057         break;
00058       case 1:
00059         res = std::cos(x);
00060         break;
00061       case 2:
00062         res = -std::sin(x);
00063         break;
00064       case 3:
00065         res = -std::cos(x);
00066         break;
00067       }
00068       return res;
00069     }
00070 
00072     static Scalar cosh(Scalar x, int n)
00073     {
00074       Scalar res;
00075       switch (n % 2) {
00076       case 0:
00077         res = std::cosh(x);
00078         break;
00079       case 1:
00080         res = std::sinh(x);
00081         break;
00082       }
00083       return res;
00084     }
00085         
00087     static Scalar sinh(Scalar x, int n)
00088     {
00089       Scalar res;
00090       switch (n % 2) {
00091       case 0:
00092         res = std::sinh(x);
00093         break;
00094       case 1:
00095         res = std::cosh(x);
00096         break;
00097       }
00098       return res;
00099     }
00100 
00101 }; // end of class StdStemFunctions
00102 
00103 } // end namespace Eigen
00104 
00105 #endif // EIGEN_STEM_FUNCTION


win_eigen
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:12:14