From f90167552b8470dd48ef88730f9c0b7fbf075d7d Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 31 May 2023 02:53:49 +0000 Subject: [PATCH] Documentation for 33750ec1f89bfdf0d24b9aec7cb247d5c8a9414a --- d5/d95/n__bonacci_8cpp__incl.map | 9 +- d5/d95/n__bonacci_8cpp__incl.md5 | 2 +- d5/d95/n__bonacci_8cpp__incl.svg | 47 ++---- db/d27/n__bonacci_8cpp.html | 144 ++++++++---------- ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 7 +- ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 2 +- ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 65 ++------ ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 9 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 2 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 73 ++------- dd/d47/namespacemath.html | 2 +- 11 files changed, 116 insertions(+), 246 deletions(-) diff --git a/d5/d95/n__bonacci_8cpp__incl.map b/d5/d95/n__bonacci_8cpp__incl.map index f8b9f4f01..245615d1d 100644 --- a/d5/d95/n__bonacci_8cpp__incl.map +++ b/d5/d95/n__bonacci_8cpp__incl.map @@ -1,7 +1,6 @@ - - - - - + + + + diff --git a/d5/d95/n__bonacci_8cpp__incl.md5 b/d5/d95/n__bonacci_8cpp__incl.md5 index 57b5fd5cc..ae12bfbab 100644 --- a/d5/d95/n__bonacci_8cpp__incl.md5 +++ b/d5/d95/n__bonacci_8cpp__incl.md5 @@ -1 +1 @@ -2621374471b0f9f68aa8347260643de3 \ No newline at end of file +560780ba81458fb0c0c830c5c5bf30a8 \ No newline at end of file diff --git a/d5/d95/n__bonacci_8cpp__incl.svg b/d5/d95/n__bonacci_8cpp__incl.svg index 5a974d4eb..3bd6a3971 100644 --- a/d5/d95/n__bonacci_8cpp__incl.svg +++ b/d5/d95/n__bonacci_8cpp__incl.svg @@ -4,16 +4,16 @@ - + math/n_bonacci.cpp Node1 - -math/n_bonacci.cpp + +math/n_bonacci.cpp @@ -21,61 +21,46 @@ Node2 - -algorithm + +cassert Node1->Node2 - - + + Node3 - -cassert + +iostream Node1->Node3 - - + + Node4 - -iostream + +vector Node1->Node4 - - - - - -Node5 - - -vector - - - - - -Node1->Node5 - - + + diff --git a/db/d27/n__bonacci_8cpp.html b/db/d27/n__bonacci_8cpp.html index 263ffd517..7b030d118 100644 --- a/db/d27/n__bonacci_8cpp.html +++ b/db/d27/n__bonacci_8cpp.html @@ -106,14 +106,13 @@ $(document).ready(function(){initNavTree('db/d27/n__bonacci_8cpp.html','../../')

Implementation of the N-bonacci series. More...

-
#include <algorithm>
-#include <cassert>
+
#include <cassert>
#include <iostream>
#include <vector>
Include dependency graph for n_bonacci.cpp:
-
+
@@ -162,15 +161,15 @@ Functions

Main function.

Returns
0 on exit
-
120 {
-
121 test(); // run self-test implementations
-
122 return 0;
-
123}
-
static void test()
Self-test implementations.
Definition: n_bonacci.cpp:63
+
104 {
+
105 test(); // run self-test implementations
+
106 return 0;
+
107}
+
static void test()
Self-test implementations.
Definition: n_bonacci.cpp:69
Here is the call graph for this function:
-
+
@@ -213,21 +212,28 @@ Here is the call graph for this function:
Returns
the n-bonacci sequence as vector array

we initialise the (n-1)th term as 1 which is the sum of preceding N zeros

similarily the sum of preceding N zeros and the (N+1)th 1 is also 1

-
41 {
-
42 std::vector<uint64_t> a(m, 0); // we create an empty array of size m
-
43
-
44 a[n - 1] = 1; /// we initialise the (n-1)th term as 1 which is the sum of
-
45 /// preceding N zeros
-
46 a[n] = 1; /// similarily the sum of preceding N zeros and the (N+1)th 1 is
-
47 /// also 1
-
48 for (uint64_t i = n + 1; i < m; i++) {
-
49 // this is an optimized solution that works in O(M) time and takes O(M)
-
50 // extra space here we use the concept of the sliding window the current
-
51 // term can be computed using the given formula
-
52 a[i] = 2 * a[i - 1] - a[i - 1 - n];
-
53 }
-
54 return a;
-
55}
+
40 {
+ +
42 m, 0); // we create an array of size m filled with zeros
+
43 if (m < n || n == 0) {
+
44 return a;
+
45 }
+
46
+
47 a[n - 1] = 1; /// we initialise the (n-1)th term as 1 which is the sum of
+
48 /// preceding N zeros
+
49 if (n == m) {
+
50 return a;
+
51 }
+
52 a[n] = 1; /// similarily the sum of preceding N zeros and the (N+1)th 1 is
+
53 /// also 1
+
54 for (uint64_t i = n + 1; i < m; i++) {
+
55 // this is an optimized solution that works in O(M) time and takes O(M)
+
56 // extra space here we use the concept of the sliding window the current
+
57 // term can be computed using the given formula
+
58 a[i] = 2 * a[i - 1] - a[i - 1 - n];
+
59 }
+
60 return a;
+
61}
Here is the call graph for this function:
@@ -263,68 +269,44 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
63 {
-
64 // n = 1 m = 1 return [1, 1]
-
65 std::cout << "1st test";
- -
67 1, 1); // first input is the param n and second one is the param m for
-
68 // N-bonacci func
-
69 std::vector<uint64_t> output_array1 = {
-
70 1, 1}; // It is the expected output series of length m
-
71 assert(std::equal(std::begin(arr1), std::end(arr1),
-
72 std::begin(output_array1)));
-
73 std::cout << "passed" << std::endl;
-
74
-
75 // n = 5 m = 15 return [0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 31, 61, 120, 236,
-
76 // 464]
-
77 std::cout << "2nd test";
- -
79 5, 15); // first input is the param n and second one is the param m for
-
80 // N-bonacci func
-
81 std::vector<uint64_t> output_array2 = {
-
82 0, 0, 0, 0, 1, 1, 2, 4,
-
83 8, 16, 31, 61, 120, 236, 464}; // It is the expected output series of
-
84 // length m
-
85 assert(std::equal(std::begin(arr2), std::end(arr2),
-
86 std::begin(output_array2)));
-
87 std::cout << "passed" << std::endl;
-
88
-
89 // n = 6 m = 17 return [0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248,
-
90 // 492, 976]
-
91 std::cout << "3rd test";
- -
93 6, 17); // first input is the param n and second one is the param m for
-
94 // N-bonacci func
-
95 std::vector<uint64_t> output_array3 = {
-
96 0, 0, 0, 0, 0, 1, 1, 2, 4,
-
97 8, 16, 32, 63, 125, 248, 492, 976}; // It is the expected output series
-
98 // of length m
-
99 assert(std::equal(std::begin(arr3), std::end(arr3),
-
100 std::begin(output_array3)));
-
101 std::cout << "passed" << std::endl;
-
102
-
103 // n = 56 m = 15 return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-
104 std::cout << "4th test";
- -
106 56, 15); // first input is the param n and second one is the param m
-
107 // for N-bonacci func
-
108 std::vector<uint64_t> output_array4 = {
-
109 0, 0, 0, 0, 0, 0, 0, 0,
-
110 0, 0, 0, 0, 0, 0, 0}; // It is the expected output series of length m
-
111 assert(std::equal(std::begin(arr4), std::end(arr4),
-
112 std::begin(output_array4)));
-
113 std::cout << "passed" << std::endl;
-
114}
+
69 {
+
70 struct TestCase {
+
71 const uint64_t n;
+
72 const uint64_t m;
+
73 const std::vector<uint64_t> expected;
+
74 TestCase(const uint64_t in_n, const uint64_t in_m,
+ +
76 : n(in_n), m(in_m), expected(data) {
+
77 assert(data.size() == m);
+
78 }
+
79 };
+
80 const std::vector<TestCase> test_cases = {
+
81 TestCase(0, 0, {}),
+
82 TestCase(0, 1, {0}),
+
83 TestCase(0, 2, {0, 0}),
+
84 TestCase(1, 0, {}),
+
85 TestCase(1, 1, {1}),
+
86 TestCase(1, 2, {1, 1}),
+
87 TestCase(1, 3, {1, 1, 1}),
+
88 TestCase(5, 15, {0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 31, 61, 120, 236, 464}),
+
89 TestCase(
+
90 6, 17,
+
91 {0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248, 492, 976}),
+
92 TestCase(56, 15, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})};
+
93
+
94 for (const auto &tc : test_cases) {
+
95 assert(math::n_bonacci::N_bonacci(tc.n, tc.m) == tc.expected);
+
96 }
+
97 std::cout << "passed" << std::endl;
+
98}
-
T begin(T... args)
-
T end(T... args)
T endl(T... args)
-
T equal(T... args)
-
std::vector< uint64_t > N_bonacci(const uint64_t &n, const uint64_t &m)
Finds the N-Bonacci series for the n parameter value and m parameter terms.
Definition: n_bonacci.cpp:41
+
int data[MAX]
test data
Definition: hash_search.cpp:24
+
Here is the call graph for this function:
-
+
diff --git a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map index 6fb51286b..cf1353460 100644 --- a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map +++ b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -1,7 +1,4 @@ - - - - - + + diff --git a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 index ece238875..77de60e3f 100644 --- a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 +++ b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -1 +1 @@ -100237f3396188af4089a52f8dfab1c0 \ No newline at end of file +f486c9c49ba8056684cc8746d21a532f \ No newline at end of file diff --git a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg index 87845970b..268a1ad21 100644 --- a/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg +++ b/db/d27/n__bonacci_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -4,78 +4,33 @@ - - + + test Node1 - -test + +test Node2 - - -std::begin + + +std::endl Node1->Node2 - - - - - -Node3 - - -std::end - - - - - -Node1->Node3 - - - - - -Node4 - - -std::endl - - - - - -Node1->Node4 - - - - - -Node5 - - -std::equal - - - - - -Node1->Node5 - - + + diff --git a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map index 6ffada44a..7892d9a13 100644 --- a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map +++ b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -1,8 +1,5 @@ - - - - - - + + + diff --git a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 index eca418974..7102b1466 100644 --- a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 +++ b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -1 +1 @@ -6e413a1379bdcfde8a5d64890f8a34af \ No newline at end of file +ae3a6dc3065298e66fd9a09de00f9083 \ No newline at end of file diff --git a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg index 4861b5574..cd2d1cb5d 100644 --- a/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg +++ b/db/d27/n__bonacci_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -4,16 +4,16 @@ - - + + main Node1 - -main + +main @@ -21,76 +21,31 @@ Node2 - -test + +test Node1->Node2 - - + + Node3 - - -std::begin + + +std::endl Node2->Node3 - - - - - -Node4 - - -std::end - - - - - -Node2->Node4 - - - - - -Node5 - - -std::endl - - - - - -Node2->Node5 - - - - - -Node6 - - -std::equal - - - - - -Node2->Node6 - - + + diff --git a/dd/d47/namespacemath.html b/dd/d47/namespacemath.html index 9ea8ebd60..c19847630 100644 --- a/dd/d47/namespacemath.html +++ b/dd/d47/namespacemath.html @@ -281,7 +281,7 @@ Algorithm

This problem can be solved using matrix exponentiation method.

See also
here for simple number exponentiation algorithm or explaination here.
Author
Ashish Daulatabad for assert for IO operations for std::vector STL

Mathematical algorithms

-

for std::is_equal, std::swap for assert for IO operations

+

for assert for std::cout

Mathematical algorithms

for assert for io operations

Mathematical algorithms