Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
sigmaodd.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 /** \file common/sigmaodd/sigmaodd.hpp (January 18, 2018)
3  * \brief
4  * Main functions to deal the sigma_odd problem.
5  *
6  * GPLv3 --- Copyright (C) 2017, 2018 Olivier Pirson
7  * http://www.opimedia.be/
8  */
9 
10 #ifndef PROGS_SRC_COMMON_SIGMAODD_SIGMAODD_HPP_
11 #define PROGS_SRC_COMMON_SIGMAODD_SIGMAODD_HPP_
12 
13 // \cond
14 #include <map>
15 #include <ostream>
16 #include <set>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 // \endcond
21 
22 #include "divisors.hpp"
23 
24 
25 namespace sigmaodd {
26 
27  /* ************
28  * Prototypes *
29  **************/
30 
31  /** \brief
32  * Iterate from first to last (included)
33  * and for each odd n such that is_little_mersenne_prime_unitary_divide(n) is false,
34  * iterate var_sum() until the result is <= n.
35  *
36  * If need more that one iteration
37  * then print n and the number of iterations.
38  *
39  * @param first_n odd >= 3
40  * @param last_n
41  */
42  void
43  check_varsigma_odd(nat_type first_n, nat_type last_n);
44 
45 
46  /**
47  * Return a string representation of the path.
48  * All numbers are separated by the corresponding <, = or > symbol.
49  */
50  std::string
51  path_to_string(const std::vector<nat_type> &path);
52 
53 
54  /** \brief
55  * Iterate from first to last (included)
56  * and for each odd n *not* square such that is_little_mersenne_prime_unitary_divide(n) is false,
57  * if varsum_odd(n) > n then print n and varsum_odd(n).
58  *
59  * If varsum_odd(n) is not divisible by 3, 5, 7 or 9
60  * then after n print '!' follow by this number.
61  *
62  * If varsum_odd(n) is a perfect square
63  * then after varsum_odd(n) print '#'.
64  *
65  * @param first odd >= 3
66  * @param last
67  * @param print_path
68  */
69  void
70  print_long(nat_type first, nat_type last, bool print_path);
71 
72 
73  /** \brief
74  * Send to the stream a string representation of the path.
75  * All numbers are separated by the corresponding <, = or > symbol.
76  *
77  * @param path must be a correct complete path from a number n to the number 1
78  * @param out
79  */
80  void
81  print_path(const std::vector<nat_type> &path, std::ostream &out = std::cout);
82 
83 
84  /** \brief
85  * Send to the stream a string representation of the path,
86  * from path_begin to path_end (included).
87  * All numbers are separated by the corresponding <, = or > symbol.
88  *
89  * @param path_begin with path_end must be a correct piece of a correct path
90  * @param path_end
91  * @param out
92  */
93  void
94  print_path(const std::vector<nat_type>::const_iterator &path_begin,
95  const std::vector<nat_type>::const_iterator &path_end,
96  std::ostream &out = std::cout);
97 
98  /** \brief
99  * Send (if the below condition is true) to the stream a string representation of the path
100  * with some information depending of the boolean parameters.
101  *
102  * Print only if print_all
103  * or if print_bad
104  * and the path start from a bad number (i.e. odd
105  * and *not* perfect square
106  * and partial length > 1).
107  *
108  * List of information (maybe) printed, separated by tabulations:
109  * * n
110  * * Category of n ('E': even, 'F': fixed point, 'S': odd perfect square,
111  * 'B': bad number or 'G': gentle number)
112  * * First number < n
113  * * Length of the partial path
114  * * Partial path (beginning of the path, until the first number < n, included)
115  * * Length of the path
116  * * Path
117  *
118  * If n is a bad number but is *not* divisible by 9
119  * then print " *" after n.
120  *
121  * If length > n
122  * then print a " *" after the partial length.
123  *
124  * If the partial path is the complete path
125  * then do not repeat the length and the path.
126  *
127  * @param path must be a correct complete path from a number n to the number 1 or a correct partial path from a number to the first number < n
128  * @param print_bad
129  * @param print_all
130  * @param print_category
131  * @param print_lower
132  * @param print_length
133  * @param print_path
134  * @param out
135  */
136  void
137  print_path_infos(const std::vector<nat_type> &path,
138  bool print_bad = true,
139  bool print_all = false,
140  bool print_category = true,
141  bool print_lower = true,
142  bool print_length = true,
143  bool print_path = true,
144  std::ostream &out = std::cout);
145 
146 
147  /** \brief
148  * Iterate from first to last (included)
149  * and print result of the sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize(n)
150  * with some informations.
151  *
152  * If print_only_longer
153  * then for each n print only the longer found.
154  *
155  * If print_path
156  * then for each n print also the complete path
157  * (recalculate by iteration of sum_odd_divisors_divided_until_odd__factorize(n)).
158  *
159  * @param first odd >= 3
160  * @param last
161  * @param print_only_longer
162  * @param print_path
163  */
164  void
166  bool print_only_longer, bool print_path);
167 
168 
169  /** \brief
170  * Iterate from first to last (included)
171  * and print result of the sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize_bound(n)
172  * with some informations.
173  *
174  * If print_only_longer
175  * then for each n print only the longer found.
176  *
177  * If print_path
178  * then for each n print also the complete path
179  * (recalculate by iteration of sum_odd_divisors_divided_until_odd__factorize(n)).
180  *
181  * @param first odd >= 3
182  * @param last
183  * @param print_only_longer
184  * @param print_path
185  */
186  void
188  bool print_only_longer, bool print_path);
189 
190 
191  /** \brief
192  * Iterate from first to last (included)
193  * and print result of the sum_odd_divisors_divided_until_odd_iterate_until_lower__naive(n)
194  * with some informations.
195  *
196  * If print_only_longer
197  * then for each n print only the longer found.
198  *
199  * If print_path
200  * then for each n print also the complete path
201  * (recalculate by iteration of sum_odd_divisors_divided_until_odd__factorize(n)).
202  *
203  * @param first odd >= 3
204  * @param last
205  * @param print_only_longer
206  * @param print_path
207  */
208  void
210  bool print_only_longer, bool print_path);
211 
212 
213  void
214  print_square(nat_type first, nat_type last, bool print_path);
215 
216 
217  /** \brief
218  * Calculates the sum of all odd divisors of n by the Euler formula method,
219  * divides the results by 2 until becomes odd,
220  * and returns it.
221  *
222  * @param n != 0
223  *
224  * @return the sum of all odd divisors of n
225  */
226  nat_type
228 
229 
230  /** \brief
231  * Calculates the sum of all odd divisors of n by the factorization method,
232  * divides the results by 2 until becomes odd,
233  * and returns it.
234  *
235  * If skip_primes_table
236  * then n must not be divisible by prime number in the primes precalculated table.
237  *
238  * @param n != 0
239  * @param skip_primes_table
240  *
241  * @return the sum of all odd divisors of n
242  */
243  nat_type
244  sum_odd_divisors_divided_until_odd__factorize(nat_type n, bool skip_primes_table = false);
245 
246 
247  /** \brief
248  * Calculates the sum of all odd divisors of n by the factorization method,
249  * divides the results by 2 until becomes odd,
250  * and returns it.
251  * ??? with bound
252  *
253  * @param n != 0
254  * @param start_n
255  *
256  * @return the sum of all odd divisors of n
257  */
258  nat_type
260 
261 
262  /** \brief
263  * Calculates the sum of all odd divisors of n by the naive method,
264  * divides the results by 2 until becomes odd,
265  * and returns it.
266  *
267  * @param n != 0
268  *
269  * @return the sum of all odd divisors of n
270  */
271  nat_type
273 
274 
275  /** \brief
276  * Iterates the sum_odd_divisors_divided_until_odd__euler() function
277  * from n until have a result lower than n.
278  *
279  * @param n > 1
280  */
281  std::pair<nat_type, unsigned int>
283 
284 
285  /** \brief
286  * Iterates the sum_odd_divisors_divided_until_odd__factorize() function
287  * from n until have a result lower than n.
288  *
289  * @param n > 1
290  */
291  std::pair<nat_type, unsigned int>
293 
294 
295  /** \brief
296  * Iterates the sum_odd_divisors_divided_until_odd__factorize() function
297  * from n until have a result lower than n.
298  * ??? with bound
299  *
300  * @param n > 1
301  */
302  std::pair<nat_type, unsigned int>
304 
305 
306  /** \brief
307  * Iterates the sum_odd_divisors_divided_until_odd__naive() function
308  * from n until have a result lower than n.
309  *
310  * @param n > 1
311  */
312  std::pair<nat_type, unsigned int>
314 
315 
316  /** \brief
317  * Calculates the sum of all odd divisors of n by the factorization method,
318  * divides the results by 2 until becomes odd,
319  * and returns it. ???
320  *
321  * @param n odd
322  *
323  * @return the sum of all odd divisors of n
324  */
325  nat_type
326  varsum_odd(nat_type n);
327 
328 
329  /** \brief
330  * Calculates the sum of all odd divisors of n by the factorization method,
331  * divides the results by 2 until becomes odd,
332  * and returns it. ???
333  *
334  * @param n odd >= potential_prime_offsets_table_modulo()
335  * @param sqrt_n ???
336  *
337  * @return the sum of all odd divisors of n
338  */
339  nat_type
340  varsum_odd_big(nat_type n, nat_type sqrt_n);
341 
342 } // namespace sigmaodd
343 
344 #endif // PROGS_SRC_COMMON_SIGMAODD_SIGMAODD_HPP_
unsigned long nat_type
Type for natural number used in all code, on 64 bits.
Definition: sigmaodd.cl:22
void print_path_infos(const std::vector< nat_type > &path, bool print_bad, bool print_all, bool print_category, bool print_lower, bool print_length, bool print_path, std::ostream &out)
Send (if the below condition is true) to the stream a string representation of the path with some inf...
Definition: sigmaodd.cpp:279
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__factorize() function from n until have a result lowe...
Definition: sigmaodd.cpp:712
void print_sigmaodd__naive(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
Definition: sigmaodd.cpp:407
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize_bound(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__factorize() function from n until have a result lowe...
Definition: sigmaodd.cpp:731
nat_type sum_odd_divisors_divided_until_odd__factorize(nat_type n, bool skip_primes_table)
Calculates the sum of all odd divisors of n by the factorization method, divides the results by 2 unt...
Definition: sigmaodd.cpp:476
void print_sigmaodd__factorize_bound(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
Definition: sigmaodd.cpp:382
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__euler(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__euler() function from n until have a result lower th...
Definition: sigmaodd.cpp:693
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
Definition: divisors.cpp:22
void print_square(nat_type first, nat_type last, bool print_path)
Definition: sigmaodd.cpp:432
nat_type varsum_odd(nat_type n)
Calculates the sum of all odd divisors of n by the factorization method, divides the results by 2 unt...
Definition: sigmaodd.cpp:769
void check_varsigma_odd(nat_type first_n, nat_type last_n)
Iterate from first to last (included) and for each odd n such that is_little_mersenne_prime_unitary_d...
Definition: sigmaodd.cpp:164
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__naive(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__naive() function from n until have a result lower th...
Definition: sigmaodd.cpp:750
nat_type sum_odd_divisors_divided_until_odd__naive(nat_type n)
Calculates the sum of all odd divisors of n by the naive method, divides the results by 2 until becom...
Definition: sigmaodd.cpp:685
void print_long(nat_type first, nat_type last, bool print_path)
Iterate from first to last (included) and for each odd n not square such that is_little_mersenne_prim...
Definition: sigmaodd.cpp:213
void print_sigmaodd__factorize(nat_type first, nat_type last, bool print_only_longer, bool print_path)
Iterate from first to last (included) and print result of the sum_odd_divisors_divided_until_odd_iter...
Definition: sigmaodd.cpp:357
nat_type sum_odd_divisors_divided_until_odd__factorize_bound(nat_type n, nat_type start_n)
Calculates the sum of all odd divisors of n by the factorization method, divides the results by 2 unt...
Definition: sigmaodd.cpp:565
void print_path(const std::vector< nat_type > &path, std::ostream &out)
Send to the stream a string representation of the path. All numbers are separated by the correspondin...
Definition: sigmaodd.cpp:251
nat_type varsum_odd_big(nat_type n, nat_type sqrt_n)
Calculates the sum of all odd divisors of n by the factorization method, divides the results by 2 unt...
Definition: sigmaodd.cpp:801
Functions in link with divisor notion: sum of divisors, factorization, GCD, coprime, ...
nat_type sum_odd_divisors_divided_until_odd__euler(nat_type n)
Calculates the sum of all odd divisors of n by the Euler formula method, divides the results by 2 unt...
Definition: sigmaodd.cpp:468
std::string path_to_string(const std::vector< nat_type > &path)
Definition: sigmaodd.cpp:193