diff --git a/d0/d01/smallest__circle_8cpp.html b/d0/d01/smallest__circle_8cpp.html index 5238f5e29..b84af5d4b 100644 --- a/d0/d01/smallest__circle_8cpp.html +++ b/d0/d01/smallest__circle_8cpp.html @@ -172,28 +172,28 @@ The function returns the radius of the circle and prints the coordinated of the
96 // for every subsequent point in the list
97 for (size_t j = i + 1; j < P.size(); j++)
98 // for every subsequent point in the list
-
99 for (size_t k = j + 1; k < P.size(); k++) {
+
99 for (size_t k = j + 1; k < P.size(); k++) {
100 // here, we now have picked three points from the given set of
101 // points that we can use
102 // viz., P[i], P[j] and P[k]
103 C.x = -0.5 * ((P[i].y * (P[j].x * P[j].x + P[j].y * P[j].y -
-
104 P[k].x * P[k].x - P[k].y * P[k].y) +
+
104 P[k].x * P[k].x - P[k].y * P[k].y) +
105 P[j].y * (P[k].x * P[k].x + P[k].y * P[k].y -
106 P[i].x * P[i].x - P[i].y * P[i].y) +
-
107 P[k].y * (P[i].x * P[i].x + P[i].y * P[i].y -
+
107 P[k].y * (P[i].x * P[i].x + P[i].y * P[i].y -
108 P[j].x * P[j].x - P[j].y * P[j].y)) /
-
109 (P[i].x * (P[j].y - P[k].y) +
+
109 (P[i].x * (P[j].y - P[k].y) +
110 P[j].x * (P[k].y - P[i].y) +
-
111 P[k].x * (P[i].y - P[j].y)));
+
111 P[k].x * (P[i].y - P[j].y)));
112 C.y = 0.5 * ((P[i].x * (P[j].x * P[j].x + P[j].y * P[j].y -
-
113 P[k].x * P[k].x - P[k].y * P[k].y) +
+
113 P[k].x * P[k].x - P[k].y * P[k].y) +
114 P[j].x * (P[k].x * P[k].x + P[k].y * P[k].y -
115 P[i].x * P[i].x - P[i].y * P[i].y) +
-
116 P[k].x * (P[i].x * P[i].x + P[i].y * P[i].y -
+
116 P[k].x * (P[i].x * P[i].x + P[i].y * P[i].y -
117 P[j].x * P[j].x - P[j].y * P[j].y)) /
-
118 (P[i].x * (P[j].y - P[k].y) +
+
118 (P[i].x * (P[j].y - P[k].y) +
119 P[j].x * (P[k].y - P[i].y) +
-
120 P[k].x * (P[i].y - P[j].y)));
+
120 P[k].x * (P[i].y - P[j].y)));
121 R = (LenghtLine(P[i], P[j]) * LenghtLine(P[j], P[k]) *
122 LenghtLine(P[k], P[i])) /
123 (4 * TriangleArea(P[i], P[j], P[k]));
@@ -227,6 +227,7 @@ The function returns the radius of the circle and prints the coordinated of the
151}
std::cout
std::endl
T endl(T... args)
+
numerical_methods::midpoint_rule::k
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
std::vector::size
T size(T... args)
LenghtLine
double LenghtLine(const Point &A, const Point &B)
Definition: smallest_circle.cpp:37
TriangleArea
double TriangleArea(const Point &A, const Point &B, const Point &C)
Definition: smallest_circle.cpp:54
diff --git a/d0/d5a/skip__list_8cpp.html b/d0/d5a/skip__list_8cpp.html index 37206c2f7..ddec41486 100644 --- a/d0/d5a/skip__list_8cpp.html +++ b/d0/d5a/skip__list_8cpp.html @@ -172,7 +172,7 @@ constexpr float data_struc
215 data_structures::SkipList lst;
216
217 for (int j = 0; j < (1 << (data_structures::MAX_LEVEL + 1)); j++) {
-
218 int k = (std::rand() % (1 << (data_structures::MAX_LEVEL + 2)) + 1);
+
218 int k = (std::rand() % (1 << (data_structures::MAX_LEVEL + 2)) + 1);
219 lst.insertElement(k, &j);
220 }
221
@@ -183,6 +183,7 @@ constexpr float data_struc
Definition: skip_list.cpp:55
void insertElement(int key, void *value)
Definition: skip_list.cpp:90
void displayList()
Definition: skip_list.cpp:191
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
constexpr int MAX_LEVEL
Maximum level of skip list.
Definition: skip_list.cpp:27
T rand(T... args)
T srand(T... args)
diff --git a/d1/d2a/knight__tour_8cpp.html b/d1/d2a/knight__tour_8cpp.html index 94504d298..bf2c4e91f 100644 --- a/d1/d2a/knight__tour_8cpp.html +++ b/d1/d2a/knight__tour_8cpp.html @@ -322,15 +322,15 @@ template<size_t V>
false if solution does not exist
58 {
-
59 int k = 0, xnext = 0, ynext = 0;
+
59 int k = 0, xnext = 0, ynext = 0;
60
61 if (mov == V * V) {
62 return true;
63 }
64
-
65 for (k = 0; k < V; k++) {
-
66 xnext = x + xmov[k];
-
67 ynext = y + ymov[k];
+
65 for (k = 0; k < V; k++) {
+
66 xnext = x + xmov[k];
+
67 ynext = y + ymov[k];
68
69 if (issafe<V>(xnext, ynext, sol)) {
70 sol[xnext][ynext] = mov;
@@ -344,6 +344,7 @@ template<size_t V>
78 }
79 return false;
80}
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
void mov(tower *From, tower *To)
Definition: tower_of_hanoi.cpp:39
Here is the call graph for this function:
diff --git a/d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html b/d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html index e9a065578..8c14bb6f7 100644 --- a/d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html +++ b/d1/d51/classrange__queries_1_1heavy__light__decomposition_1_1_tree.html @@ -394,9 +394,9 @@ template<typename X >
118 if (p != -1) {
119 t_depth[u] = 1 + t_depth[p];
120 }
-
121 for (int k = 1; k < t_maxlift; k++) {
+
121 for (int k = 1; k < t_maxlift; k++) {
122 if (t_par[u][k - 1] != -1) {
-
123 t_par[u][k] = t_par[t_par[u][k - 1]][k - 1];
+
123 t_par[u][k] = t_par[t_par[u][k - 1]][k - 1];
124 }
125 }
126
@@ -407,6 +407,7 @@ template<typename X >
131 }
132 }
void dfs_lca(int u, int p=-1)
Utility function to populate the t_par vector.
Definition: heavy_light_decomposition.cpp:116
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
Here is the call graph for this function:
@@ -636,10 +637,10 @@ template<typename X >
237 if (a == b) {
238 return a;
239 }
-
240 for (int k = t_maxlift - 1; k >= 0; k--) {
+
240 for (int k = t_maxlift - 1; k >= 0; k--) {
241 if (t_par[a][k] != t_par[b][k]) {
-
242 a = t_par[a][k];
-
243 b = t_par[b][k];
+
242 a = t_par[a][k];
+
243 b = t_par[b][k];
244 }
245 }
246 return t_par[a][0];
@@ -699,12 +700,12 @@ template<typename X >
Returns
void
200 {
-
201 for (int k = 0; k < t_maxlift; k++) {
+
201 for (int k = 0; k < t_maxlift; k++) {
202 if (*p == -1) {
203 return;
204 }
205 if (dist & 1) {
-
206 *p = t_par[*p][k];
+
206 *p = t_par[*p][k];
207 }
208 dist >>= 1;
209 }
diff --git a/d1/d9a/hopcroft__karp_8cpp.html b/d1/d9a/hopcroft__karp_8cpp.html index e693bb6e4..0b49e8400 100644 --- a/d1/d9a/hopcroft__karp_8cpp.html +++ b/d1/d9a/hopcroft__karp_8cpp.html @@ -180,15 +180,15 @@ Algorithm
309
310 int v1 = 0, v2 = 0, e = 0;
311 std::cin >> v1 >> v2 >> e; // vertices of left side, right side and edges
-
312 HKGraph g(v1, v2);
+
312 HKGraph g(v1, v2);
313 int u = 0, v = 0;
314 for (int i = 0; i < e; ++i)
315 {
316 std::cin >> u >> v;
-
317 g.addEdge(u, v);
+
317 g.addEdge(u, v);
318 }
319
-
320 int res = g.hopcroftKarpAlgorithm();
+
320 int res = g.hopcroftKarpAlgorithm();
321 std::cout << "Maximum matching is " << res <<"\n";
322
323 return 0;
@@ -198,10 +198,11 @@ Algorithm
Represents Bipartite graph for Hopcroft Karp implementation.
Definition: hopcroft_karp.cpp:67
void tests()
Definition: hopcroft_karp.cpp:255
+
double g(double x)
A function g(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:97
Here is the call graph for this function:
-
+
diff --git a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map index 7734b1ff4..102449f77 100644 --- a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map +++ b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -1,8 +1,8 @@ - - - - - - + + + + + + diff --git a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 index b64f3d36c..508e0c48e 100644 --- a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 +++ b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -1 +1 @@ -3cd89b90428da094b5ee440de29552e9 \ No newline at end of file +19b475d234b3dd9cae5b1d90d5b1089f \ No newline at end of file diff --git a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg index 5d1810a40..a0327d4a6 100644 --- a/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg +++ b/d1/d9a/hopcroft__karp_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -4,11 +4,11 @@ - - + + main - + Node1 @@ -21,96 +21,84 @@ Node2 - - -graph::HKGraph::addEdge + + +tests Node1->Node2 - - + + Node3 - + + +graph::HKGraph::addEdge + + + + + +Node2->Node3 + + + + + +Node4 + graph::HKGraph::hopcroft KarpAlgorithm - - -Node1->Node3 - - + + +Node2->Node4 + + - - -Node6 - - -tests - - - - - -Node1->Node6 - - - - - -Node4 - + + +Node5 + graph::HKGraph::bfs - - -Node3->Node4 + + +Node4->Node5 - - -Node5 - + + +Node6 + graph::HKGraph::dfs - - -Node3->Node5 + + +Node4->Node6 - - -Node5->Node5 + + +Node6->Node6 - - -Node6->Node2 - - - - - -Node6->Node3 - - - diff --git a/d1/da6/rungekutta_8cpp.html b/d1/da6/rungekutta_8cpp.html index 7ad7420c2..1e2d248ae 100644 --- a/d1/da6/rungekutta_8cpp.html +++ b/d1/da6/rungekutta_8cpp.html @@ -283,7 +283,7 @@ Here is the call graph for this function:
66
67 auto n = static_cast<uint64_t>((x - init_x) / h);
68 // used a vector container for the variables
-
69 std::vector<double> k(4, 0.0);
+
69 std::vector<double> k(4, 0.0);
70
71 // Iterate for number of iterations
72
@@ -291,10 +291,10 @@ Here is the call graph for this function:
74 for (int i = 1; i <= n; ++i) {
75 // Apply Runge Kutta Formulas
76 // to find next value of y
-
77 k[0] = h * change(init_x, y);
-
78 k[1] = h * change(init_x + 0.5 * h, y + 0.5 * k[0]);
-
79 k[2] = h * change(init_x + 0.5 * h, y + 0.5 * k[1]);
-
80 k[3] = h * change(init_x + h, y + k[2]);
+
77 k[0] = h * change(init_x, y);
+
78 k[1] = h * change(init_x + 0.5 * h, y + 0.5 * k[0]);
+
79 k[2] = h * change(init_x + 0.5 * h, y + 0.5 * k[1]);
+
80 k[3] = h * change(init_x + h, y + k[2]);
81
82 // Update next value of y
83
@@ -308,6 +308,7 @@ Here is the call graph for this function:
91 return y;
92}
int h(int key)
Definition: hash_search.cpp:45
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
static double change(double x, double y)
for using the vector container
Definition: rungekutta.cpp:33
diff --git a/d1/db3/structcompare.html b/d1/db3/structcompare.html index 4a6863498..e26d8a349 100644 --- a/d1/db3/structcompare.html +++ b/d1/db3/structcompare.html @@ -137,8 +137,9 @@ Public Member Functions
31 {
-
32 return (l->freq > r->freq);
+
32 return (l->freq > r->freq);
33 }
+
double l(double x)
A function l(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:109
diff --git a/d1/de0/namespacenumerical__methods.html b/d1/de0/namespacenumerical__methods.html index 8b6f82311..39a6de3d2 100644 --- a/d1/de0/namespacenumerical__methods.html +++ b/d1/de0/namespacenumerical__methods.html @@ -99,8 +99,11 @@ $(document).ready(function(){initNavTree('d1/de0/namespacenumerical__methods.htm

Detailed Description

for io operations

Numerical Methods.

+

for std::map container

for math operations

-

Numerical methods

+

Numerical methods

+

for assert for math functions for integer allocation for std::atof for std::function for IO operations

+

Numerical algorithms/methods

diff --git a/d2/d05/class_min_heap.html b/d2/d05/class_min_heap.html index 42340aa75..0eb53aa47 100644 --- a/d2/d05/class_min_heap.html +++ b/d2/d05/class_min_heap.html @@ -369,7 +369,7 @@ Here is the call graph for this function:
61 // First insert the new key at the end
62 heap_size++;
63 int i = heap_size - 1;
-
64 harr[i] = k;
+
64 harr[i] = k;
65
66 // Fix the min heap property if it is violated
67 while (i != 0 && harr[parent(i)] > harr[i]) {
@@ -378,6 +378,7 @@ Here is the call graph for this function:
70 }
71}
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
Here is the call graph for this function:
@@ -433,11 +434,11 @@ Here is the call graph for this function:

to heapify a subtree with the root at given index

A recursive method to heapify a subtree with the root at given index This method assumes that the subtrees are already heapified

113 {
-
114 int l = left(i);
+
114 int l = left(i);
115 int r = right(i);
116 int smallest = i;
117 if (l < heap_size && harr[l] < harr[i])
-
118 smallest = l;
+
118 smallest = l;
119 if (r < heap_size && harr[r] < harr[smallest])
120 smallest = r;
121 if (smallest != i) {
@@ -447,6 +448,7 @@ Here is the call graph for this function:
125}
int left(int i)
Definition: binaryheap.cpp:31
int right(int i)
Definition: binaryheap.cpp:34
+
double l(double x)
A function l(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:109
Here is the call graph for this function:
diff --git a/d2/d26/count__inversions_8cpp.html b/d2/d26/count__inversions_8cpp.html index db51edf0d..5acbf87e5 100644 --- a/d2/d26/count__inversions_8cpp.html +++ b/d2/d26/count__inversions_8cpp.html @@ -316,14 +316,14 @@ template<typename T >
85 {
86 uint32_t i = left; /* i --> index of left sub-array */
87 uint32_t j = mid + 1; /* j --> index for right sub-array */
-
88 uint32_t k = left; /* k --> index for resultant array temp */
+
88 uint32_t k = left; /* k --> index for resultant array temp */
89 uint32_t inv_count = 0; // inversion count
90
91 while ((i <= mid) && (j <= right)) {
92 if (arr[i] <= arr[j]) {
-
93 temp[k++] = arr[i++];
+
93 temp[k++] = arr[i++];
94 } else {
-
95 temp[k++] = arr[j++];
+
95 temp[k++] = arr[j++];
96 inv_count +=
97 (mid - i +
98 1); // tricky; may vary depending on selection of sub-array
@@ -331,18 +331,19 @@ template<typename T >
100 }
101 // Add remaining elements from the larger subarray to the end of temp
102 while (i <= mid) {
-
103 temp[k++] = arr[i++];
+
103 temp[k++] = arr[i++];
104 }
105 while (j <= right) {
-
106 temp[k++] = arr[j++];
+
106 temp[k++] = arr[j++];
107 }
108 // Copy temp[] to arr[]
-
109 for (k = left; k <= right; k++) {
-
110 arr[k] = temp[k];
+
109 for (k = left; k <= right; k++) {
+
110 arr[k] = temp[k];
111 }
112 return inv_count;
113}
T left(T... args)
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
diff --git a/d2/d3b/namespaceqr__algorithm.html b/d2/d3b/namespaceqr__algorithm.html index 2d849a274..bc4c191b0 100644 --- a/d2/d3b/namespaceqr__algorithm.html +++ b/d2/d3b/namespaceqr__algorithm.html @@ -458,14 +458,15 @@ template<typename T >
197// parallelize on threads
198#pragma omp for
199#endif
-
200 for (int k = i; k < COLUMNS; k++) {
+
200 for (int k = i; k < COLUMNS; k++) {
201 for (int kk = 0; kk < ROWS; kk++) {
-
202 col_vector2[kk] = A[kk][k];
+
202 col_vector2[kk] = A[kk][k];
203 }
-
204 R[0][i][k] = (col_vector * col_vector2).sum();
+
204 R[0][i][k] = (col_vector * col_vector2).sum();
205 }
206 }
207}
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
T sum(const std::vector< std::valarray< T > > &A)
Definition: vector_ops.hpp:232
std::valarray< T > vector_proj(const std::valarray< T > &a, const std::valarray< T > &b)
Definition: qr_decompose.h:104
double vector_mag(const std::valarray< T > &a)
Definition: qr_decompose.h:92
diff --git a/d2/d8a/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d.html b/d2/d8a/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d.html index 685a5f071..b1b312c09 100644 --- a/d2/d8a/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d.html +++ b/d2/d8a/classrange__queries_1_1heavy__light__decomposition_1_1_h_l_d.html @@ -300,10 +300,10 @@ template<typename X >
412 std::swap(a, b);
413 }
414 while (Tree<X>::t_depth[a] >= Tree<X>::t_depth[b]) {
-
415 int l = h_label[h_parent[a]];
+
415 int l = h_label[h_parent[a]];
416 int r = h_label[a];
- +
419 }
420 ret = SG<X>::combine(ret, SG<X>::query(l, r));
421 a = Tree<X>::t_par[h_parent[a]][0];
@@ -318,6 +318,7 @@ template<typename X >
X sret_init
inital query return value
Definition: heavy_light_decomposition.cpp:264
std::vector< int > t_depth
a vector to store the depth of a node,
Definition: heavy_light_decomposition.cpp:88
std::vector< std::vector< int > > t_par
a matrix to store every node's 2^kth parent
Definition: heavy_light_decomposition.cpp:87
+
double l(double x)
A function l(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:109
T swap(T... args)
Here is the call graph for this function:
diff --git a/d3/d40/graph__coloring_8cpp.html b/d3/d40/graph__coloring_8cpp.html index 0f92004f0..bc42f9180 100644 --- a/d3/d40/graph__coloring_8cpp.html +++ b/d3/d40/graph__coloring_8cpp.html @@ -326,7 +326,7 @@ Here is the call graph for this function:

Main function.

Returns
0 on exit

Driver Code

-
Examples
/Users/runner/work/C-Plus-Plus/C-Plus-Plus/numerical_methods/rungekutta.cpp, and /Users/runner/work/C-Plus-Plus/C-Plus-Plus/sorting/wiggle_sort.cpp.
+
Examples
/Users/runner/work/C-Plus-Plus/C-Plus-Plus/numerical_methods/rungekutta.cpp, and /Users/runner/work/C-Plus-Plus/C-Plus-Plus/sorting/wiggle_sort.cpp.
112 {
113 // Create following graph and test whether it is 3 colorable
diff --git a/d3/dfe/horspool_8cpp.html b/d3/dfe/horspool_8cpp.html index 648a0c482..de39bcda5 100644 --- a/d3/dfe/horspool_8cpp.html +++ b/d3/dfe/horspool_8cpp.html @@ -240,13 +240,13 @@ false if text string does not contain prototype string
64 prototype.size() -
65 1); // Index that we shift in text to find the substring
66 while (i < text.size()) {
-
67 int j = i, k = 0;
+
67 int j = i, k = 0;
68 bool flag = true;
69
70 for (int z = static_cast<int>(prototype.size() - 1); z >= 0 && flag;
71 z--) { // Checking if all characters of substring are equal with all characters of string
72 if (text[j] == prototype[z]) {
-
73 k++;
+
73 k++;
74 j--;
75 } else {
76 flag = false; // If two characters are not equal set flag to false and break from loop
@@ -267,6 +267,7 @@ false if text string does not contain prototype string
91 return false;
92}
std::unordered_map< char, int > findShiftTable(const std::string &prototype)
Definition: horspool.cpp:26
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
Here is the call graph for this function:
diff --git a/d4/def/kohonen__som__topology_8cpp.html b/d4/def/kohonen__som__topology_8cpp.html index d5b95cac5..72f06feb2 100644 --- a/d4/def/kohonen__som__topology_8cpp.html +++ b/d4/def/kohonen__som__topology_8cpp.html @@ -317,14 +317,14 @@ Here is the call graph for this function:
379 }
380 if (i < num_out) { // only add new arrays if i < num_out
381 W[i] = std::vector<std::valarray<double>>(num_out);
-
382 for (int k = 0; k < num_out; k++) {
-
383 W[i][k] = std::valarray<double>(features);
+
382 for (int k = 0; k < num_out; k++) {
+
383 W[i][k] = std::valarray<double>(features);
384#ifdef _OPENMP
385#pragma omp for
386#endif
387 for (j = 0; j < features; j++) {
388 // preallocate with random initial weights
-
389 W[i][k][j] = _random(-10, 10);
+
389 W[i][k][j] = _random(-10, 10);
390 }
391 }
392 }
@@ -341,6 +341,7 @@ Here is the call graph for this function:
double _random(double a, double b)
Definition: kohonen_som_topology.cpp:53
void test_2d_classes(std::vector< std::valarray< double > > *data)
Definition: kohonen_som_topology.cpp:330
T max(T... args)
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
int save_u_matrix(const char *fname, const std::vector< std::vector< std::valarray< double > > > &W)
Definition: kohonen_som_topology.cpp:142
void kohonen_som(const std::vector< std::valarray< double > > &X, std::vector< std::vector< std::valarray< double > > > *W, double alpha_min)
Definition: kohonen_som_topology.cpp:269
@@ -386,14 +387,14 @@ Here is the call graph for this function:
461 }
462 if (i < num_out) { // only add new arrays if i < num_out
463 W[i] = std::vector<std::valarray<double>>(num_out);
-
464 for (int k = 0; k < num_out; k++) {
-
465 W[i][k] = std::valarray<double>(features);
+
464 for (int k = 0; k < num_out; k++) {
+
465 W[i][k] = std::valarray<double>(features);
466#ifdef _OPENMP
467#pragma omp for
468#endif
469 for (j = 0; j < features; j++) {
470 // preallocate with random initial weights
-
471 W[i][k][j] = _random(-10, 10);
+
471 W[i][k][j] = _random(-10, 10);
472 }
473 }
474 }
@@ -447,14 +448,14 @@ Here is the call graph for this function:
547 }
548 if (i < num_out) { // only add new arrays if i < num_out
549 W[i] = std::vector<std::valarray<double>>(num_out);
-
550 for (int k = 0; k < num_out; k++) {
-
551 W[i][k] = std::valarray<double>(features);
+
550 for (int k = 0; k < num_out; k++) {
+
551 W[i][k] = std::valarray<double>(features);
552#ifdef _OPENMP
553#pragma omp for
554#endif
555 for (j = 0; j < features; j++) {
556 // preallocate with random initial weights
-
557 W[i][k][j] = _random(-10, 10);
+
557 W[i][k][j] = _random(-10, 10);
558 }
559 }
560 }
diff --git a/d4/df4/classmachine__learning_1_1neural__network_1_1_neural_network.html b/d4/df4/classmachine__learning_1_1neural__network_1_1_neural_network.html index 12fc68cae..36babd947 100644 --- a/d4/df4/classmachine__learning_1_1neural__network_1_1_neural_network.html +++ b/d4/df4/classmachine__learning_1_1neural__network_1_1_neural_network.html @@ -446,13 +446,14 @@ Here is the call graph for this function:
291 std::vector<std::valarray<double>> current_pass = X;
292 details.emplace_back(X);
293 for (const auto &l : layers) {
-
294 current_pass = multiply(current_pass, l.kernel);
-
295 current_pass = apply_function(current_pass, l.activation_function);
+
294 current_pass = multiply(current_pass, l.kernel);
+
295 current_pass = apply_function(current_pass, l.activation_function);
296 details.emplace_back(current_pass);
297 }
298 return details;
299 }
T emplace_back(T... args)
+
double l(double x)
A function l(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:109
std::vector< std::valarray< T > > multiply(const std::vector< std::valarray< T > > &A, const std::vector< std::valarray< T > > &B)
Definition: vector_ops.hpp:460
std::vector< std::valarray< T > > apply_function(const std::vector< std::valarray< T > > &A, T(*func)(const T &))
Definition: vector_ops.hpp:329
diff --git a/d5/d33/gram__schmidt_8cpp.html b/d5/d33/gram__schmidt_8cpp.html index 27caa6c33..41779abf9 100644 --- a/d5/d33/gram__schmidt_8cpp.html +++ b/d5/d33/gram__schmidt_8cpp.html @@ -321,7 +321,7 @@ Here is the call graph for this function:
128 r = c;
129 }
130
-
131 int k = 1;
+
131 int k = 1;
132
133 while (k <= r) {
134 if (k == 1) {
@@ -336,7 +336,7 @@ Here is the call graph for this function:
143 all_projection[i] = 0; /// First initialised to zero
144 }
145
-
146 int l = 1;
+
146 int l = 1;
147 while (l < k) {
149 temp{}; /// to store previous projected array
@@ -344,7 +344,7 @@ Here is the call graph for this function:
151 /// previous array will change
152 factor = projection(A[k - 1], B[l - 1], c);
153 for (int i = 0; i < c; ++i) {
-
154 temp[i] = B[l - 1][i] * factor; /// projected array created
+
154 temp[i] = B[l - 1][i] * factor; /// projected array created
155 }
156 for (int j = 0; j < c; ++j) {
157 all_projection[j] =
@@ -352,21 +352,23 @@ Here is the call graph for this function:
159 temp[j]; /// we take the projection with all the
160 /// previous vector and add them.
161 }
-
162 l++;
+
162 l++;
163 }
164 for (int i = 0; i < c; ++i) {
-
165 B[k - 1][i] =
-
166 A[k - 1][i] -
+
165 B[k - 1][i] =
+
166 A[k - 1][i] -
167 all_projection[i]; /// subtract total projection vector
168 /// from the input vector
169 }
170 }
-
171 k++;
+
171 k++;
172 }
173 display(r, c, B); // for displaying orthogoanlised vectors
174}
double projection(const std::array< double, 10 > &x, const std::array< double, 10 > &y, const int &c)
Definition: gram_schmidt.cpp:79
+
double l(double x)
A function l(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:109
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
Here is the call graph for this function:
diff --git a/d5/d4c/group__sorting.html b/d5/d4c/group__sorting.html index 1c725a45f..f38c7502e 100644 --- a/d5/d4c/group__sorting.html +++ b/d5/d4c/group__sorting.html @@ -415,12 +415,13 @@ template<typename T >
51 arr[k] = R[j];
52 j++;
53 }
-
54 k++;
+
54 k++;
55 }
56
57 delete[] L;
58 delete[] R;
59}
+
double k(double x)
A function k(x) that will be used to test the method.
Definition: midpoint_integral_method.cpp:103
diff --git a/d5/d88/md__d_i_r_e_c_t_o_r_y.html b/d5/d88/md__d_i_r_e_c_t_o_r_y.html index ca3c8f45a..6972e721a 100644 --- a/d5/d88/md__d_i_r_e_c_t_o_r_y.html +++ b/d5/d88/md__d_i_r_e_c_t_o_r_y.html @@ -355,6 +355,7 @@ Numerical Methods
  • Golden Search Extrema
  • Lu Decompose
  • Lu Decomposition
  • +
  • Midpoint Integral Method
  • Newton Raphson Method
  • Ode Forward Euler
  • Ode Midpoint Euler
  • diff --git a/d5/d96/md5_8cpp.html b/d5/d96/md5_8cpp.html index 4c37940ad..d0745bf06 100644 --- a/d5/d96/md5_8cpp.html +++ b/d5/d96/md5_8cpp.html @@ -348,19 +348,19 @@ Here is the call graph for this function:
    235
    236 // Main "hashing" loop
    237 for (uint8_t i = 0; i < 64; i++) {
    -
    238 uint32_t F = 0, g = 0;
    +
    238 uint32_t F = 0, g = 0;
    239 if (i < 16) {
    240 F = (B & C) | ((~B) & D);
    -
    241 g = i;
    +
    241 g = i;
    242 } else if (i < 32) {
    243 F = (D & B) | ((~D) & C);
    -
    244 g = (5 * i + 1) % 16;
    +
    244 g = (5 * i + 1) % 16;
    245 } else if (i < 48) {
    246 F = B ^ C ^ D;
    -
    247 g = (3 * i + 5) % 16;
    +
    247 g = (3 * i + 5) % 16;
    248 } else {
    249 F = C ^ (B | (~D));
    -
    250 g = (7 * i) % 16;
    +
    250 g = (7 * i) % 16;
    251 }
    252
    253 // Update the accumulators
    @@ -397,6 +397,7 @@ Here is the call graph for this function:
    uint32_t toLittleEndian32(uint32_t n)
    Sets 32-bit integer to little-endian if needed.
    Definition: md5.cpp:89
    uint64_t toLittleEndian64(uint64_t n)
    Sets 64-bit integer to little-endian if needed.
    Definition: md5.cpp:102
    uint32_t leftRotate32bits(uint32_t n, std::size_t rotate)
    Rotates the bits of a 32-bit unsigned integer.
    Definition: md5.cpp:66
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    Here is the call graph for this function:
    diff --git a/d5/def/stairs__pattern_8cpp.html b/d5/def/stairs__pattern_8cpp.html index 428569d87..7e431b9b5 100644 --- a/d5/def/stairs__pattern_8cpp.html +++ b/d5/def/stairs__pattern_8cpp.html @@ -140,7 +140,7 @@ Functions

    main function

    17 {
    -
    18 int l, st = 2, x, r, z, n, sp;
    +
    18 int l, st = 2, x, r, z, n, sp;
    19 std::cout << "enter Index ";
    20 std::cin >> x;
    21 z = x;
    @@ -150,7 +150,7 @@ Functions
    25 for (sp = 1; sp <= z; sp++) {
    26 std::cout << " ";
    27 }
    -
    28 for (l = 1; l <= st; l++) {
    +
    28 for (l = 1; l <= st; l++) {
    29 std::cout << "*";
    30 }
    @@ -161,6 +161,7 @@ Functions
    T endl(T... args)
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    Here is the call graph for this function:
    diff --git a/d6/d7a/golden__search__extrema_8cpp.html b/d6/d7a/golden__search__extrema_8cpp.html index d1d029c26..8cabbb498 100644 --- a/d6/d7a/golden__search__extrema_8cpp.html +++ b/d6/d7a/golden__search__extrema_8cpp.html @@ -215,7 +215,7 @@ Functions
    51 c = lim_b - ratio; // right-side section start
    52 d = lim_a + ratio; // left-side section end
    53
    -
    54 if (f(c) < f(d)) {
    +
    54 if (f(c) < f(d)) {
    55 // select left section
    56 lim_b = d;
    57 } else {
    @@ -235,6 +235,7 @@ Functions
    #define EPSILON
    solution accuracy limit
    Definition: golden_search_extrema.cpp:17
    T infinity(T... args)
    +
    double f(double x)
    A function f(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:90
    T sqrt(T... args)
    T swap(T... args)
    diff --git a/d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html b/d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html index abd2eebe8..2d7c4d48d 100644 --- a/d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html +++ b/d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html @@ -284,7 +284,7 @@ Here is the call graph for this function:

    @params[in] the numbers 'a' and 'm' from above equation

    Returns
    the modular inverse of a
    76 {
    77 int64_t x = 0, y = 0;
    -
    78 uint64_t g = gcdExtended(a, m, &x, &y);
    +
    78 uint64_t g = gcdExtended(a, m, &x, &y);
    79 if (g != 1) { // modular inverse doesn't exist
    80 return -1;
    81 } else {
    @@ -292,6 +292,7 @@ Here is the call graph for this function:
    83 return res;
    84 }
    85 }
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    Here is the call graph for this function:
    diff --git a/d8/d72/class_r_btree.html b/d8/d72/class_r_btree.html index 5159572be..6fde7d549 100644 --- a/d8/d72/class_r_btree.html +++ b/d8/d72/class_r_btree.html @@ -521,18 +521,18 @@ Private Attributes
    77 }
    78 while (t->parent != NULL && t->parent->color == 'r')
    79 {
    -
    80 node *g = t->parent->parent;
    -
    81 if (g->left == t->parent)
    +
    80 node *g = t->parent->parent;
    +
    81 if (g->left == t->parent)
    82 {
    -
    83 if (g->right != NULL)
    +
    83 if (g->right != NULL)
    84 {
    -
    85 u = g->right;
    +
    85 u = g->right;
    86 if (u->color == 'r')
    87 {
    88 t->parent->color = 'b';
    89 u->color = 'b';
    -
    90 g->color = 'r';
    -
    91 t = g;
    +
    90 g->color = 'r';
    +
    91 t = g;
    92 }
    93 }
    94 else
    @@ -543,21 +543,21 @@ Private Attributes
    99 leftrotate(t);
    100 }
    101 t->parent->color = 'b';
    -
    102 g->color = 'r';
    +
    102 g->color = 'r';
    103 rightrotate(g);
    104 }
    105 }
    106 else
    107 {
    -
    108 if (g->left != NULL)
    +
    108 if (g->left != NULL)
    109 {
    -
    110 u = g->left;
    +
    110 u = g->left;
    111 if (u->color == 'r')
    112 {
    113 t->parent->color = 'b';
    114 u->color = 'b';
    -
    115 g->color = 'r';
    -
    116 t = g;
    +
    115 g->color = 'r';
    +
    116 t = g;
    117 }
    118 }
    119 else
    @@ -568,13 +568,14 @@ Private Attributes
    124 rightrotate(t);
    125 }
    126 t->parent->color = 'b';
    -
    127 g->color = 'r';
    +
    127 g->color = 'r';
    128 leftrotate(g);
    129 }
    130 }
    131 root->color = 'b';
    132 }
    133}
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    diff --git a/d8/d7a/sha1_8cpp.html b/d8/d7a/sha1_8cpp.html index 9639a6151..005b9e710 100644 --- a/d8/d7a/sha1_8cpp.html +++ b/d8/d7a/sha1_8cpp.html @@ -304,23 +304,23 @@ Here is the call graph for this function:
    156
    157 // Main "hashing" loop
    158 for (uint8_t i = 0; i < 80; i++) {
    -
    159 uint32_t F = 0, g = 0;
    +
    159 uint32_t F = 0, g = 0;
    160 if (i < 20) {
    161 F = (b & c) | ((~b) & d);
    -
    162 g = 0x5A827999;
    +
    162 g = 0x5A827999;
    163 } else if (i < 40) {
    164 F = b ^ c ^ d;
    -
    165 g = 0x6ED9EBA1;
    +
    165 g = 0x6ED9EBA1;
    166 } else if (i < 60) {
    167 F = (b & c) | (b & d) | (c & d);
    -
    168 g = 0x8F1BBCDC;
    +
    168 g = 0x8F1BBCDC;
    169 } else {
    170 F = b ^ c ^ d;
    -
    171 g = 0xCA62C1D6;
    +
    171 g = 0xCA62C1D6;
    172 }
    173
    174 // Update the accumulators
    -
    175 uint32_t temp = leftRotate32bits(a, 5) + F + e + g + blocks[i];
    +
    175 uint32_t temp = leftRotate32bits(a, 5) + F + e + g + blocks[i];
    176 e = d;
    177 d = c;
    178 c = leftRotate32bits(b, 30);
    @@ -352,6 +352,7 @@ Here is the call graph for this function:
    T copy(T... args)
    uint32_t leftRotate32bits(uint32_t n, std::size_t rotate)
    Rotates the bits of a 32-bit unsigned integer.
    Definition: md5.cpp:66
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    Here is the call graph for this function:
    diff --git a/d8/db1/binomial__calculate_8cpp.html b/d8/db1/binomial__calculate_8cpp.html index 7e73f91a2..a6c52eb16 100644 --- a/d8/db1/binomial__calculate_8cpp.html +++ b/d8/db1/binomial__calculate_8cpp.html @@ -173,21 +173,22 @@ Functions
    32 {
    33 // basic cases
    34 if (k > (n / 2))
    -
    35 k = n - k;
    +
    35 k = n - k;
    36 if (k == 1)
    37 return n;
    38 if (k == 0)
    39 return 1;
    40
    41 size_t result = 1;
    -
    42 for (int32_t i = 1; i <= k; ++i) {
    -
    43 result *= n - k + i;
    +
    42 for (int32_t i = 1; i <= k; ++i) {
    +
    43 result *= n - k + i;
    44 result /= i;
    45 }
    46
    47 return result;
    48}
    uint64_t result(uint64_t n)
    Definition: fibonacci_sum.cpp:76
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    Here is the call graph for this function:
    @@ -241,7 +242,7 @@ Here is the call graph for this function:
    85 }
    86
    87 int32_t n = atoi(argv[1]);
    -
    88 int32_t k = atoi(argv[2]);
    +
    88 int32_t k = atoi(argv[2]);
    89
    91 return 0;
    diff --git a/d9/d69/median__search_8cpp.html b/d9/d69/median__search_8cpp.html index b244320a0..40d425e32 100644 --- a/d9/d69/median__search_8cpp.html +++ b/d9/d69/median__search_8cpp.html @@ -255,7 +255,7 @@ Here is the call graph for this function:
    87 high.push_back(a[i]);
    88 }
    89 }
    -
    90 int k = int(low.size());
    +
    90 int k = int(low.size());
    91 if(idx < k){
    92 return median_of_medians(low, idx);
    93 }
    @@ -268,6 +268,7 @@ Here is the call graph for this function:
    100}
    T begin(T... args)
    T end(T... args)
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    T min(T... args)
    T push_back(T... args)
    T size(T... args)
    @@ -308,7 +309,7 @@ Here is the call graph for this function:
    116 std::cout << "test case:2 passed\n";
    117
    118 std::vector<int> C{1,2,3,4,5,1000,8,9,99};
    -
    119 int k = 3;
    +
    119 int k = 3;
    120 assert(C[3] == search::median_search::median_of_medians(C, k)); // C[3] = 4, is the fourth smallest element.
    121 std::cout << "test case:3 passed\n";
    122 std::cout << "--All tests passed--\n";
    diff --git a/d9/daa/namespacemidpoint__rule.html b/d9/daa/namespacemidpoint__rule.html new file mode 100644 index 000000000..d7a94e1cc --- /dev/null +++ b/d9/daa/namespacemidpoint__rule.html @@ -0,0 +1,111 @@ + + + + + + + +Algorithms_in_C++: midpoint_rule Namespace Reference + + + + + + + + + + + + + + + +
    +
    + + + + + + +
    +
    Algorithms_in_C++ 1.0.0 +
    +
    Set of algorithms implemented in C++.
    +
    +
    + + + + + + + +
    +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    midpoint_rule Namespace Reference
    +
    +
    + +

    Functions for the Midpoint Integral method implementation. +More...

    +

    Detailed Description

    +

    Functions for the Midpoint Integral method implementation.

    +
    +
    + + + + diff --git a/da/d24/sqrt__double_8cpp.html b/da/d24/sqrt__double_8cpp.html index c7ddb858c..a7069cae1 100644 --- a/da/d24/sqrt__double_8cpp.html +++ b/da/d24/sqrt__double_8cpp.html @@ -175,7 +175,7 @@ Here is the call graph for this function:
    17 if (a > 0 && a < 1) {
    18 return 1 / Sqrt(1 / a);
    19 }
    -
    20 double l = 0, r = a;
    +
    20 double l = 0, r = a;
    21 /* Epsilon is the precision.
    22 A great precision is
    23 between 1e-7 and 1e-12.
    @@ -183,18 +183,19 @@ Here is the call graph for this function:
    25 */
    26 double epsilon = 1e-12;
    27 while (l <= r) {
    -
    28 double mid = (l + r) / 2;
    +
    28 double mid = (l + r) / 2;
    29 if (mid * mid > a) {
    30 r = mid;
    31 } else {
    32 if (a - mid * mid < epsilon) {
    33 return mid;
    34 }
    -
    35 l = mid;
    +
    35 l = mid;
    36 }
    37 }
    38 return -1;
    39}
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    Here is the call graph for this function:
    diff --git a/da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html b/da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html index 178c89c81..b4631c67b 100644 --- a/da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html +++ b/da/d37/structdata__structures_1_1sparse__table_1_1_sparse__table.html @@ -171,16 +171,18 @@ size_t n = 0

    < represents minimum value over the range [g, r - pow(2,g) + 1]

    < represents minimum value over the whole range [l,r]

    109 {
    -
    110 int64_t g = LOG[r - l + 1]; ///< smallest power of 2 covering [l,r]
    -
    111 int64_t x = ST[g][l]; ///< represents minimum value over the range
    +
    110 int64_t g = LOG[r - l + 1]; ///< smallest power of 2 covering [l,r]
    +
    111 int64_t x = ST[g][l]; ///< represents minimum value over the range
    112 ///< [g,l]
    113 int64_t y =
    -
    114 ST[g][r - (1 << g) + 1]; ///< represents minimum value over the
    +
    114 ST[g][r - (1 << g) + 1]; ///< represents minimum value over the
    115 ///< range [g, r - pow(2,g) + 1]
    116
    117 return (A[x] <= A[y] ? x : y); ///< represents minimum value over
    118 ///< the whole range [l,r]
    119 }
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    std::array< int64_t, N > LOG
    where floor(log2(i)) are precomputed.
    Definition: sparse_table.cpp:59
    std::array< int64_t, N > A
    input array to perform RMQ.
    Definition: sparse_table.cpp:56
    std::array< std::array< int64_t, N >, M > ST
    the sparse table storing min() values for given interval.
    Definition: sparse_table.cpp:58
    diff --git a/da/d7b/primality__test_8cpp.html b/da/d7b/primality__test_8cpp.html index 70b2731fa..af02f1201 100644 --- a/da/d7b/primality__test_8cpp.html +++ b/da/d7b/primality__test_8cpp.html @@ -147,12 +147,13 @@ Functions
    20 (number % 3 == 0 && number != 3))
    21 return false;
    22
    -
    23 for (int k = 1; 36 * k * k - 12 * k < number; ++k) {
    +
    23 for (int k = 1; 36 * k * k - 12 * k < number; ++k) {
    24 if ((number % (6 * k + 1) == 0) || (number % (6 * k - 1) == 0))
    25 return false;
    26 }
    27 return true;
    28}
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    diff --git a/da/dc3/linked__list_8cpp.html b/da/dc3/linked__list_8cpp.html index f585e3036..c13391bf8 100644 --- a/da/dc3/linked__list_8cpp.html +++ b/da/dc3/linked__list_8cpp.html @@ -201,7 +201,7 @@ Here is the call graph for this function:

    Main function: Allows the user add and delete values from the list. Also allows user to search for and display values in the list.

    Returns
    0 on exit
    222 {
    - +
    224 int choice = 0;
    225 int x = 0;
    226 std::string s;
    @@ -220,7 +220,7 @@ Here is the call graph for this function:
    239
    240 if (data_structures::linked_list::isDigit(s)) {
    241 x = std::stoi(s);
    -
    242 l.push_back(x);
    +
    242 l.push_back(x);
    243 } else {
    244 std::cout << "Wrong Input!\n";
    245 }
    @@ -230,7 +230,7 @@ Here is the call graph for this function:
    249 std::cin >> s;
    250 if (data_structures::linked_list::isDigit(s)) {
    251 x = std::stoi(s);
    -
    252 l.erase(x);
    +
    252 l.erase(x);
    253 } else {
    254 std::cout << "Wrong Input!\n";
    255 }
    @@ -241,13 +241,13 @@ Here is the call graph for this function:
    260 if (data_structures::linked_list::isDigit(s)) {
    261 x = std::stoi(s);
    -
    263 l.search(x);
    +
    263 l.search(x);
    264 } else {
    265 std::cout << "Wrong Input!\n";
    266 }
    267 break;
    268 case 4:
    -
    269 l.display();
    +
    269 l.display();
    270 std::cout << "\n";
    271 break;
    272 default:
    @@ -261,17 +261,14 @@ Here is the call graph for this function:
    Definition: linked_list.cpp:81
    -
    std::shared_ptr< link > search(int find_elem)
    Definition: linked_list.cpp:197
    -
    void erase(int old_elem)
    Definition: linked_list.cpp:152
    -
    void display()
    Definition: linked_list.cpp:181
    -
    void push_back(int new_elem)
    Definition: linked_list.cpp:123
    T endl(T... args)
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    T stoi(T... args)
    Here is the call graph for this function:
    -
    +
    diff --git a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map index eafdc9dc1..20bc2d61e 100644 --- a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map +++ b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -1,11 +1,5 @@ - - - - - - - - - + + + diff --git a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 index 5305d0a4a..883202f77 100644 --- a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 +++ b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -1 +1 @@ -6b212deec9f04ec65076ade9ca5faded \ No newline at end of file +6332525467792455913e957281290568 \ No newline at end of file diff --git a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg index 117debeb4..a943ca74a 100644 --- a/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg +++ b/da/dc3/linked__list_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -4,162 +4,49 @@ - - + + main - + Node1 - -main + +main Node2 - - -data_structures::linked -_list::list::display + + +std::endl Node1->Node2 - - - - - -Node4 - - -std::endl - - - - - -Node1->Node4 - - - - - -Node5 - - -data_structures::linked -_list::list::erase - - - - - -Node1->Node5 - - - - - -Node7 - - -data_structures::linked -_list::list::push_back - - - - - -Node1->Node7 - - - - - -Node8 - - -data_structures::linked -_list::list::search - - - - - -Node1->Node8 - - - - - -Node9 - - -std::stoi - - - - - -Node1->Node9 - - + + Node3 - - -data_structures::linked -_list::list::isEmpty + + +std::stoi - + -Node2->Node3 - - - - - -Node5->Node3 - - - - - -Node6 - - -std::shared_ptr::reset - - - - - -Node5->Node6 - - - - - -Node7->Node3 - - - - - -Node8->Node3 - - +Node1->Node3 + + diff --git a/da/dc9/fibonacci__matrix__exponentiation_8cpp.html b/da/dc9/fibonacci__matrix__exponentiation_8cpp.html index c3ed31605..fbd64942b 100644 --- a/da/dc9/fibonacci__matrix__exponentiation_8cpp.html +++ b/da/dc9/fibonacci__matrix__exponentiation_8cpp.html @@ -178,9 +178,9 @@ Functions
    42 {
    43 for(int j=0;j<2;j++)
    44 {
    -
    45 for(int k=0;k<2;k++)
    +
    45 for(int k=0;k<2;k++)
    46 {
    -
    47 res[i][j]=(res[i][j]%mod+((Identity[i][k]%mod*transition[k][j]%mod))%mod)%mod;
    +
    47 res[i][j]=(res[i][j]%mod+((Identity[i][k]%mod*transition[k][j]%mod))%mod)%mod;
    48 }
    49 }
    50 }
    @@ -199,9 +199,9 @@ Functions
    63 {
    64 for(int j=0;j<2;j++)
    65 {
    -
    66 for(int k=0;k<2;k++)
    +
    66 for(int k=0;k<2;k++)
    67 {
    -
    68 res1[i][j]=(res1[i][j]%mod+((transition[i][k]%mod*transition[k][j]%mod))%mod)%mod;
    +
    68 res1[i][j]=(res1[i][j]%mod+((transition[i][k]%mod*transition[k][j]%mod))%mod)%mod;
    69 }
    70 }
    71 }
    @@ -218,6 +218,7 @@ Functions
    82 return ((result[0]%mod*Identity[0][0]%mod)%mod+(result[1]%mod*Identity[1][0]%mod)%mod)%mod;
    83}
    uint64_t result(uint64_t n)
    Definition: fibonacci_sum.cpp:76
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    diff --git a/db/d01/brent__method__extrema_8cpp.html b/db/d01/brent__method__extrema_8cpp.html index dd00fe72d..e671c569d 100644 --- a/db/d01/brent__method__extrema_8cpp.html +++ b/db/d01/brent__method__extrema_8cpp.html @@ -227,7 +227,7 @@ Functions
    48
    49 double v = lim_a + M_GOLDEN_RATIO * (lim_b - lim_a);
    50 double u, w = v, x = v;
    -
    51 double fu, fv = f(v);
    +
    51 double fu, fv = f(v);
    52 double fw = fv, fx = fv;
    53
    54 double mid_point = (lim_a + lim_b) / 2.f;
    @@ -275,7 +275,7 @@ Functions
    96 else
    97 u = -tolerance;
    98 u += x;
    -
    99 fu = f(u);
    +
    99 fu = f(u);
    100
    101 // update variables
    102 if (fu <= fx) {
    @@ -314,6 +314,7 @@ Functions
    135}
    #define EPSILON
    system accuracy limit
    Definition: brent_method_extrema.cpp:23
    +
    double f(double x)
    A function f(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:90
    T swap(T... args)
    Here is the call graph for this function:
    diff --git a/db/d40/integral__approximation2_8cpp.html b/db/d40/integral__approximation2_8cpp.html index ae9809254..ac7b70da3 100644 --- a/db/d40/integral__approximation2_8cpp.html +++ b/db/d40/integral__approximation2_8cpp.html @@ -384,13 +384,13 @@ Here is the call graph for this function:
    139 << std::endl;
    140 ;
    141
    - +
    144 double integral = 0;
    145 double lower_bound = 0, upper_bound = 0;
    146
    147 /* \int_{-2}^{2} -x^2 + 4 dx */
    -
    148 f = [&](double& x) { return -x * x + 4.0; };
    +
    148 f = [&](double& x) { return -x * x + 4.0; };
    149
    150 lower_bound = -2.0;
    151 upper_bound = 2.0;
    @@ -414,7 +414,7 @@ Here is the call graph for this function:
    169 << std::endl;
    170
    171 /* \int_{0}^{1} e^x dx */
    -
    172 f = [&](double& x) { return std::exp(x); };
    +
    172 f = [&](double& x) { return std::exp(x); };
    173
    174 lower_bound = 0.0;
    175 upper_bound = 1.0;
    @@ -441,7 +441,7 @@ Here is the call graph for this function:
    196 This is a difficult integral because of its infinite domain.
    197 Therefore, it may deviate largely from the expected result.
    198 */
    -
    199 f = [&](double& x) { return std::sin(M_PI * x) / (M_PI * x); };
    +
    199 f = [&](double& x) { return std::sin(M_PI * x) / (M_PI * x); };
    200
    201 pdf = [&](double& x) {
    202 return 1.0 / std::sqrt(2.0 * M_PI) * std::exp(-x * x / 2.0);
    @@ -458,6 +458,7 @@ Here is the call graph for this function:
    double integral_monte_carlo(const double &start_point, const Function &function, const Function &pdf, const uint32_t &num_samples=1000000)
    Compute an approximation of an integral using Monte Carlo integration.
    Definition: integral_approximation2.cpp:112
    T lower_bound(T... args)
    +
    double f(double x)
    A function f(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:90
    T sin(T... args)
    T sqrt(T... args)
    T upper_bound(T... args)
    diff --git a/db/d9a/classuint128__t.html b/db/d9a/classuint128__t.html index 8fb8e74f5..637549e32 100644 --- a/db/d9a/classuint128__t.html +++ b/db/d9a/classuint128__t.html @@ -697,13 +697,14 @@ Here is the call graph for this function:
    146 unsigned long r = 0;
    147 _BitScanForward64(&r, f);
    148 if (r == 64) {
    -
    149 unsigned long l = 0;
    +
    149 unsigned long l = 0;
    150 _BitScanForward64(&l, s);
    -
    151 return 64 + l;
    +
    151 return 64 + l;
    152 }
    153 return r;
    154#endif
    155 }
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    @@ -742,9 +743,9 @@ Here is the call graph for this function:
    169 unsigned long r = 0;
    170 _BitScanReverse64(&r, s);
    171 if (r == 64) {
    -
    172 unsigned long l = 0;
    +
    172 unsigned long l = 0;
    173 _BitScanReverse64(&l, f);
    -
    174 return 64 + l;
    +
    174 return 64 + l;
    175 }
    176 return r;
    177#endif
    diff --git a/dc/d5a/rat__maze_8cpp.html b/dc/d5a/rat__maze_8cpp.html index aa594887e..748970837 100644 --- a/dc/d5a/rat__maze_8cpp.html +++ b/dc/d5a/rat__maze_8cpp.html @@ -300,7 +300,7 @@ Here is the call graph for this function:

    Self-test implementations.

    Returns
    void
    -
    Examples
    /Users/runner/work/C-Plus-Plus/C-Plus-Plus/numerical_methods/rungekutta.cpp, and /Users/runner/work/C-Plus-Plus/C-Plus-Plus/sorting/wiggle_sort.cpp.
    +
    Examples
    /Users/runner/work/C-Plus-Plus/C-Plus-Plus/numerical_methods/rungekutta.cpp, and /Users/runner/work/C-Plus-Plus/C-Plus-Plus/sorting/wiggle_sort.cpp.
    86 {
    87 const int size = 4;
    diff --git a/dc/dc4/_2_users_2runner_2work_2_c-_plus-_plus_2_c-_plus-_plus_2numerical_methods_2rungekutta_8cpp-example.html b/dc/dc4/_2_users_2runner_2work_2_c-_plus-_plus_2_c-_plus-_plus_2numerical_methods_2rungekutta_8cpp-example.html index e3340c1a1..48cfdc9f2 100644 --- a/dc/dc4/_2_users_2runner_2work_2_c-_plus-_plus_2_c-_plus-_plus_2numerical_methods_2rungekutta_8cpp-example.html +++ b/dc/dc4/_2_users_2runner_2work_2_c-_plus-_plus_2_c-_plus-_plus_2numerical_methods_2rungekutta_8cpp-example.html @@ -162,7 +162,7 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
    auto n = static_cast<uint64_t>((x - init_x) / h);
    // used a vector container for the variables
    - +
    // Iterate for number of iterations
    @@ -170,10 +170,10 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
    for (int i = 1; i <= n; ++i) {
    // Apply Runge Kutta Formulas
    // to find next value of y
    -
    k[0] = h * change(init_x, y);
    -
    k[1] = h * change(init_x + 0.5 * h, y + 0.5 * k[0]);
    -
    k[2] = h * change(init_x + 0.5 * h, y + 0.5 * k[1]);
    -
    k[3] = h * change(init_x + h, y + k[2]);
    +
    k[0] = h * change(init_x, y);
    +
    k[1] = h * change(init_x + 0.5 * h, y + 0.5 * k[0]);
    +
    k[2] = h * change(init_x + 0.5 * h, y + 0.5 * k[1]);
    +
    k[3] = h * change(init_x + h, y + k[2]);
    // Update next value of y
    @@ -193,8 +193,8 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
    * @brief Tests to check algorithm implementation.
    * @returns void
    */
    -
    static void test() {
    -
    std::cout << "The Runge Kutta function will be tested on the basis of "
    +
    static void test() {
    +
    std::cout << "The Runge Kutta function will be tested on the basis of "
    "precomputed values\n";
    std::cout << "Test 1...."
    @@ -223,13 +223,14 @@ $(document).ready(function(){initNavTree('dc/dc4/_2_users_2runner_2work_2_c-_plu
    * @brief Main function
    * @returns 0 on exit
    */
    -
    int main() {
    +
    int main() {
    test(); // Execute the tests
    return 0;
    }
    int main()
    Main function.
    Definition: graph_coloring.cpp:112
    int h(int key)
    Definition: hash_search.cpp:45
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    for io operations
    Functions for Runge Kutta fourth order method.
    static void test()
    Self-test implementations.
    Definition: rat_maze.cpp:86
    diff --git a/de/d1c/midpoint__integral__method_8cpp__incl.map b/de/d1c/midpoint__integral__method_8cpp__incl.map new file mode 100644 index 000000000..91af16246 --- /dev/null +++ b/de/d1c/midpoint__integral__method_8cpp__incl.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/de/d1c/midpoint__integral__method_8cpp__incl.md5 b/de/d1c/midpoint__integral__method_8cpp__incl.md5 new file mode 100644 index 000000000..05d608719 --- /dev/null +++ b/de/d1c/midpoint__integral__method_8cpp__incl.md5 @@ -0,0 +1 @@ +cb4d842974681cf60eb688b551f3de3f \ No newline at end of file diff --git a/de/d1c/midpoint__integral__method_8cpp__incl.svg b/de/d1c/midpoint__integral__method_8cpp__incl.svg new file mode 100644 index 000000000..062915a04 --- /dev/null +++ b/de/d1c/midpoint__integral__method_8cpp__incl.svg @@ -0,0 +1,128 @@ + + + + + + +numerical_methods/midpoint_integral_method.cpp + + + +Node1 + + +numerical_methods/midpoint +_integral_method.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + +Node3 + + +cmath + + + + + +Node1->Node3 + + + + + +Node4 + + +cstdint + + + + + +Node1->Node4 + + + + + +Node5 + + +cstdlib + + + + + +Node1->Node5 + + + + + +Node6 + + +functional + + + + + +Node1->Node6 + + + + + +Node7 + + +iostream + + + + + +Node1->Node7 + + + + + +Node8 + + +map + + + + + +Node1->Node8 + + + + + diff --git a/de/d75/qr__eigen__values_8cpp.html b/de/d75/qr__eigen__values_8cpp.html index 2edda51db..d304daea6 100644 --- a/de/d75/qr__eigen__values_8cpp.html +++ b/de/d75/qr__eigen__values_8cpp.html @@ -355,12 +355,13 @@ Here is the call graph for this function:
    66 for (int i = 0; i < R1; i++) {
    67 for (int j = 0; j < C2; j++) {
    68 OUT[0][i][j] = 0.f;
    -
    69 for (int k = 0; k < C1; k++) {
    -
    70 OUT[0][i][j] += A[i][k] * B[k][j];
    +
    69 for (int k = 0; k < C1; k++) {
    +
    70 OUT[0][i][j] += A[i][k] * B[k][j];
    71 }
    72 }
    73 }
    74}
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    T perror(T... args)
    diff --git a/de/d9b/prime__numbers_8cpp.html b/de/d9b/prime__numbers_8cpp.html index 5bd45086c..89a8828ed 100644 --- a/de/d9b/prime__numbers_8cpp.html +++ b/de/d9b/prime__numbers_8cpp.html @@ -181,11 +181,11 @@ Here is the call graph for this function:
    17 res.emplace_back(i);
    18 }
    19 for (int p : res) {
    -
    20 size_t k = i * p;
    +
    20 size_t k = i * p;
    21 if (k > max) {
    22 break;
    23 }
    -
    24 is_not_prime[k] = true;
    +
    24 is_not_prime[k] = true;
    25 if (i % p == 0) {
    26 break;
    27 }
    @@ -195,6 +195,7 @@ Here is the call graph for this function:
    31}
    T emplace_back(T... args)
    T max(T... args)
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    Here is the call graph for this function:
    diff --git a/df/d11/midpoint__integral__method_8cpp.html b/df/d11/midpoint__integral__method_8cpp.html new file mode 100644 index 000000000..67be9de90 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp.html @@ -0,0 +1,601 @@ + + + + + + + +Algorithms_in_C++: numerical_methods/midpoint_integral_method.cpp File Reference + + + + + + + + + + + + + + + +
    +
    + + + + + + +
    +
    Algorithms_in_C++ 1.0.0 +
    +
    Set of algorithms implemented in C++.
    +
    +
    + + + + + + + +
    +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    + +
    midpoint_integral_method.cpp File Reference
    +
    +
    + +

    A numerical method for easy approximation of integrals +More...

    +
    #include <cassert>
    +#include <cmath>
    +#include <cstdint>
    +#include <cstdlib>
    +#include <functional>
    +#include <iostream>
    +#include <map>
    +
    +Include dependency graph for midpoint_integral_method.cpp:
    +
    +
    +
    +
    +
    + + + + + + + +

    +Namespaces

    namespace  numerical_methods
     for io operations
     
    namespace  midpoint_rule
     Functions for the Midpoint Integral method implementation.
     
    + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    double numerical_methods::midpoint_rule::midpoint (const std::int32_t N, const double h, const double a, const std::function< double(double)> &func)
     Main function for implementing the Midpoint Integral Method implementation. More...
     
    double numerical_methods::midpoint_rule::f (double x)
     A function f(x) that will be used to test the method. More...
     
    double numerical_methods::midpoint_rule::g (double x)
     A function g(x) that will be used to test the method. More...
     
    double numerical_methods::midpoint_rule::k (double x)
     A function k(x) that will be used to test the method. More...
     
    double numerical_methods::midpoint_rule::l (double x)
     A function l(x) that will be used to test the method. More...
     
    static void test (std::int32_t N, double h, double a, double b, bool used_argv_parameters)
     Self-test implementations. More...
     
    int main (int argc, char **argv)
     Main function. More...
     
    +

    Detailed Description

    +

    A numerical method for easy approximation of integrals

    +

    The idea is to split the interval into N of intervals and use as interpolation points the xi for which it applies that xi = x0 + i*h, where h is a step defined as h = (b-a)/N where a and b are the first and last points of the interval of the integration [a, b].

    +

    We create a table of the xi and their corresponding f(xi) values and we evaluate the integral by the formula: I = h * {f(x0+h/2) + f(x1+h/2) + ... + f(xN-1+h/2)}

    +

    Arguments can be passed as parameters from the command line argv[1] = N, argv[2] = a, argv[3] = b. In this case if the default values N=16, a=1, b=3 are changed then the tests/assert are disabled.

    +
    Author
    ggkogkou
    +

    Function Documentation

    + +

    ◆ f()

    + +
    +
    + + + + + + + + +
    double numerical_methods::midpoint_rule::f (double x)
    +
    + +

    A function f(x) that will be used to test the method.

    +
    Parameters
    + + +
    xThe independent variable xi
    +
    +
    +
    Returns
    the value of the dependent variable yi = f(xi) = sqrt(xi) + ln(xi)
    +
    90{ return std::sqrt(x) + std::log(x); }
    +
    T log(T... args)
    +
    T sqrt(T... args)
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ g()

    + +
    +
    + + + + + + + + +
    double numerical_methods::midpoint_rule::g (double x)
    +
    + +

    A function g(x) that will be used to test the method.

    +
    Parameters
    + + +
    xThe independent variable xi
    +
    +
    +
    Returns
    the value of the dependent variable yi = g(xi) = e^(-xi) * (4 - xi^2)
    +
    97{ return std::exp(-x) * (4 - std::pow(x, 2)); }
    +
    T exp(T... args)
    +
    T pow(T... args)
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ k()

    + +
    +
    + + + + + + + + +
    double numerical_methods::midpoint_rule::k (double x)
    +
    + +

    A function k(x) that will be used to test the method.

    +
    Parameters
    + + +
    xThe independent variable xi
    +
    +
    +
    Returns
    the value of the dependent variable yi = k(xi) = sqrt(2*xi^3 + 3)
    +
    Examples
    /Users/runner/work/C-Plus-Plus/C-Plus-Plus/numerical_methods/rungekutta.cpp.
    +
    +
    103{ return std::sqrt(2 * std::pow(x, 3) + 3); }
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ l()

    + +
    +
    + + + + + + + + +
    double numerical_methods::midpoint_rule::l (double x)
    +
    + +

    A function l(x) that will be used to test the method.

    +
    Parameters
    + + +
    xThe independent variable xi
    +
    +
    +
    Returns
    the value of the dependent variable yi = l(xi) = xi + ln(2*xi + 1)
    +
    109{ return x + std::log(2 * x + 1); }
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ main()

    + +
    +
    + + + + + + + + + + + + + + + + + + +
    int main (int argc,
    char ** argv 
    )
    +
    + +

    Main function.

    +
    Parameters
    + + + +
    argccommandline argument count (ignored)
    argvcommandline array of arguments (ignored)
    +
    +
    +
    Returns
    0 on exit
    +

    Number of intervals to divide the integration interval.

    +

    MUST BE EVEN

    +

    Starting and ending point of the integration in

    +

    the real axis

    +

    Step, calculated by a, b and N

    +
    162 {
    + +
    164 16; /// Number of intervals to divide the integration interval.
    +
    165 /// MUST BE EVEN
    +
    166 double a = 1, b = 3; /// Starting and ending point of the integration in
    +
    167 /// the real axis
    +
    168 double h = NAN; /// Step, calculated by a, b and N
    +
    169
    +
    170 bool used_argv_parameters =
    +
    171 false; // If argv parameters are used then the assert must be omitted
    +
    172 // for the test cases
    +
    173
    +
    174 // Get user input (by the command line parameters or the console after
    +
    175 // displaying messages)
    +
    176 if (argc == 4) {
    +
    177 N = std::atoi(argv[1]);
    +
    178 a = std::atof(argv[2]);
    +
    179 b = std::atof(argv[3]);
    +
    180 // Check if a<b else abort
    +
    181 assert(a < b && "a has to be less than b");
    +
    182 assert(N > 0 && "N has to be > 0");
    +
    183 if (N < 4 || a != 1 || b != 3) {
    +
    184 used_argv_parameters = true;
    +
    185 }
    +
    186 std::cout << "You selected N=" << N << ", a=" << a << ", b=" << b
    +
    187 << std::endl;
    +
    188 } else {
    +
    189 std::cout << "Default N=" << N << ", a=" << a << ", b=" << b
    +
    190 << std::endl;
    +
    191 }
    +
    192
    +
    193 // Find the step
    +
    194 h = (b - a) / N;
    +
    195
    +
    196 test(N, h, a, b, used_argv_parameters); // run self-test implementations
    +
    197
    +
    198 return 0;
    +
    199}
    +
    T atof(T... args)
    +
    T atoi(T... args)
    + +
    constexpr uint32_t N
    A struct to represent sparse table for min() as their invariant function, for the given array A....
    Definition: sparse_table.cpp:47
    +
    T endl(T... args)
    +
    int h(int key)
    Definition: hash_search.cpp:45
    + +
    static void test(std::int32_t N, double h, double a, double b, bool used_argv_parameters)
    Self-test implementations.
    Definition: midpoint_integral_method.cpp:123
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ midpoint()

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    double numerical_methods::midpoint_rule::midpoint (const std::int32_t N,
    const double h,
    const double a,
    const std::function< double(double)> & func 
    )
    +
    + +

    Main function for implementing the Midpoint Integral Method implementation.

    +
    Parameters
    + + + + + +
    Nis the number of intervals
    his the step
    ais x0
    funcis the function that will be integrated
    +
    +
    +
    Returns
    the result of the integration
    +
    53 {
    + +
    55 data_table; // Contains the data points, key: i, value: f(xi)
    +
    56 double xi = a; // Initialize xi to the starting point x0 = a
    +
    57
    +
    58 // Create the data table
    +
    59 // Loop from x0 to xN-1
    +
    60 double temp = NAN;
    +
    61 for (std::int32_t i = 0; i < N; i++) {
    +
    62 temp = func(xi + h / 2); // find f(xi+h/2)
    +
    63 data_table.insert(
    +
    64 std::pair<std::int32_t, double>(i, temp)); // add i and f(xi)
    +
    65 xi += h; // Get the next point xi for the next iteration
    +
    66 }
    +
    67
    +
    68 // Evaluate the integral.
    +
    69 // Remember: {f(x0+h/2) + f(x1+h/2) + ... + f(xN-1+h/2)}
    +
    70 double evaluate_integral = 0;
    +
    71 for (std::int32_t i = 0; i < N; i++) evaluate_integral += data_table.at(i);
    +
    72
    +
    73 // Multiply by the coefficient h
    +
    74 evaluate_integral *= h;
    +
    75
    +
    76 // If the result calculated is nan, then the user has given wrong input
    +
    77 // interval.
    +
    78 assert(!std::isnan(evaluate_integral) &&
    +
    79 "The definite integral can't be evaluated. Check the validity of "
    +
    80 "your input.\n");
    +
    81 // Else return
    +
    82 return evaluate_integral;
    +
    83}
    +
    T at(T... args)
    +
    T insert(T... args)
    +
    T isnan(T... args)
    + + +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    + +

    ◆ test()

    + +
    +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    static void test (std::int32_t N,
    double h,
    double a,
    double b,
    bool used_argv_parameters 
    )
    +
    +static
    +
    + +

    Self-test implementations.

    +
    Parameters
    + + + + + + +
    Nis the number of intervals
    his the step
    ais x0
    bis the end of the interval
    used_argv_parametersis 'true' if argv parameters are given and 'false' if not
    +
    +
    +
    124 {
    +
    125 // Call midpoint() for each of the test functions f, g, k, l
    +
    126 // Assert with two decimal point precision
    + +
    128 N, h, a, numerical_methods::midpoint_rule::f);
    +
    129 assert((used_argv_parameters || (result_f >= 4.09 && result_f <= 4.10)) &&
    +
    130 "The result of f(x) is wrong");
    +
    131 std::cout << "The result of integral f(x) on interval [" << a << ", " << b
    +
    132 << "] is equal to: " << result_f << std::endl;
    +
    133
    + +
    135 N, h, a, numerical_methods::midpoint_rule::g);
    +
    136 assert((used_argv_parameters || (result_g >= 0.27 && result_g <= 0.28)) &&
    +
    137 "The result of g(x) is wrong");
    +
    138 std::cout << "The result of integral g(x) on interval [" << a << ", " << b
    +
    139 << "] is equal to: " << result_g << std::endl;
    +
    140
    + +
    142 N, h, a, numerical_methods::midpoint_rule::k);
    +
    143 assert((used_argv_parameters || (result_k >= 9.06 && result_k <= 9.07)) &&
    +
    144 "The result of k(x) is wrong");
    +
    145 std::cout << "The result of integral k(x) on interval [" << a << ", " << b
    +
    146 << "] is equal to: " << result_k << std::endl;
    +
    147
    + +
    149 N, h, a, numerical_methods::midpoint_rule::l);
    +
    150 assert((used_argv_parameters || (result_l >= 7.16 && result_l <= 7.17)) &&
    +
    151 "The result of l(x) is wrong");
    +
    152 std::cout << "The result of integral l(x) on interval [" << a << ", " << b
    +
    153 << "] is equal to: " << result_l << std::endl;
    +
    154}
    +
    double midpoint(const std::int32_t N, const double h, const double a, const std::function< double(double)> &func)
    Main function for implementing the Midpoint Integral Method implementation.
    Definition: midpoint_integral_method.cpp:52
    +
    +Here is the call graph for this function:
    +
    +
    +
    +
    + +
    +
    +
    +
    + + + + diff --git a/df/d11/midpoint__integral__method_8cpp.js b/df/d11/midpoint__integral__method_8cpp.js new file mode 100644 index 000000000..c11a0662b --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp.js @@ -0,0 +1,10 @@ +var midpoint__integral__method_8cpp = +[ + [ "f", "df/d11/midpoint__integral__method_8cpp.html#a7ee8e824ef3e138a9a21883b26d97226", null ], + [ "g", "df/d11/midpoint__integral__method_8cpp.html#ae682ee71af44b1e9e884849cc6a6b040", null ], + [ "k", "df/d11/midpoint__integral__method_8cpp.html#ae9f66040f8e0ba73c1c741261c22a52a", null ], + [ "l", "df/d11/midpoint__integral__method_8cpp.html#ad53616fb4fa6880ae876bcba53365c51", null ], + [ "main", "df/d11/midpoint__integral__method_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627", null ], + [ "midpoint", "df/d11/midpoint__integral__method_8cpp.html#a7072493d1f0f8a91b2a71d4cc456c09c", null ], + [ "test", "df/d11/midpoint__integral__method_8cpp.html#a2ae48a41e43dc6ab11b962742349646e", null ] +]; \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.map b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.map new file mode 100644 index 000000000..ba5342183 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.md5 new file mode 100644 index 000000000..ccb3fa530 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.md5 @@ -0,0 +1 @@ +933cfa74fd0798b815fb68d8a2bb3bf4 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.svg new file mode 100644 index 000000000..8f16b846b --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a2ae48a41e43dc6ab11b962742349646e_cgraph.svg @@ -0,0 +1,52 @@ + + + + + + +test + + + +Node1 + + +test + + + + + +Node2 + + +std::endl + + + + + +Node1->Node2 + + + + + +Node3 + + +h + + + + + +Node1->Node3 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.map b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.map new file mode 100644 index 000000000..ec07b0539 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.map @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.md5 new file mode 100644 index 000000000..4e241f6a3 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.md5 @@ -0,0 +1 @@ +789454801ae4af4a2066076e1a213e13 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.svg new file mode 100644 index 000000000..b69490247 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a3c04138a5bfe5d72780bb7e82a18e627_cgraph.svg @@ -0,0 +1,109 @@ + + + + + + +main + + + +Node1 + + +main + + + + + +Node2 + + +std::atof + + + + + +Node1->Node2 + + + + + +Node3 + + +std::atoi + + + + + +Node1->Node3 + + + + + +Node4 + + +std::endl + + + + + +Node1->Node4 + + + + + +Node5 + + +h + + + + + +Node1->Node5 + + + + + +Node6 + + +test + + + + + +Node1->Node6 + + + + + +Node6->Node4 + + + + + +Node6->Node5 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.map b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.map new file mode 100644 index 000000000..98908f6f7 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.md5 new file mode 100644 index 000000000..eaec7d18d --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.md5 @@ -0,0 +1 @@ +d371b96c9516262c01e1d8ad54bbfc8a \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.svg new file mode 100644 index 000000000..c880f65c3 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7072493d1f0f8a91b2a71d4cc456c09c_cgraph.svg @@ -0,0 +1,89 @@ + + + + + + +numerical_methods::midpoint_rule::midpoint + + + +Node1 + + +numerical_methods:: +midpoint_rule::midpoint + + + + + +Node1->Node1 + + + + + +Node2 + + +std::map::at + + + + + +Node1->Node2 + + + + + +Node3 + + +h + + + + + +Node1->Node3 + + + + + +Node4 + + +std::map::insert + + + + + +Node1->Node4 + + + + + +Node5 + + +std::isnan + + + + + +Node1->Node5 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.map b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.map new file mode 100644 index 000000000..2c953bfc0 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.md5 new file mode 100644 index 000000000..b11801b68 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.md5 @@ -0,0 +1 @@ +e874b7a4f13a184aee08d3378ad6a8a2 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.svg new file mode 100644 index 000000000..e0c7addba --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_a7ee8e824ef3e138a9a21883b26d97226_cgraph.svg @@ -0,0 +1,59 @@ + + + + + + +numerical_methods::midpoint_rule::f + + + +Node1 + + +numerical_methods:: +midpoint_rule::f + + + + + +Node1->Node1 + + + + + +Node2 + + +std::log + + + + + +Node1->Node2 + + + + + +Node3 + + +std::sqrt + + + + + +Node1->Node3 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.map b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.map new file mode 100644 index 000000000..7792ede1f --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.map @@ -0,0 +1,4 @@ + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.md5 new file mode 100644 index 000000000..373d41907 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.md5 @@ -0,0 +1 @@ +1a1f7f7ca1524ca8e26060fe6270f0c5 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.svg new file mode 100644 index 000000000..7afc4731e --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ad53616fb4fa6880ae876bcba53365c51_cgraph.svg @@ -0,0 +1,44 @@ + + + + + + +numerical_methods::midpoint_rule::l + + + +Node1 + + +numerical_methods:: +midpoint_rule::l + + + + + +Node1->Node1 + + + + + +Node2 + + +std::log + + + + + +Node1->Node2 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.map b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.map new file mode 100644 index 000000000..9e350f28d --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.md5 new file mode 100644 index 000000000..67578825a --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.md5 @@ -0,0 +1 @@ +bc13e45eadc3877f0fb149de355cf296 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.svg new file mode 100644 index 000000000..29d995e08 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae682ee71af44b1e9e884849cc6a6b040_cgraph.svg @@ -0,0 +1,59 @@ + + + + + + +numerical_methods::midpoint_rule::g + + + +Node1 + + +numerical_methods:: +midpoint_rule::g + + + + + +Node1->Node1 + + + + + +Node2 + + +std::exp + + + + + +Node1->Node2 + + + + + +Node3 + + +std::pow + + + + + +Node1->Node3 + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.map b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.map new file mode 100644 index 000000000..a9a83ba57 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.md5 b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.md5 new file mode 100644 index 000000000..64de61431 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.md5 @@ -0,0 +1 @@ +60d0842ff97a4f87fb8b476cd61aeb36 \ No newline at end of file diff --git a/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.svg b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.svg new file mode 100644 index 000000000..3a32f8e89 --- /dev/null +++ b/df/d11/midpoint__integral__method_8cpp_ae9f66040f8e0ba73c1c741261c22a52a_cgraph.svg @@ -0,0 +1,59 @@ + + + + + + +numerical_methods::midpoint_rule::k + + + +Node1 + + +numerical_methods:: +midpoint_rule::k + + + + + +Node1->Node1 + + + + + +Node2 + + +std::pow + + + + + +Node1->Node2 + + + + + +Node3 + + +std::sqrt + + + + + +Node1->Node3 + + + + + diff --git a/df/d82/breadth__first__search_8cpp.html b/df/d82/breadth__first__search_8cpp.html index e90c3ae8e..d8b65bcca 100644 --- a/df/d82/breadth__first__search_8cpp.html +++ b/df/d82/breadth__first__search_8cpp.html @@ -181,30 +181,29 @@ Functions
    189 std::cout << "Enter the number of edges: ";
    190 std::cin >> edges;
    191
    - +
    193
    194 std::cout << "Enter space-separated pairs of vertices that form edges: "
    195 << std::endl;
    196 while (edges--) {
    197 int u = 0, v = 0;
    198 std::cin >> u >> v;
    -
    199 g.add_edge(u, v);
    +
    199 g.add_edge(u, v);
    200 }
    201
    - +
    202 g.breadth_first_search(0);
    203 return 0;
    204}
    static void tests()
    Definition: breadth_first_search.cpp:139
    Definition: breadth_first_search.cpp:64
    -
    std::map< T, bool > breadth_first_search(T src)
    Definition: breadth_first_search.cpp:96
    -
    void add_edge(T u, T v, bool bidir=true)
    Definition: breadth_first_search.cpp:74
    T endl(T... args)
    +
    double g(double x)
    A function g(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:97
    Here is the call graph for this function:
    -
    +
    @@ -238,23 +237,23 @@ Here is the call graph for this function:

    Test 3 Begins

    139 {
    140 /// Test 1 Begin
    - +
    142 std::map<int, bool> correct_result;
    -
    143 g.add_edge(0, 1);
    -
    144 g.add_edge(1, 2);
    -
    145 g.add_edge(2, 3);
    +
    143 g.add_edge(0, 1);
    +
    144 g.add_edge(1, 2);
    +
    145 g.add_edge(2, 3);
    146 correct_result[0] = true;
    147 correct_result[1] = true;
    148 correct_result[2] = true;
    149 correct_result[3] = true;
    150
    -
    151 std::map<int, bool> returned_result = g.breadth_first_search(2);
    +
    151 std::map<int, bool> returned_result = g.breadth_first_search(2);
    152
    153 assert(returned_result == correct_result);
    154 std::cout << "Test 1 Passed..." << std::endl;
    155
    156 /// Test 2 Begin
    -
    157 returned_result = g.breadth_first_search(0);
    +
    157 returned_result = g.breadth_first_search(0);
    158
    159 assert(returned_result == correct_result);
    160 std::cout << "Test 2 Passed..." << std::endl;
    @@ -281,6 +280,8 @@ Here is the call graph for this function:
    181 assert(correct_res == returned_res);
    182 std::cout << "Test 3 Passed..." << std::endl;
    183}
    +
    std::map< T, bool > breadth_first_search(T src)
    Definition: breadth_first_search.cpp:96
    +
    void add_edge(T u, T v, bool bidir=true)
    Definition: breadth_first_search.cpp:74
    Here is the call graph for this function:
    diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map index e555d2641..74ce7b993 100644 --- a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map +++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -1,11 +1,11 @@ - - - - - - - - - + + + + + + + + + diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 index 7f54b756d..f7ee60491 100644 --- a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 +++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -1 +1 @@ -bd041341195b2e0789cc74208a3fe618 \ No newline at end of file +d8a1b32206259a1ba8719912d88e4116 \ No newline at end of file diff --git a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg index 0ad6b856c..ace057c3c 100644 --- a/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg +++ b/df/d82/breadth__first__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -4,158 +4,146 @@ - - + + main - + Node1 - -main + +main Node2 - - -graph::Graph::add_edge + + +std::endl Node1->Node2 - - + + Node3 - - -graph::Graph::breadth -_first_search + + +tests Node1->Node3 - - + + - - -Node8 - - -std::endl - - - - - -Node1->Node8 - - - - - -Node9 - - -tests - - - - - -Node1->Node9 - - + + +Node3->Node2 + + Node4 - - -std::queue::empty + + +graph::Graph::add_edge Node3->Node4 - - + + Node5 - - -std::queue::front + + +graph::Graph::breadth +_first_search Node3->Node5 - - + + Node6 - + + +std::queue::empty + + + + + +Node5->Node6 + + + + + +Node7 + + +std::queue::front + + + + + +Node5->Node7 + + + + + +Node8 + std::queue::pop - - -Node3->Node6 + + +Node5->Node8 - - -Node7 - + + +Node9 + std::queue::push - - -Node3->Node7 + + +Node5->Node9 - - -Node9->Node2 - - - - - -Node9->Node3 - - - - - -Node9->Node8 - - - diff --git a/df/dce/namespacegraph.html b/df/dce/namespacegraph.html index 1d18e2454..bfd3bf104 100644 --- a/df/dce/namespacegraph.html +++ b/df/dce/namespacegraph.html @@ -156,7 +156,7 @@ Functions

    for IO operations for std::set

    Graph Algorithms

    A bipartite graph is the one whose nodes can be divided into two disjoint sets in such a way that the nodes in a set are not connected to each other at all, i.e. no intra-set connections. The only connections that exist are that of inter-set, i.e. the nodes from one set are connected to a subset of nodes in the other set. In this implementation, using a graph in the form of adjacency list, check whether the given graph is a bipartite or not.

    -

    References used: GeeksForGeeks

    Author
    tushar2407 for IO operations for queue data structure for vector data structure for assert
    +

    References used: GeeksForGeeks

    Author
    tushar2407 for assert for IO operations for queue data structure for vector data structure

    Graphical algorithms

    for std::min for assert for IO operations for limits of integral types for std::vector

    Function Documentation

    @@ -374,34 +374,37 @@ Here is the call graph for this function:

    insert the neighbouring node into the queue

    if both the current node and its neighbour has the same state then it is not a bipartite graph

    return true when all the connected nodes of the current nodes are travelled and satisify all the above conditions

    -
    40{
    -
    41 std::queue<int64_t> q; ///< stores the neighbouring node indexes in squence
    -
    42 /// of being reached
    -
    43 q.push(index); /// insert the current node into the queue
    -
    44 (*visited)[index] = 1; /// mark the current node as travelled
    -
    45 while(q.size())
    -
    46 {
    -
    47 int64_t u = q.front();
    -
    48 q.pop();
    -
    49 for(uint64_t i=0;i<graph[u].size();i++)
    -
    50 {
    -
    51 int64_t v = graph[u][i]; ///< stores the neighbour of the current node
    -
    52 if(!(*visited)[v]) /// check whether the neighbour node is
    -
    53 /// travelled already or not
    -
    54 {
    -
    55 (*visited)[v] = ((*visited)[u]==1)?-1:1; /// colour the neighbouring node with
    -
    56 /// different colour than the current node
    -
    57 q.push(v); /// insert the neighbouring node into the queue
    -
    58 }
    -
    59 else if((*visited)[v] == (*visited)[u]) /// if both the current node and its neighbour
    -
    60 /// has the same state then it is not a bipartite graph
    +
    37 {
    +
    38 std::queue<int64_t> q; ///< stores the neighbouring node indexes in squence
    +
    39 /// of being reached
    +
    40 q.push(index); /// insert the current node into the queue
    +
    41 (*visited)[index] = 1; /// mark the current node as travelled
    +
    42 while (q.size()) {
    +
    43 int64_t u = q.front();
    +
    44 q.pop();
    +
    45 for (uint64_t i = 0; i < graph[u].size(); i++) {
    +
    46 int64_t v =
    +
    47 graph[u][i]; ///< stores the neighbour of the current node
    +
    48 if (!(*visited)[v]) /// check whether the neighbour node is
    +
    49 /// travelled already or not
    +
    50 {
    +
    51 (*visited)[v] =
    +
    52 ((*visited)[u] == 1)
    +
    53 ? -1
    +
    54 : 1; /// colour the neighbouring node with
    +
    55 /// different colour than the current node
    +
    56 q.push(v); /// insert the neighbouring node into the queue
    +
    57 } else if ((*visited)[v] ==
    +
    58 (*visited)[u]) /// if both the current node and its
    +
    59 /// neighbour has the same state then it
    +
    60 /// is not a bipartite graph
    61 {
    62 return false;
    63 }
    64 }
    65 }
    -
    66 return true; /// return true when all the connected nodes of the current
    -
    67 /// nodes are travelled and satisify all the above conditions
    +
    66 return true; /// return true when all the connected nodes of the current
    +
    67 /// nodes are travelled and satisify all the above conditions
    68}
    Graph Algorithms.
    @@ -755,24 +758,25 @@ Here is the call graph for this function:
    Returns
    booleans

    < stores boolean values which signify whether that node had been visited or not

    if the current node is not visited then check whether the sub-graph of that node is a bipartite or not

    -
    76{
    -
    77 std::vector<int64_t> visited(graph.size()); ///< stores boolean values
    -
    78 /// which signify whether that node had been visited or not
    -
    79
    -
    80 for(uint64_t i=0;i<graph.size();i++)
    -
    81 {
    -
    82 if(!visited[i]) /// if the current node is not visited then check
    -
    83 /// whether the sub-graph of that node is a bipartite or not
    -
    84 {
    -
    85 if(!checkBipartite(graph, i, &visited))
    -
    86 {
    +
    75 {
    + +
    77 graph.size()); ///< stores boolean values
    +
    78 /// which signify whether that node had been visited or
    +
    79 /// not
    +
    80
    +
    81 for (uint64_t i = 0; i < graph.size(); i++) {
    +
    82 if (!visited[i]) /// if the current node is not visited then check
    +
    83 /// whether the sub-graph of that node is a bipartite
    +
    84 /// or not
    +
    85 {
    +
    86 if (!checkBipartite(graph, i, &visited)) {
    87 return false;
    88 }
    89 }
    90 }
    91 return true;
    92}
    -
    bool checkBipartite(const std::vector< std::vector< int64_t > > &graph, int64_t index, std::vector< int64_t > *visited)
    function to check whether the passed graph is bipartite or not
    Definition: is_graph_bipartite2.cpp:35
    +
    bool checkBipartite(const std::vector< std::vector< int64_t > > &graph, int64_t index, std::vector< int64_t > *visited)
    function to check whether the passed graph is bipartite or not
    Definition: is_graph_bipartite2.cpp:36
    Here is the call graph for this function:
    @@ -839,12 +843,12 @@ Here is the call graph for this function:
    54 int32_t curr_weight = 0;
    55
    56 //// compute current path weight
    -
    57 int k = src;
    +
    57 int k = src;
    58 for (int i : vtx) {
    -
    59 curr_weight += (*cities)[k][i];
    -
    60 k = i;
    +
    59 curr_weight += (*cities)[k][i];
    +
    60 k = i;
    61 }
    -
    62 curr_weight += (*cities)[k][src];
    +
    62 curr_weight += (*cities)[k][src];
    63
    64 //// update minimum
    65 min_path = std::min(min_path, curr_weight);
    @@ -855,6 +859,7 @@ Here is the call graph for this function:
    70}
    T begin(T... args)
    T end(T... args)
    +
    double k(double x)
    A function k(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:103
    T min(T... args)
    T next_permutation(T... args)
    T push_back(T... args)
    diff --git a/df/dd5/binary__search_8cpp.html b/df/dd5/binary__search_8cpp.html index fae99818c..d49a0a08c 100644 --- a/df/dd5/binary__search_8cpp.html +++ b/df/dd5/binary__search_8cpp.html @@ -159,19 +159,20 @@ Functions
    -1 if T is not found
    15 {
    -
    16 int l = 0;
    +
    16 int l = 0;
    17
    18 while (l <= r) {
    -
    19 int m = l + (r - l) / 2;
    +
    19 int m = l + (r - l) / 2;
    20 if (key == a[m])
    21 return m;
    22 else if (key < a[m])
    23 r = m - 1;
    24 else
    -
    25 l = m + 1;
    +
    25 l = m + 1;
    26 }
    27 return -1;
    28}
    +
    double l(double x)
    A function l(x) that will be used to test the method.
    Definition: midpoint_integral_method.cpp:109
    diff --git a/dir_9c6faab82c22511b50177aa2e38e2780.html b/dir_9c6faab82c22511b50177aa2e38e2780.html index 8f598b9d8..307ecf39d 100644 --- a/dir_9c6faab82c22511b50177aa2e38e2780.html +++ b/dir_9c6faab82c22511b50177aa2e38e2780.html @@ -120,6 +120,9 @@ Files file  lu_decomposition.h [code]  Functions associated with LU Decomposition of a square matrix.
      +file  midpoint_integral_method.cpp + A numerical method for easy approximation of integrals
    +  file  newton_raphson_method.cpp  Solve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions.
      diff --git a/dir_9c6faab82c22511b50177aa2e38e2780.js b/dir_9c6faab82c22511b50177aa2e38e2780.js index ef6c1a60d..cf6df4db0 100644 --- a/dir_9c6faab82c22511b50177aa2e38e2780.js +++ b/dir_9c6faab82c22511b50177aa2e38e2780.js @@ -8,6 +8,7 @@ var dir_9c6faab82c22511b50177aa2e38e2780 = [ "golden_search_extrema.cpp", "d6/d7a/golden__search__extrema_8cpp.html", "d6/d7a/golden__search__extrema_8cpp" ], [ "lu_decompose.cpp", "dd/d65/lu__decompose_8cpp.html", "dd/d65/lu__decompose_8cpp" ], [ "lu_decomposition.h", "d1/dbe/lu__decomposition_8h.html", "d1/dbe/lu__decomposition_8h" ], + [ "midpoint_integral_method.cpp", "df/d11/midpoint__integral__method_8cpp.html", "df/d11/midpoint__integral__method_8cpp" ], [ "newton_raphson_method.cpp", "de/dd3/newton__raphson__method_8cpp.html", "de/dd3/newton__raphson__method_8cpp" ], [ "ode_forward_euler.cpp", "db/dd3/ode__forward__euler_8cpp.html", "db/dd3/ode__forward__euler_8cpp" ], [ "ode_midpoint_euler.cpp", "d6/dd3/ode__midpoint__euler_8cpp.html", "d6/dd3/ode__midpoint__euler_8cpp" ], diff --git a/files.html b/files.html index 51deb6f04..55a6f1cd3 100644 --- a/files.html +++ b/files.html @@ -262,15 +262,16 @@ solve-a-rat-in-a-maze-c-java-pytho/"  golden_search_extrema.cppFind extrema of a univariate real function in a given interval using golden section search algorithm  lu_decompose.cppLU decomposition of a square matrix  lu_decomposition.hFunctions associated with LU Decomposition of a square matrix - newton_raphson_method.cppSolve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions - ode_forward_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using forward Euler method - ode_midpoint_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method - ode_semi_implicit_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler method - qr_decompose.hLibrary functions to compute QR decomposition of a given matrix - qr_decomposition.cppProgram to compute the QR decomposition of a given matrix - qr_eigen_values.cppCompute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method - rungekutta.cppRunge Kutta fourth order method implementation - successive_approximation.cppMethod of successive approximations using fixed-point iteration method + midpoint_integral_method.cppA numerical method for easy approximation of integrals + newton_raphson_method.cppSolve the equation \(f(x)=0\) using Newton-Raphson method for both real and complex solutions + ode_forward_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using forward Euler method + ode_midpoint_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method + ode_semi_implicit_euler.cppSolve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler method + qr_decompose.hLibrary functions to compute QR decomposition of a given matrix + qr_decomposition.cppProgram to compute the QR decomposition of a given matrix + qr_eigen_values.cppCompute real eigen values and eigen vectors of a symmetric matrix using QR decomposition method + rungekutta.cppRunge Kutta fourth order method implementation + successive_approximation.cppMethod of successive approximations using fixed-point iteration method   operations_on_datastructures  array_left_rotation.cppImplementation for the Array Left Rotation algorithm  array_right_rotation.cppImplementation for the Array right Rotation algorithm diff --git a/globals_func_m.html b/globals_func_m.html index 7508105c8..6b9392b7d 100644 --- a/globals_func_m.html +++ b/globals_func_m.html @@ -93,7 +93,7 @@ $(document).ready(function(){initNavTree('globals_func_m.html',''); initResizabl  

    - m -