The CyMeAlg Software (Release 0.01)
dummyrnd.h
Go to the documentation of this file.
1 /// @addtogroup cymealg
2 /// @{
3 
4 /////////////////////////////////////////////////////////////////////////////
5 ///
6 /// @file
7 ///
8 /// This header file contains the definition of a dummy rounding class.
9 ///
10 /// @author Pawel Pilarczyk
11 ///
12 /////////////////////////////////////////////////////////////////////////////
13 
14 // Copyright (C) 1997-2020 by Pawel Pilarczyk.
15 //
16 // This file is part of my research software. This is free software:
17 // you can redistribute it and/or modify it under the terms of the GNU
18 // General Public License as published by the Free Software Foundation,
19 // either version 3 of the License, or (at your option) any later version.
20 //
21 // This software is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this software; see the file "license.txt". If not,
28 // please, see <http://www.gnu.org/licenses/>.
29 
30 // Started in January 2006. Last revision: August 23, 2019.
31 
32 
33 #ifndef _CYMEALG_DUMMYRND_H_
34 #define _CYMEALG_DUMMYRND_H_
35 
36 namespace cymealg {
37 
38 // --------------------------------------------------
39 // ----------------- DUMMY ROUNDING -----------------
40 // --------------------------------------------------
41 
42 /// A dummy class for rounding operations which does not actually do
43 /// any rounding. Please, use it as a template for your own rounding classes.
44 template <class numType>
46 {
47 public:
48  /// Adds two numbers with the result rounded downwards.
49  static inline numType add_down (const numType &x, const numType &y)
50  { return x + y; }
51 
52  /// Adds two numbers with the result rounded upwards.
53  static inline numType add_up (const numType &x, const numType &y)
54  { return x + y; }
55 
56  /// Subtracts two numbers with the result rounded downwards.
57  static inline numType sub_down (const numType &x, const numType &y)
58  { return x - y; }
59 
60  /// Subtracts two numbers with the result rounded upwards.
61  static inline numType sub_up (const numType &x, const numType &y)
62  { return x - y; }
63 
64  /// Multiplies two numbers with the result rounded downwards.
65  static inline numType mul_down (const numType &x, const numType &y)
66  { return x * y; }
67 
68  /// Multiplies two numbers with the result rounded upwards.
69  static inline numType mul_up (const numType &x, const numType &y)
70  { return x * y; }
71 
72  /// Divides two numbers with the result rounded downwards.
73  static inline numType div_down (const numType &x, const numType &y)
74  { return x / y; }
75 
76  /// Divides a number by an integer with the result rounded downwards.
77  static inline numType div_down (const numType &x, int_t y)
78  { return x / y; }
79 
80  /// Divides two numbers with the result rounded upwards.
81  static inline numType div_up (const numType &x, const numType &y)
82  { return x / y; }
83 
84 private:
85 }; /* class dummyRounding */
86 
87 
88 } // namespace cymealg
89 
90 #endif // _CYMEALG_DUMMYRND_H_
91 
92 /// @}
93 
static numType sub_down(const numType &x, const numType &y)
Subtracts two numbers with the result rounded downwards.
Definition: dummyrnd.h:57
static numType div_down(const numType &x, int_t y)
Divides a number by an integer with the result rounded downwards.
Definition: dummyrnd.h:77
static numType sub_up(const numType &x, const numType &y)
Subtracts two numbers with the result rounded upwards.
Definition: dummyrnd.h:61
static numType div_down(const numType &x, const numType &y)
Divides two numbers with the result rounded downwards.
Definition: dummyrnd.h:73
static numType add_up(const numType &x, const numType &y)
Adds two numbers with the result rounded upwards.
Definition: dummyrnd.h:53
A dummy class for rounding operations which does not actually do any rounding.
Definition: dummyrnd.h:45
static numType mul_down(const numType &x, const numType &y)
Multiplies two numbers with the result rounded downwards.
Definition: dummyrnd.h:65
static numType mul_up(const numType &x, const numType &y)
Multiplies two numbers with the result rounded upwards.
Definition: dummyrnd.h:69
static numType add_down(const numType &x, const numType &y)
Adds two numbers with the result rounded downwards.
Definition: dummyrnd.h:49
static numType div_up(const numType &x, const numType &y)
Divides two numbers with the result rounded upwards.
Definition: dummyrnd.h:81