Elements  6.2
A C++ base framework for the Euclid Software.
PiCalculator.cpp
Go to the documentation of this file.
1 
19 
20 namespace Elements {
21 namespace Examples {
22 
23 void PiCalculator::calculate(unsigned int terms) {
24 
25  double pi = 0.0;
26  // Leibniz formula for pi
27  double numerator = -1.0;
28  double denominator = -1.0;
29 
30  for (unsigned int ii = 0; ii < terms; ++ii) {
31  numerator *= -1;
32  denominator += 2.0;
33  pi += numerator / denominator;
34  }
35 
36  pi *= 4.0;
37 
39 }
40 
41 void PiCalculator::setShowResultCallback(show_result_callback_type f) {
42 
44 }
45 
46 } // namespace Examples
47 } // namespace Elements
Elements::Examples::PiCalculator::setShowResultCallback
void setShowResultCallback(show_result_callback_type f)
Definition: PiCalculator.cpp:41
Elements::Examples::PiCalculator::calculate
void calculate(unsigned int terms)
Definition: PiCalculator.cpp:23
Elements::Kernel::Units::pi
constexpr double pi
Definition: MathConstants.h:34
PiCalculator.h
Elements::Examples::PiCalculator::m_show_result_callback
show_result_callback_type m_show_result_callback
Definition: PiCalculator.h:41
Elements
Definition: callBackExample.h:35