NETGeographicLib  1.51
Accumulator.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/Accumulator.h
4  * \brief Header for NETGeographicLib::Accumulator class
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * https://geographiclib.sourceforge.io/
11  **********************************************************************/
12 
14 {
15  /*!
16  \brief .NET wrapper for GeographicLib::Accumulator.
17 
18  This class allows .NET applications to access GeographicLib::Accumulator<double>.
19 
20  This allow many numbers of floating point type \e double to be added together
21  with twice the normal precision. The effective
22  precision of the sum is 106 bits or about 32 decimal places.
23 
24  The implementation follows J. R. Shewchuk,
25  <a href="https://doi.org/10.1007/PL00009321"> Adaptive Precision
26  Floating-Point Arithmetic and Fast Robust Geometric Predicates</a>,
27  Discrete & Computational Geometry 18(3) 305--363 (1997).
28 
29  C# Example:
30  \include example-Accumulator.cs
31  Managed C++ Example:
32  \include example-Accumulator.cpp
33  Visual Basic Example:
34  \include example-Accumulator.vb
35 
36  <B>INTERFACE DIFFERENCES:</B><BR>
37  Since assignment operators (=,+=,-=,*=) are not supported in managed classes;
38  - the Assign() method replaces the = operator,
39  - the Sum() method replaces the += and -= operators, and
40  - the Multiply() method replaces the *= operator,
41 
42  Use Result() instead of the () operator to obtain the summed value from the accumulator.
43  */
44  public ref class Accumulator
45  {
46  private:
47  // Pointer to the unmanaged GeographicLib::Accumulator.
48  GeographicLib::Accumulator<double>* m_pAccumulator;
49  // The finalizer releases the unmanaged object when this class is destroyrd.
50  !Accumulator(void);
51  public:
52  //! \brief Constructor.
53  Accumulator(void);
54  //! \brief Destructor calls the finalizer.
55  ~Accumulator() { this->!Accumulator(); }
56  /*!
57  \brief Assigns a value to an accumulator.
58  \param[in] a The value to be assigned.
59  */
60  void Assign( double a );
61  //! \brief Returns the accumulated value.
62  double Result();
63  /*!
64  \brief Adds a value to the accumulator.
65  \param[in] a The value to be added.
66  */
67  void Sum( double a );
68  /*!
69  \brief Multiplication by an integer
70  \param[in] i The multiplier.
71  */
72  void Multiply( int i );
73  /*!
74  \brief Equality operator.
75  \param[in] lhs The accumulator.
76  \param[in] a The value to be compared to.
77  \return true if the accumulated value is equal to a.
78  */
79  static bool operator == ( Accumulator^ lhs, double a );
80  /*!
81  \brief Inequality operator.
82  \param[in] lhs The accumulator.
83  \param[in] a The value to be compared to.
84  \return true if the accumulated value is not equal to a.
85  */
86  static bool operator != ( Accumulator^ lhs, double a );
87  /*!
88  \brief Less than operator.
89  \param[in] lhs The accumulator.
90  \param[in] a The value to be compared to.
91  \return true if the accumulated value is less than a.
92  */
93  static bool operator < ( Accumulator^ lhs, double a );
94  /*!
95  \brief Less than or equal to operator.
96  \param[in] lhs The accumulator.
97  \param[in] a The value to be compared to.
98  \return true if the accumulated value is less than or equal to a.
99  */
100  static bool operator <= ( Accumulator^ lhs, double a );
101  /*!
102  \brief Greater than operator.
103  \param[in] lhs The accumulator.
104  \param[in] a The value to be compared to.
105  \return true if the accumulated value is greater than a.
106  */
107  static bool operator > ( Accumulator^ lhs, double a );
108  /*!
109  \brief Greater than or equal to operator.
110  \param[in] lhs The accumulator.
111  \param[in] a The value to be compared to.
112  \return true if the accumulated value is greater than or equal to a.
113  */
114  static bool operator >= ( Accumulator^ lhs, double a );
115  };
116 } //namespace NETGeographicLib
static bool operator<=(Accumulator^ lhs, double a)
Less than or equal to operator.
void Multiply(int i)
Multiplication by an integer.
static bool operator>(Accumulator^ lhs, double a)
Greater than operator.
double Result()
Returns the accumulated value.
static bool operator<(Accumulator^ lhs, double a)
Less than operator.
~Accumulator()
Destructor calls the finalizer.
Definition: Accumulator.h:55
.NET wrapper for GeographicLib::Accumulator.
Definition: Accumulator.h:44
static bool operator==(Accumulator^ lhs, double a)
Equality operator.
void Sum(double a)
Adds a value to the accumulator.
void Assign(double a)
Assigns a value to an accumulator.
Accumulator(void)
Constructor.
static bool operator>=(Accumulator^ lhs, double a)
Greater than or equal to operator.
static bool operator!=(Accumulator^ lhs, double a)
Inequality operator.