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 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_STEM_FUNCTION
00026 #define EIGEN_STEM_FUNCTION
00027 
00031 template <typename Scalar>
00032 class StdStemFunctions
00033 {
00034   public:
00035 
00037     static Scalar exp(Scalar x, int)
00038     {
00039       return std::exp(x);
00040     }
00041 
00043     static Scalar cos(Scalar x, int n)
00044     {
00045       Scalar res;
00046       switch (n % 4) {
00047       case 0: 
00048         res = std::cos(x);
00049         break;
00050       case 1:
00051         res = -std::sin(x);
00052         break;
00053       case 2:
00054         res = -std::cos(x);
00055         break;
00056       case 3:
00057         res = std::sin(x);
00058         break;
00059       }
00060       return res;
00061     }
00062 
00064     static Scalar sin(Scalar x, int n)
00065     {
00066       Scalar res;
00067       switch (n % 4) {
00068       case 0:
00069         res = std::sin(x);
00070         break;
00071       case 1:
00072         res = std::cos(x);
00073         break;
00074       case 2:
00075         res = -std::sin(x);
00076         break;
00077       case 3:
00078         res = -std::cos(x);
00079         break;
00080       }
00081       return res;
00082     }
00083 
00085     static Scalar cosh(Scalar x, int n)
00086     {
00087       Scalar res;
00088       switch (n % 2) {
00089       case 0:
00090         res = std::cosh(x);
00091         break;
00092       case 1:
00093         res = std::sinh(x);
00094         break;
00095       }
00096       return res;
00097     }
00098         
00100     static Scalar sinh(Scalar x, int n)
00101     {
00102       Scalar res;
00103       switch (n % 2) {
00104       case 0:
00105         res = std::sinh(x);
00106         break;
00107       case 1:
00108         res = std::cosh(x);
00109         break;
00110       }
00111       return res;
00112     }
00113 
00114 }; // end of class StdStemFunctions
00115 
00116 #endif // EIGEN_STEM_FUNCTION


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:33:40