ScalarMath.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/ScalarMath.h
10 
11 #ifndef __ScalarMath_H
12 #define __ScalarMath_H
13 
14 #include "MEAL/Scalar.h"
15 
16 namespace MEAL {
17 
19  class ScalarMath {
20 
21  public:
22 
24  ScalarMath (double value = 0.0);
25 
27  explicit ScalarMath (const Estimate<double>& value);
28 
30  ScalarMath (const ScalarMath& s);
31 
34 
36  ScalarMath (Scalar& s);
37 
39  const ScalarMath operator = (const ScalarMath& s);
40 
42  const ScalarMath operator += (const ScalarMath& b);
43 
45  const ScalarMath operator -= (const ScalarMath& b);
46 
48  const ScalarMath operator *= (const ScalarMath& b);
49 
51  const ScalarMath operator /= (const ScalarMath& b);
52 
54  double evaluate () const;
55 
57  Estimate<double> get_Estimate () const;
58 
60  Scalar* get_expression () const { return expression; }
61 
62  protected:
63 
66 
67  };
68 
71 
73  const ScalarMath operator + (const ScalarMath& b);
74 
76  const ScalarMath operator + (const ScalarMath& a, const ScalarMath& b);
77 
79  const ScalarMath operator - (const ScalarMath& a, const ScalarMath& b);
80 
82  const ScalarMath operator * (const ScalarMath& a, const ScalarMath& b);
83 
85  const ScalarMath operator / (const ScalarMath& a, const ScalarMath& b);
86 
88  bool operator == (const ScalarMath& a, const ScalarMath& b);
89 
91  bool operator != (const ScalarMath& a, const ScalarMath& b);
92 
94  bool operator < (const ScalarMath& a, const ScalarMath& b);
95 
97  bool operator > (const ScalarMath& a, const ScalarMath& b);
98 
100  bool operator <= (const ScalarMath&, const ScalarMath&);
101 
103  bool operator >= (const ScalarMath&, const ScalarMath&);
104 
106  const ScalarMath pow (const ScalarMath& x, const ScalarMath& y);
107 
109  const ScalarMath sqrt (const ScalarMath& x);
110 
112  const ScalarMath abs (const ScalarMath& x);
113 
115  const ScalarMath sin (const ScalarMath& x);
116 
118  const ScalarMath cos (const ScalarMath& x);
119 
121  const ScalarMath tan (const ScalarMath& x);
122 
124  const ScalarMath sinh (const ScalarMath& x);
125 
127  const ScalarMath cosh (const ScalarMath& x);
128 
130  const ScalarMath tanh (const ScalarMath& x);
131 
133  const ScalarMath erf (const ScalarMath& x);
134 
136  const ScalarMath exp (const ScalarMath& x);
137 
139  const ScalarMath log (const ScalarMath& x);
140 
142  const ScalarMath atanh (const ScalarMath& x);
143 
145  const ScalarMath atan (const ScalarMath& x);
146 
148  const ScalarMath atan2 (const ScalarMath& y, const ScalarMath& x);
149 
151  inline std::ostream&
152  operator << (std::ostream& o, const ScalarMath& sm)
153  {
154  return o << sm.get_Estimate();
155  }
156 }
157 
158 #endif
159 
Abstract base class of unary functions of another Scalar function.
Definition: UnaryScalar.h:26
const ScalarMath exp(const ScalarMath &x)
Return a ScalarMath instance representing exp(x)
Definition: ScalarMath.C:224
Scalar * get_expression() const
Access the expression.
Definition: ScalarMath.h:70
const ScalarMath sinh(const ScalarMath &x)
Return a ScalarMath instance representing sinh(x)
Definition: ScalarMath.C:184
bool operator!=(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluations are not equal.
Definition: ScalarMath.C:135
const ScalarMath tan(const ScalarMath &x)
Return a ScalarMath instance representing tan(x)
Definition: ScalarMath.C:176
void set_arg1(T *model)
Set the first argument to the binary operation.
Definition: BinaryRule.h:76
const ScalarMath operator+(const ScalarMath &b)
Nothing operator.
Definition: ScalarMath.C:125
bool operator<=(const ScalarMath &, const ScalarMath &)
Comparison operator.
Definition: ScalarMath.C:286
const ScalarMath erf(const ScalarMath &x)
Return a ScalarMath instance representing erf(x)
Definition: ScalarMath.C:216
Represents a value with no free parameters.
Definition: Value.h:26
const ScalarMath atan(const ScalarMath &x)
Return a ScalarMath instance representing atan(x)
Definition: ScalarMath.C:248
bool operator<(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluation of a is less than that of b.
Definition: ScalarMath.C:140
ScalarMath(double value=0.0)
Default construct from a scalar value.
Definition: ScalarMath.C:41
The hyperbolic sine of a Scalar function.
Definition: ScalarHypSine.h:24
const ScalarMath log(const ScalarMath &x)
Return a ScalarMath instance representing log(x)
Definition: ScalarMath.C:232
const ScalarMath sin(const ScalarMath &x)
Return a ScalarMath instance representing sin(x)
Definition: ScalarMath.C:160
Reference::To< Scalar > expression
The expression.
Definition: ScalarMath.h:75
const ScalarMath operator/(const ScalarMath &a, const ScalarMath &b)
Return a ScalarMath instance representing a/b.
Definition: ScalarMath.C:113
The hyperbolic cosine of a Scalar function.
Definition: ScalarHypCosine.h:24
The logarithm of a Scalar function.
Definition: ScalarLogarithm.h:24
const ScalarMath pow(const ScalarMath &x, const ScalarMath &y)
Return a ScalarMath instance representing x^y.
Definition: ScalarMath.C:264
bool operator>=(const ScalarMath &, const ScalarMath &)
Comparison operator.
Definition: ScalarMath.C:292
const ScalarMath sqrt(const ScalarMath &x)
Return a ScalarMath instance representing x^.5.
Definition: ScalarMath.C:151
std::ostream & operator<<(std::ostream &o, const ScalarMath &sm)
Useful for quickly printing the values.
Definition: ScalarMath.h:157
const ScalarMath abs(const ScalarMath &x)
Return a ScalarMath instance representing |x|.
Definition: ScalarMath.C:208
The square root of a Scalar function.
Definition: ScalarRoot.h:24
Represents a scalar parameter, .
Definition: ScalarParameter.h:24
const ScalarMath tanh(const ScalarMath &x)
Return a ScalarMath instance representing tanh(x)
Definition: ScalarMath.C:200
Abstract base class of binary functions of two other Scalar functions.
Definition: BinaryScalar.h:26
const ScalarMath operator/=(const ScalarMath &b)
Division operator.
Definition: ScalarMath.C:89
The absolute value of a Scalar function.
Definition: ScalarAbsolute.h:24
The hyperbolic tangent of a Scalar function.
Definition: ScalarHypTangent.h:24
The tangent of a Scalar function.
Definition: ScalarTangent.h:24
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
const ScalarMath operator-(const ScalarMath &b)
Negation operator.
Definition: ScalarMath.C:119
const ScalarMath cosh(const ScalarMath &x)
Return a ScalarMath instance representing cosh(x)
Definition: ScalarMath.C:192
Convenience interface to building expressions from elements.
Definition: ScalarMath.h:24
The inverse hyperbolic tangent of a Scalar function.
Definition: ScalarInverseHypTangent.h:24
const ScalarMath operator+=(const ScalarMath &b)
Addition operator.
Definition: ScalarMath.C:71
The sine of a Scalar function.
Definition: ScalarSine.h:24
The exponential of a Scalar function.
Definition: ScalarExponential.h:24
const ScalarMath atanh(const ScalarMath &x)
Return a ScalarMath instance representing atanh(x)
Definition: ScalarMath.C:240
bool operator>(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluation of a is less than that of b.
Definition: ScalarMath.C:145
const ScalarMath operator=(const ScalarMath &s)
Assignment operator.
Definition: ScalarMath.C:62
const ScalarMath operator*=(const ScalarMath &b)
Multiplication operator.
Definition: ScalarMath.C:83
const ScalarMath cos(const ScalarMath &x)
Return a ScalarMath instance representing cos(x)
Definition: ScalarMath.C:168
Pure virtual base class of scalar functions.
Definition: Scalar.h:24
The tangent of a Scalar function.
Definition: ScalarPower.h:24
The inverse tangent of the ratio of two Scalar functions.
Definition: ScalarInverseTangent2.h:24
const ScalarMath operator*(const ScalarMath &a, const ScalarMath &b)
Return a ScalarMath instance representing a*b.
Definition: ScalarMath.C:107
Estimate< double > get_Estimate() const
Evaluate the expression and its estimated error.
Definition: ScalarMath.C:279
void set_model(T *model)
Set the Function on which the operation will be performed.
Definition: UnaryRule.h:67
The cosine of a Scalar function.
Definition: ScalarCosine.h:24
The inverse tangent of the ratio of two Scalar functions.
Definition: ScalarInverseTangent.h:24
double evaluate() const
Evaluate the expression.
Definition: ScalarMath.C:273
bool operator==(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluations are equal.
Definition: ScalarMath.C:130
const ScalarMath atan2(const ScalarMath &y, const ScalarMath &x)
Return a ScalarMath instance representing tan(y/x)
Definition: ScalarMath.C:255
void set_arg2(T *model)
Set the second argument to the binary operation.
Definition: BinaryRule.h:93
const ScalarMath operator-=(const ScalarMath &b)
Subtraction operator.
Definition: ScalarMath.C:77
The error function of a Scalar function.
Definition: ScalarErrorFunction.h:24

Generated using doxygen 1.8.17