Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2004 Sandia Corporation and Argonne National
5 : : Laboratory. Under the terms of Contract DE-AC04-94AL85000
6 : : with Sandia Corporation, the U.S. Government retains certain
7 : : rights in this software.
8 : :
9 : : This library is free software; you can redistribute it and/or
10 : : modify it under the terms of the GNU Lesser General Public
11 : : License as published by the Free Software Foundation; either
12 : : version 2.1 of the License, or (at your option) any later version.
13 : :
14 : : This library is distributed in the hope that it will be useful,
15 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : Lesser General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License
20 : : (lgpl.txt) along with this library; if not, write to the Free Software
21 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : :
23 : : [email protected], [email protected], [email protected],
24 : : [email protected], [email protected], [email protected],
25 : : [email protected]
26 : :
27 : : ***************************************************************** */
28 : : /*!
29 : : \file Exponent.hpp
30 : : \brief
31 : :
32 : : \author Jason Kraftcheck
33 : : \date 2005-5-2
34 : : */
35 : :
36 : : #ifndef MESQUITE_POWER_HPP
37 : : #define MESQUITE_POWER_HPP
38 : :
39 : : #include "Mesquite.hpp"
40 : :
41 : : namespace MBMesquite
42 : : {
43 : :
44 : : class Exponent
45 : : {
46 : : public:
47 : : typedef double ( Exponent::*constMemberPtr )( double ) const;
48 : : static constMemberPtr get_func_ptr( double exponent );
49 : :
50 : 318 : Exponent() : funcPointer( 0 ) {}
51 : :
52 : 292 : explicit Exponent( double exponent ) : mExponent( exponent ), funcPointer( get_func_ptr( exponent ) ) {}
53 : :
54 : 22269927 : inline double raise( double p_value ) const
55 : : {
56 [ + - ]: 22269927 : return ( this->*funcPointer )( p_value );
57 : : }
58 : :
59 : : void set_exponent( double exponent );
60 : :
61 : 318 : inline Exponent& operator=( double d )
62 : : {
63 : 318 : set_exponent( d );
64 : 318 : return *this;
65 : : }
66 : :
67 : : // inline operator double () const
68 : : // { return mExponent; }
69 : 4785503 : inline double value() const
70 : : {
71 : 4785503 : return mExponent;
72 : : }
73 : :
74 : : double pow0( double x ) const;
75 : : double pow1( double x ) const;
76 : : double squareRoot( double x ) const;
77 : : double cubeRoot( double x ) const;
78 : : double invCubeRoot( double x ) const;
79 : : double powTwoThirds( double x ) const;
80 : : double invTwoThirds( double x ) const;
81 : : double pow2( double x ) const;
82 : : double powPositiveInt( double x ) const;
83 : : double std_pow( double x ) const;
84 : : double inverse( double x ) const;
85 : : double invSquareRoot( double x ) const;
86 : : double powThreeHalves( double x ) const;
87 : : double invSquare( double x ) const;
88 : : double powNegativeInt( double x ) const;
89 : :
90 : : private:
91 : : double mExponent;
92 : : constMemberPtr funcPointer;
93 : : };
94 : :
95 : : } // namespace MBMesquite
96 : :
97 : : #endif
|