HermesCommon  3.0
ord.cpp
Go to the documentation of this file.
1 // This file is part of HermesCommon
2 //
3 // Hermes is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes; if not, see <http://www.gnu.prg/licenses/>.
18 #include "ord.h"
19 #include <algorithm>
20 
21 namespace Hermes
22 {
23  Ord::Ord() : order(0) {}
24  Ord::Ord(int o) : order(o) {}
25  Ord::Ord(double o) : order(0) {}
26 
27  int Ord::get_order() const { return order; }
28 
29  Ord Ord::get_max_order() { return Ord(30); }
30 
31  Ord Ord::operator+ (const Ord &o) { return Ord(std::max(this->order, o.order)); }
32  Ord Ord::operator+ (double d) { return *this; }
33  Ord Ord::operator+ (std::complex<double> d) { return *this; }
34  Ord Ord::operator-(const Ord &o) { return Ord(std::max(this->order, o.order)); }
35  Ord Ord::operator-(double d) { return *this; }
36  Ord Ord::operator-(std::complex<double> d) { return *this; }
37  Ord Ord::operator*(const Ord &o) { return Ord(this->order + o.order); }
38  Ord Ord::operator*(double d) { return *this; }
39  Ord Ord::operator*(std::complex<double> d) { return *this; }
40  Ord Ord::operator/(const Ord &o) { return Ord::get_max_order(); }
41  Ord Ord::operator/(double d) { return *this; }
42  Ord Ord::operator/(std::complex<double> d) { return *this; }
43 
44  Ord Ord::operator+=(const Ord &o) { this->order = std::max(this->order, o.order); return *this; }
45  Ord Ord::operator-=(const Ord &o) { this->order = std::max(this->order, o.order); return *this; }
46 
47  Ord Ord::operator+=(const double &d) { return *this; }
48  Ord Ord::operator+=(const std::complex<double> &d) { return *this; }
49  Ord Ord::operator-=(const double &d) { return *this; }
50  Ord Ord::operator-=(const std::complex<double> &d) { return *this; }
51  Ord Ord::operator*=(const double &d) { return *this; }
52  Ord Ord::operator*=(const std::complex<double> &d) { return *this; }
53  Ord Ord::operator/=(const double &d) { return *this; }
54  Ord Ord::operator/=(const std::complex<double> &d) { return *this; }
55 
56  bool Ord::operator<(double d) { return true; }
57  bool Ord::operator<(std::complex<double> d) { return true; }
58  bool Ord::operator>(double d) { return false; }
59  bool Ord::operator>(std::complex<double> d) { return false; }
60  bool Ord::operator<(const Ord &o) { return this->order < o.order; }
61  bool Ord::operator>(const Ord &o) { return this->order > o.order; }
62 
63  Ord operator/(const double &a, const Ord &b) { return Ord::get_max_order(); }
64  Ord operator*(const double &a, const Ord &b) { return b; }
65  Ord operator + (const double &a, const Ord &b) { return b; }
66  Ord operator-(const double &a, const Ord &b) { return b; }
67  Ord operator/(const std::complex<double> &a, const Ord &b) { return Ord::get_max_order(); }
68  Ord operator*(const std::complex<double> &a, const Ord &b) { return b; }
69  Ord operator + (const std::complex<double> &a, const Ord &b) { return b; }
70  Ord operator-(const std::complex<double> &a, const Ord &b) { return b; }
71  Ord operator-(const Ord &a) { return a; }
72 
73  Ord pow(const Ord &a, const double &b) { return Ord((int)ceil(fabs(b)) * a.get_order()); }
74  Ord sqrt(const Ord &a) { return a; }
75  Ord sqr(const Ord &a) { return Ord(2 * a.get_order()); }
76  Ord conj(const Ord &a) { return a; }
77  Ord abs(const Ord &a) { return a; }
78  Ord magn(const Ord &a) { return a; }
79 
80  Ord atan2(const Ord &a, const Ord &b) { return Ord::get_max_order(); }
81  Ord atan(const Ord &a) { return Ord::get_max_order(); }
82  Ord sin(const Ord &a) { return Ord::get_max_order(); }
83  Ord cos(const Ord &a) { return Ord::get_max_order(); }
84  Ord log(const Ord &a) { return Ord::get_max_order(); }
85  Ord exp(const Ord &a) { return Ord(3 * a.get_order()); }
86 }
General namespace for the Hermes library.
Contains class Ord for calculation of integration order.