diff --git a/annotated.html b/annotated.html index bdb63a1a3..4e6a4691b 100644 --- a/annotated.html +++ b/annotated.html @@ -172,7 +172,6 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  NmathFor IO operations  Nncr_modulo_p  CNCRModuloPClass which contains all methods required for calculating nCr mod p - CPoint  Noperations_on_datastructuresFor std::vector  Ncircular_linked_list  CCircularLinkedListA class that implements a Circular Linked List @@ -229,8 +228,8 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  Cbst_nodeA struct to represent a node in the Binary Search Tree  CBtree  Ccll - CCompareComparator class for priority queue - Ccompare + Ccompare + CCompareComparator class for priority queue  CComplexClass Complex to represent complex numbers as a field  CCycleCheck  Cdouble_linked_list @@ -253,8 +252,8 @@ $(document).ready(function(){initNavTree('annotated.html',''); initResizable();  CNode  CPoint  Cquery - CQueue - Cqueue + Cqueue + CQueue  CRBtree  CSegmentIntersection  CSolution diff --git a/annotated_dup.js b/annotated_dup.js index cccb65c67..92495cdcc 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -94,8 +94,7 @@ var annotated_dup = [ "math", "dd/d47/namespacemath.html", [ [ "ncr_modulo_p", null, [ [ "NCRModuloP", "d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html", "d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p" ] - ] ], - [ "Point", "de/d4f/structmath_1_1_point.html", null ] + ] ] ] ], [ "operations_on_datastructures", "da/d6d/namespaceoperations__on__datastructures.html", [ [ "circular_linked_list", null, [ @@ -173,8 +172,8 @@ var annotated_dup = [ "binary_search_tree", "d9/dde/classbinary__search__tree.html", "d9/dde/classbinary__search__tree" ], [ "Btree", "d9/d90/struct_btree.html", null ], [ "cll", "d5/d15/classcll.html", null ], - [ "Compare", "de/d4a/class_compare.html", "de/d4a/class_compare" ], [ "compare", "d1/db3/structcompare.html", null ], + [ "Compare", "de/d4a/class_compare.html", "de/d4a/class_compare" ], [ "Complex", "da/d5a/class_complex.html", "da/d5a/class_complex" ], [ "CycleCheck", "d3/dbb/class_cycle_check.html", "d3/dbb/class_cycle_check" ], [ "double_linked_list", "d9/dee/classdouble__linked__list.html", null ], @@ -197,8 +196,8 @@ var annotated_dup = [ "Node", "db/d8b/struct_node.html", null ], [ "Point", "d8/dc8/struct_point.html", "d8/dc8/struct_point" ], [ "query", "dd/d1b/structquery.html", null ], - [ "Queue", "dc/db5/struct_queue.html", null ], [ "queue", "db/da9/classqueue.html", "db/da9/classqueue" ], + [ "Queue", "dc/db5/struct_queue.html", null ], [ "RBtree", "d8/d72/class_r_btree.html", null ], [ "SegmentIntersection", "d4/db4/struct_segment_intersection.html", "d4/db4/struct_segment_intersection" ], [ "Solution", "dd/d4f/class_solution.html", null ], diff --git a/classes.html b/classes.html index 6d7d62263..bac62953b 100644 --- a/classes.html +++ b/classes.html @@ -110,7 +110,7 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
binary_search_tree
BinaryTree (operations_on_datastructures::reverse_binary_tree)
BinaryTree (others::iterative_tree_traversals)
Bitset (data_structures)
BloomFilter (data_structures)
binary_search_tree::bst_node
BT (others::recursive_tree_traversals)
Btree
C
-
CircularLinkedList (operations_on_datastructures::circular_linked_list)
cll
Compare
compare
AyStarSearch::comparison_operator (machine_learning::aystar_search)
Complex
Convexhull (geometry::jarvis)
CycleCheck
+
CircularLinkedList (operations_on_datastructures::circular_linked_list)
cll
compare
Compare
AyStarSearch::comparison_operator (machine_learning::aystar_search)
Complex
Convexhull (geometry::jarvis)
CycleCheck
D
DenseLayer (machine_learning::neural_network::layers)
double_linked_list
dsu
@@ -143,10 +143,10 @@ $(document).ready(function(){initNavTree('classes.html',''); initResizable(); })
NCRModuloP (math::ncr_modulo_p)
NeuralNetwork (machine_learning::neural_network)
Node (data_structures::linked_list)
Node (data_structures)
Node (data_structures::tree_234)
Trie::Node (data_structures::trie_using_hashmap)
node
Node
Node (operations_on_datastructures::circular_linked_list)
Node (operations_on_datastructures::inorder_traversal_of_bst)
Node (operations_on_datastructures::reverse_binary_tree)
Node (others::iterative_tree_traversals)
Node (others::recursive_tree_traversals)
perSegTree::Node (range_queries)
Node (search::sublist_search)
P
-
pattern (strings::boyer_moore)
perSegTree (range_queries)
Point (ciphers::elliptic_curve_key_exchange)
Point (geometry::grahamscan)
Point (geometry::jarvis)
Point (math)
Point
+
pattern (strings::boyer_moore)
perSegTree (range_queries)
Point (ciphers::elliptic_curve_key_exchange)
Point (geometry::grahamscan)
Point (geometry::jarvis)
Point
Q
-
query
Queue
queue
Queue_Array (data_structures::queue_using_array)
+
query
queue
Queue
Queue_Array (data_structures::queue_using_array)
R
RBtree
RootedTree (graph)
diff --git a/d0/d51/approximate__pi_8cpp.html b/d0/d51/approximate__pi_8cpp.html index 93ccddec0..1674829a3 100644 --- a/d0/d51/approximate__pi_8cpp.html +++ b/d0/d51/approximate__pi_8cpp.html @@ -98,53 +98,64 @@ $(document).ready(function(){initNavTree('d0/d51/approximate__pi_8cpp.html','../
-Classes | Namespaces | -Functions
+Typedefs | +Functions | +Variables
approximate_pi.cpp File Reference

Implementation to calculate an estimate of the number π (Pi). More...

-
#include <iostream>
-#include <vector>
+
#include <cassert>
#include <cstdlib>
+#include <iostream>
+#include <vector>
Include dependency graph for approximate_pi.cpp:
-
+
- - - -

-Classes

struct  math::Point
 

Namespaces

namespace  math
 for IO operations
 
+ + + + +

+Typedefs

+using math::Point = { double x
 structure of points containing two numbers, x and y, such that 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1.
 
- + + - - - - - - + + + + + + +

Functions

double math::approximate_pi (const std::vector< Point > &pts)
double math::approximate_pi (const std::vector< Point > &pts)
 This function uses the points in a given vector 'pts' (drawn at random) to return an approximation of the number π.
 
static void test ()
 Self-test implementations.
 
int main (int argc, char *argv[])
 Main function.
 
static void tests ()
 Self-test implementations.
 
int main ()
 Main function.
 
+ + +

+Variables

+double math::y
 

Detailed Description

Implementation to calculate an estimate of the number π (Pi).

-

We take a random point P with coordinates (x, y) such that 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1. If x² + y² ≤ 1, then the point is inside the quarter disk of radius 1, otherwise the point is outside. We know that the probability of the point being inside the quarter disk is equal to π/4 double approx(vector<Point> &pts) which will use the points pts (drawn at random) to return an estimate of the number π

Note
This implementation is better than naive recursive or iterative approach.
+

We take a random point P with coordinates (x, y) such that 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1. If x² + y² ≤ 1, then the point is inside the quarter disk of radius 1, else the point is outside. We know that the probability of the point being inside the quarter disk is equal to π/4 double approx(vector<Point> &pts) which will use the points pts (drawn at random) to return an estimate of the number π

Note
This implementation is better than naive recursive or iterative approach.
Author
Qannaf AL-SAHMI

Function Documentation

- -

◆ main()

+ +

◆ main()

@@ -152,47 +163,30 @@ Functions int main ( - int  - argc, - - - + void  + ) - char *  - argv[]  - - - - ) -

Main function.

-
Parameters
- - - -
argccommandline argument count (ignored)
argvcommandline array of arguments (ignored)
-
-
Returns
0 on exit
-
75 {
-
76 test(); // run self-test implementations
-
77 return 0;
-
78}
-
static void test()
Self-test implementations.
Definition approximate_pi.cpp:58
+
80 {
+
81 tests(); // run self-test implementations
+
82 return 0;
+
83}
+
static void tests()
Self-test implementations.
Definition approximate_pi.cpp:62
Here is the call graph for this function:
-
+
- -

◆ test()

+ +

◆ tests()

@@ -201,7 +195,7 @@ Here is the call graph for this function:
- + @@ -216,28 +210,31 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
58 {
- -
60 for (std::size_t i = 0; i < 100000; i++) {
- -
62 p.x = rand() / (double)RAND_MAX; // 0 <= x <= 1
-
63 p.y = rand() / (double)RAND_MAX; // 0 <= y <= 1
-
64 rands.push_back(p);
-
65 }
-
66 std::cout << math::approximate_pi(rands) << std::endl; // ~3.14
-
67}
+
62 {
+ +
64 for (std::size_t i = 0; i < 100000; i++) {
+ +
66 p.x = rand() / static_cast<double>(RAND_MAX); // 0 <= x <= 1
+
67 p.y = rand() / static_cast<double>(RAND_MAX); // 0 <= y <= 1
+
68 rands.push_back(p);
+
69 }
+
70 assert(math::approximate_pi(rands) > 3.135);
+
71 assert(math::approximate_pi(rands) < 3.145);
+
72
+
73 std::cout << "All tests have successfully passed!" << std::endl;
+
74}
T endl(T... args)
-
double approximate_pi(const std::vector< Point > &pts)
Definition approximate_pi.cpp:35
+
{ double x Point
structure of points containing two numbers, x and y, such that 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1.
Definition approximate_pi.cpp:36
+
double approximate_pi(const std::vector< Point > &pts)
This function uses the points in a given vector 'pts' (drawn at random) to return an approximation of...
Definition approximate_pi.cpp:47
T push_back(T... args)
T rand(T... args)
-
Definition approximate_pi.cpp:30
Here is the call graph for this function:
-
+
diff --git a/d0/d51/approximate__pi_8cpp.js b/d0/d51/approximate__pi_8cpp.js index 3f66d708c..c85844089 100644 --- a/d0/d51/approximate__pi_8cpp.js +++ b/d0/d51/approximate__pi_8cpp.js @@ -1,7 +1,7 @@ var approximate__pi_8cpp = [ - [ "math::Point", "de/d4f/structmath_1_1_point.html", null ], + [ "Point", "d0/d51/approximate__pi_8cpp.html#a937dc0c826acf3e6c0d2785527f7e9d7", null ], [ "approximate_pi", "d0/d51/approximate__pi_8cpp.html#abf7f2a6d91f1ca6c89698792aea3f188", null ], - [ "main", "d0/d51/approximate__pi_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97", null ], - [ "test", "d0/d51/approximate__pi_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] + [ "main", "d0/d51/approximate__pi_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "tests", "d0/d51/approximate__pi_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e", null ] ]; \ No newline at end of file diff --git a/d0/d51/approximate__pi_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 b/d0/d51/approximate__pi_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 deleted file mode 100644 index d2eec5588..000000000 --- a/d0/d51/approximate__pi_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 +++ /dev/null @@ -1 +0,0 @@ -38adabce757fd6da14773ccf09b11611 \ No newline at end of file diff --git a/d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.map similarity index 54% rename from d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map rename to d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.map index 1f3ca7336..7e68b6dc3 100644 --- a/d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map +++ b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.map @@ -1,11 +1,11 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.md5 b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.md5 new file mode 100644 index 000000000..e4c54be20 --- /dev/null +++ b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.md5 @@ -0,0 +1 @@ +b5dab79a48fcf8352434c9ccc43e128f \ No newline at end of file diff --git a/d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg similarity index 59% rename from d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg rename to d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg index 2bb515f99..f2ff79e42 100644 --- a/d0/d51/approximate__pi_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg +++ b/d0/d51/approximate__pi_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg @@ -3,9 +3,9 @@ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> - - + +
static void test static void tests ( )