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
16namespace 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
70 const ScalarMath operator - (const ScalarMath& b);
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
Convenience interface to building expressions from elements.
Definition ScalarMath.h:19
const ScalarMath operator/=(const ScalarMath &b)
Division operator.
Definition ScalarMath.C:89
ScalarMath(double value=0.0)
Default construct from a scalar value.
Definition ScalarMath.C:41
Estimate< double > get_Estimate() const
Evaluate the expression and its estimated error.
Definition ScalarMath.C:279
double evaluate() const
Evaluate the expression.
Definition ScalarMath.C:273
Scalar * get_expression() const
Access the expression.
Definition ScalarMath.h:60
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 operator+=(const ScalarMath &b)
Addition operator.
Definition ScalarMath.C:71
const ScalarMath operator-=(const ScalarMath &b)
Subtraction operator.
Definition ScalarMath.C:77
Reference::To< Scalar > expression
The expression.
Definition ScalarMath.h:65
Pure virtual base class of scalar functions.
Definition Scalar.h:20
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16
const ScalarMath log(const ScalarMath &x)
Return a ScalarMath instance representing log(x)
Definition ScalarMath.C:232
bool operator<=(const ScalarMath &, const ScalarMath &)
Comparison operator.
const ScalarMath sin(const ScalarMath &x)
Return a ScalarMath instance representing sin(x)
Definition ScalarMath.C:160
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
bool operator>=(const ScalarMath &, const ScalarMath &)
Comparison operator.
const ScalarMath operator*(const ScalarMath &a, const ScalarMath &b)
Return a ScalarMath instance representing a*b.
Definition ScalarMath.C:107
const ScalarMath atan(const ScalarMath &x)
Return a ScalarMath instance representing atan(x)
Definition ScalarMath.C:248
const ScalarMath cos(const ScalarMath &x)
Return a ScalarMath instance representing cos(x)
Definition ScalarMath.C:168
bool operator==(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluations are equal.
Definition ScalarMath.C:130
const ScalarMath pow(const ScalarMath &x, const ScalarMath &y)
Return a ScalarMath instance representing x^y.
Definition ScalarMath.C:264
const ScalarMath operator/(const ScalarMath &a, const ScalarMath &b)
Return a ScalarMath instance representing a/b.
Definition ScalarMath.C:113
const ScalarMath sqrt(const ScalarMath &x)
Return a ScalarMath instance representing x^.5.
Definition ScalarMath.C:151
const ScalarMath atan2(const ScalarMath &y, const ScalarMath &x)
Return a ScalarMath instance representing tan(y/x)
Definition ScalarMath.C:255
const ScalarMath exp(const ScalarMath &x)
Return a ScalarMath instance representing exp(x)
Definition ScalarMath.C:224
std::ostream & operator<<(std::ostream &o, const ScalarMath &sm)
Useful for quickly printing the values.
Definition ScalarMath.h:152
bool operator!=(const ScalarMath &a, const ScalarMath &b)
Return true if the expression evaluations are not equal.
Definition ScalarMath.C:135
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 &b)
Negation operator.
Definition ScalarMath.C:119
const ScalarMath operator+(const ScalarMath &b)
Nothing operator.
Definition ScalarMath.C:125
const ScalarMath tanh(const ScalarMath &x)
Return a ScalarMath instance representing tanh(x)
Definition ScalarMath.C:200
const ScalarMath abs(const ScalarMath &x)
Return a ScalarMath instance representing |x|.
Definition ScalarMath.C:208
const ScalarMath atanh(const ScalarMath &x)
Return a ScalarMath instance representing atanh(x)
Definition ScalarMath.C:240
const ScalarMath erf(const ScalarMath &x)
Return a ScalarMath instance representing erf(x)
Definition ScalarMath.C:216
const ScalarMath cosh(const ScalarMath &x)
Return a ScalarMath instance representing cosh(x)
Definition ScalarMath.C:192
const ScalarMath sinh(const ScalarMath &x)
Return a ScalarMath instance representing sinh(x)
Definition ScalarMath.C:184
const ScalarMath tan(const ScalarMath &x)
Return a ScalarMath instance representing tan(x)
Definition ScalarMath.C:176

Generated using doxygen 1.14.0