From 705d498d06c6e18e50303eb89b8a4dd6481f8441 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 23 Jul 2020 11:53:31 +0000 Subject: [PATCH] Documentation for 42e1246ffcbb2954bbb20cc4a7c51a8611fe8fd6 --- d1/dbe/lu__decomposition_8h_source.html | 8 +- d4/d86/large__number_8h_source.html | 2 +- d4/d9c/primes__up__to__billion_8cpp.html | 2 +- d6/d2c/caesar__cipher_8cpp.html | 2 +- d8/ddf/sieve__of__eratosthenes_8cpp.html | 165 +++++++++++------- d8/ddf/sieve__of__eratosthenes_8cpp.js | 5 +- ...5843bdf82d2a6cc8596ae8fd3b8df9_cgraph.map} | 3 +- ...35843bdf82d2a6cc8596ae8fd3b8df9_cgraph.md5 | 1 + ...35843bdf82d2a6cc8596ae8fd3b8df9_cgraph.svg | 52 ++++++ ...0fa6579eab0db3c1c0ab1bf6d651be3_cgraph.map | 4 + ...0fa6579eab0db3c1c0ab1bf6d651be3_cgraph.md5 | 1 + ...0fa6579eab0db3c1c0ab1bf6d651be3_cgraph.svg | 37 ++++ ...8ec9ad42717780d6caaff9d3d6977f9_cgraph.map | 6 + ...8ec9ad42717780d6caaff9d3d6977f9_cgraph.md5 | 1 + ...8ec9ad42717780d6caaff9d3d6977f9_cgraph.svg | 67 +++++++ ...0de20c22cf2304b1cbe70953d57e7b7_cgraph.md5 | 1 - ...0de20c22cf2304b1cbe70953d57e7b7_cgraph.svg | 37 ---- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 11 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 2 +- ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 129 ++++++++++---- da/d35/sieve__of__eratosthenes_8cpp__incl.map | 6 +- da/d35/sieve__of__eratosthenes_8cpp__incl.md5 | 2 +- da/d35/sieve__of__eratosthenes_8cpp__incl.svg | 50 ++++-- de/d9b/prime__numbers_8cpp.html | 2 +- dir_296d53ceaeaa7e099814a6def439fe8a.html | 2 +- files.html | 2 +- globals_func_p.html | 2 +- globals_func_s.html | 2 +- globals_func_t.html | 9 +- globals_p.html | 2 +- globals_s.html | 2 +- globals_t.html | 9 +- navtreedata.js | 4 +- navtreeindex2.js | 12 +- navtreeindex3.js | 6 +- navtreeindex4.js | 3 +- search/all_10.js | 2 +- search/all_13.js | 2 +- search/all_14.js | 2 +- search/functions_10.js | 2 +- search/functions_13.js | 2 +- search/functions_14.js | 2 +- 42 files changed, 466 insertions(+), 197 deletions(-) rename d8/ddf/{sieve__of__eratosthenes_8cpp_ae0de20c22cf2304b1cbe70953d57e7b7_cgraph.map => sieve__of__eratosthenes_8cpp_a235843bdf82d2a6cc8596ae8fd3b8df9_cgraph.map} (50%) create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a235843bdf82d2a6cc8596ae8fd3b8df9_cgraph.md5 create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a235843bdf82d2a6cc8596ae8fd3b8df9_cgraph.svg create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a60fa6579eab0db3c1c0ab1bf6d651be3_cgraph.map create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a60fa6579eab0db3c1c0ab1bf6d651be3_cgraph.md5 create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a60fa6579eab0db3c1c0ab1bf6d651be3_cgraph.svg create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.map create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.md5 create mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_a88ec9ad42717780d6caaff9d3d6977f9_cgraph.svg delete mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_ae0de20c22cf2304b1cbe70953d57e7b7_cgraph.md5 delete mode 100644 d8/ddf/sieve__of__eratosthenes_8cpp_ae0de20c22cf2304b1cbe70953d57e7b7_cgraph.svg diff --git a/d1/dbe/lu__decomposition_8h_source.html b/d1/dbe/lu__decomposition_8h_source.html index bd7515903..70f9131ac 100644 --- a/d1/dbe/lu__decomposition_8h_source.html +++ b/d1/dbe/lu__decomposition_8h_source.html @@ -212,7 +212,6 @@ $(document).ready(function(){initNavTree('d1/dbe/lu__decomposition_8h_source.htm
test3
void test3()
Test function to find maxima for the function in the interval Expected result: .
Definition: brent_method_extrema.cpp:188
std::string
STL class.
std::uniform_int_distribution
-
print
void print(uint32_t N, const bool *isprime)
Definition: sieve_of_eratosthenes.cpp:38
primes
std::vector< int > primes(int max)
Definition: prime_numbers.cpp:12
miller_rabin_primality_test
bool miller_rabin_primality_test(T num, T repeats)
Definition: miller_rabin.cpp:125
std::clock_t
@@ -225,7 +224,8 @@ $(document).ready(function(){initNavTree('d1/dbe/lu__decomposition_8h_source.htm
std::vector::size
T size(T... args)
multiply
int multiply(int x, int res[], int res_size)
Definition: power_for_huge_numbers.cpp:25
ans
ll ans(ll n)
Definition: matrix_exponentiation.cpp:91
-
main
int main()
Definition: sieve_of_eratosthenes.cpp:50
+
main
int main()
Definition: sieve_of_eratosthenes.cpp:65
+
sieve
std::vector< bool > sieve(uint32_t N)
Definition: sieve_of_eratosthenes.cpp:26
complex_str
const char * complex_str(const std::complex< double > &x)
Definition: durand_kerner_roots.cpp:76
test3
void test3()
Test function to find maxima for the function in the interval Expected result: .
Definition: golden_search_extrema.cpp:123
get_minima
double get_minima(const std::function< double(double)> &f, double lim_a, double lim_b)
Get the real root of a function in the given interval.
Definition: brent_method_extrema.cpp:35
@@ -239,6 +239,7 @@ $(document).ready(function(){initNavTree('d1/dbe/lu__decomposition_8h_source.htm
std::sqrt
T sqrt(T... args)
power
void power(int x, int n)
Definition: power_for_huge_numbers.cpp:56
test1
void test1()
Test function to find minima for the function in the interval Expected result = 2.
Definition: golden_search_extrema.cpp:78
+
is_prime
bool is_prime(T num)
Definition: check_prime.cpp:22
main
int main()
Definition: prime_numbers.cpp:26
std::mt19937
std::vector::push_back
T push_back(T... args)
@@ -274,10 +275,10 @@ $(document).ready(function(){initNavTree('d1/dbe/lu__decomposition_8h_source.htm
statistics::stats_computer2
Definition: realtime_stats.cpp:72
main
int main(int argc, char **argv)
Definition: realtime_stats.cpp:158
sgn
int sgn(T val)
Definition: false_position.cpp:34
+
print
void print(uint32_t N, const std::vector< bool > &is_prime)
Definition: sieve_of_eratosthenes.cpp:44
std::rand
T rand(T... args)
std::swap
T swap(T... args)
lu_decomposition.h
Functions associated with LU Decomposition of a square matrix.
-
sieve
void sieve(uint32_t N, bool *isprime)
Definition: sieve_of_eratosthenes.cpp:21
test_function
void test_function(const float *test_data, const int number_of_samples)
Definition: realtime_stats.cpp:118
SieveOfEratosthenes
void SieveOfEratosthenes(int N)
Definition: prime_factorization.cpp:23
std::string::substr
T substr(T... args)
@@ -315,6 +316,7 @@ $(document).ready(function(){initNavTree('d1/dbe/lu__decomposition_8h_source.htm
std::time
T time(T... args)
MAX_ITERATIONS
#define MAX_ITERATIONS
Maximum number of iterations to check.
Definition: bisection_method.cpp:22
std::vector::cend
T cend(T... args)
+
tests
void tests()
Definition: sieve_of_eratosthenes.cpp:56
std::setw
T setw(T... args)
std::max
T max(T... args)
main
int main()
Definition: string_fibonacci.cpp:81
diff --git a/d4/d86/large__number_8h_source.html b/d4/d86/large__number_8h_source.html index 428bbedd6..6202e701f 100644 --- a/d4/d86/large__number_8h_source.html +++ b/d4/d86/large__number_8h_source.html @@ -406,7 +406,6 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::domain_error
STL class.
std::string
STL class.
std::shared_ptr
STL class.
-
print
void print(uint32_t N, const bool *isprime)
Definition: sieve_of_eratosthenes.cpp:38
MAX
#define MAX
Definition: fibonacci_fast.cpp:27
Graph::addVertices
void addVertices(unsigned int num=1)
Definition: cycle_check_directed_graph.cpp:118
test1
bool test1()
Definition: large_factorial.cpp:17
@@ -581,6 +580,7 @@ $(document).ready(function(){initNavTree('d4/d86/large__number_8h_source.html','
std::is_integral
main
int main()
Definition: check_prime.cpp:45
test2
bool test2()
Definition: large_factorial.cpp:54
+
print
void print(uint32_t N, const std::vector< bool > &is_prime)
Definition: sieve_of_eratosthenes.cpp:44
Graph::Graph
Graph(unsigned int vertices, AdjList &&adjList)
Definition: cycle_check_directed_graph.cpp:76
std::priority_queue
STL class.
std::rand
T rand(T... args)
diff --git a/d4/d9c/primes__up__to__billion_8cpp.html b/d4/d9c/primes__up__to__billion_8cpp.html index 5385690b1..3ec910d11 100644 --- a/d4/d9c/primes__up__to__billion_8cpp.html +++ b/d4/d9c/primes__up__to__billion_8cpp.html @@ -123,7 +123,7 @@ Variables

Detailed Description

Compute prime numbers upto 1 billion.

-
See also
prime_numbers.cpp sieve_of_eratosthenes.cpp
+
See also
prime_numbers.cpp sieve_of_eratosthenes.cpp

Function Documentation

◆ main()

diff --git a/d6/d2c/caesar__cipher_8cpp.html b/d6/d2c/caesar__cipher_8cpp.html index 66e31e167..3497be542 100644 --- a/d6/d2c/caesar__cipher_8cpp.html +++ b/d6/d2c/caesar__cipher_8cpp.html @@ -345,7 +345,6 @@ Here is the call graph for this function:
tolowerRoman
std::string tolowerRoman(int n)
Definition: decimal_to_roman_numeral.cpp:24
test_f
void test_f(const int NUM_DATA)
Definition: shell_sort2.cpp:145
string_search
String search algorithms.
Definition: brute_force_string_searching.cpp:13
-
print
void print(uint32_t N, const bool *isprime)
Definition: sieve_of_eratosthenes.cpp:38
MAX
#define MAX
Definition: fibonacci_fast.cpp:27
show_data
void show_data(T *arr, size_t LEN)
Definition: shell_sort2.cpp:18
std::list
STL class.
@@ -484,6 +483,7 @@ Here is the call graph for this function:
main
int main(int argc, char **argv)
Definition: qr_eigen_values.cpp:243
std::ceil
T ceil(T... args)
circle
double circle(const std::vector< Point > &P)
Definition: smallest_circle.cpp:87
+
print
void print(uint32_t N, const std::vector< bool > &is_prime)
Definition: sieve_of_eratosthenes.cpp:44
eq
static float eq(float y)
Definition: successive_approximation.cpp:12
test_int
static void test_int()
Definition: quick_sort_3.cpp:138
struzik_search
Type * struzik_search(Type *array, size_t size, Type key)
Definition: exponential_search.cpp:59
diff --git a/d8/ddf/sieve__of__eratosthenes_8cpp.html b/d8/ddf/sieve__of__eratosthenes_8cpp.html index 0c7399d28..2310fe807 100644 --- a/d8/ddf/sieve__of__eratosthenes_8cpp.html +++ b/d8/ddf/sieve__of__eratosthenes_8cpp.html @@ -97,28 +97,33 @@ $(document).ready(function(){initNavTree('d8/ddf/sieve__of__eratosthenes_8cpp.ht
-

Get list of prime numbers using Sieve of Eratosthenes Sieve of Eratosthenes is an algorithm to find the primes that is between 2 to N (as defined in main). +

Get list of prime numbers using Sieve of Eratosthenes. More...

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

Functions

void sieve (uint32_t N, bool *isprime)
 
void print (uint32_t N, const bool *isprime)
 
std::vector< bool > sieve (uint32_t N)
 
void print (uint32_t N, const std::vector< bool > &is_prime)
 
void tests ()
 
int main ()
 

Detailed Description

-

Get list of prime numbers using Sieve of Eratosthenes Sieve of Eratosthenes is an algorithm to find the primes that is between 2 to N (as defined in main).

-

Time Complexity : \(O(N \cdot\log N)\)
+

Get list of prime numbers using Sieve of Eratosthenes.

+

Sieve of Eratosthenes is an algorithm that finds all the primes between 2 and N.

+

Time Complexity : \(O(N \cdot\log \log N)\)
Space Complexity : \(O(N)\)

See also
primes_up_to_billion.cpp prime_numbers.cpp

Function Documentation

@@ -137,26 +142,25 @@ Space Complexity : \(O(N)\)

Main function

-
50  {
-
51  uint32_t N = 100;
-
52  bool *isprime = new bool[N];
-
53  sieve(N, isprime);
-
54  print(N, isprime);
-
55  delete[] isprime;
-
56 
-
57  return 0;
-
58 }
+
65  {
+
66  tests();
+
67 
+
68  uint32_t N = 100;
+ +
70  print(N, is_prime);
+
71  return 0;
+
72 }
Here is the call graph for this function:
-
+
- -

◆ print()

+ +

◆ print()

@@ -170,8 +174,8 @@ Here is the call graph for this function:
- const bool *  - isprime  + const std::vector< bool > &  + is_prime  @@ -182,81 +186,110 @@ Here is the call graph for this function:

This function prints out the primes to STDOUT

Parameters
- - + +
Nnumber of primes to check
[in]isprimea boolean array of size N identifying if i^th number is prime or not
Nnumber of primes to check
is_primea vector of N + 1 booleans identifying if i^th number is a prime or not
-
38  {
-
39  for (uint32_t i = 2; i <= N; i++) {
-
40  if (!isprime[i]) {
-
41  std::cout << i << ' ';
-
42  }
-
43  }
- -
45 }
+
44  {
+
45  for (uint32_t i = 2; i <= N; i++) {
+
46  if (is_prime[i]) {
+
47  std::cout << i << ' ';
+
48  }
+
49  }
+ +
51 }
Here is the call graph for this function:
-
+
- -

◆ sieve()

+ +

◆ sieve()

- + - - - - + - - - - - - -
void sieve std::vector<bool> sieve ( uint32_t N,
N) bool * isprime 
)
-

This is the function that finds the primes and eliminates the multiples.

Parameters
+

This is the function that finds the primes and eliminates the multiples. Contains a common optimization to start eliminating multiples of a prime p starting from p * p since all of the lower multiples have been already eliminated.

Parameters
- - +
Nnumber of primes to check
[out]isprimea boolean array of size N identifying if i^th number is prime or not
Nnumber of primes to check
-
21  {
-
22  isprime[0] = true;
-
23  isprime[1] = true;
-
24  for (uint32_t i = 2; i * i <= N; i++) {
-
25  if (!isprime[i]) {
-
26  for (uint32_t j = (i << 1); j <= N; j = j + i) {
-
27  isprime[j] = true;
-
28  }
-
29  }
-
30  }
-
31 }
-
+
Returns
is_prime a vector of N + 1 booleans identifying if i^th number is a prime or not
+
26  {
+
27  std::vector<bool> is_prime(N + 1, true);
+
28  is_prime[0] = is_prime[1] = false;
+
29  for (uint32_t i = 2; i * i <= N; i++) {
+
30  if (is_prime[i]) {
+
31  for (uint32_t j = i * i; j <= N; j += i) {
+
32  is_prime[j] = false;
+
33  }
+
34  }
+
35  }
+
36  return is_prime;
+
37 }
+
+Here is the call graph for this function:
+
+
+
+
+ +
+
+ +

◆ tests()

+ +
+
+ + + + + + + +
void tests ()
+
+

Test implementations

+
56  {
+
57  // 0 1 2 3 4 5 6 7 8 9 10
+
58  std::vector<bool> ans{false, false, true, true, false, true, false, true, false, false, false};
+
59  assert(sieve(10) == ans);
+
60 }
+
+Here is the call graph for this function:
+
+
+
+
+
-
void print(uint32_t N, const bool *isprime)
Definition: sieve_of_eratosthenes.cpp:38
+ +
ll ans(ll n)
Definition: matrix_exponentiation.cpp:91
+
std::vector< bool > sieve(uint32_t N)
Definition: sieve_of_eratosthenes.cpp:26
+
bool is_prime(T num)
Definition: check_prime.cpp:22
-
void sieve(uint32_t N, bool *isprime)
Definition: sieve_of_eratosthenes.cpp:21
+
void print(uint32_t N, const std::vector< bool > &is_prime)
Definition: sieve_of_eratosthenes.cpp:44
T endl(T... args)
-
bool isprime[1000006]
Definition: prime_factorization.cpp:13
+
void tests()
Definition: sieve_of_eratosthenes.cpp:56