severalgos/3np1 mod problem C++
June 21, 2020
|
Typedefs | |
typedef uint64_t | value_type |
typedef value_type(* | operation_type) (value_type) |
typedef value_type(* | operation_mask_type) (value_type, value_type) |
Functions | |
value_type | C (value_type n) |
Collatz C function. More... | |
value_type | C_mask (value_type n, value_type mask) |
Return \(C(n) = \frac{n}{2}\) if n even, \(C(n) = (3n + 1) \& mask\) if n odd. More... | |
value_type | m2 (value_type n) |
\(m_2\) function. More... | |
value_type | F (value_type n) |
F odd function. More... | |
value_type | F_mask (value_type n, value_type mask) |
Return \(F(0) = 0\) \(F(n) = \frac{n}{2^k}\) if n even \(F(n) = \frac{(3n + 1) \& mask}{2^k}\) if n odd which k as large as possible = \(m_2(...)\). More... | |
std::set< value_type > | search_mask_exceptions (value_type mask) |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo (mask + 1). More... | |
std::set< value_type > | search_mask_exceptions_32 () |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\). More... | |
std::set< value_type > | search_mask_exceptions_64 () |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\). More... | |
std::vector< value_type > | start_path_mask (value_type n, operation_mask_type operation_mask, value_type mask) |
Given operation, return the start of path from n to the first value < n or to the first repeated value. More... | |
value_type | T (value_type n) |
Terras T function. More... | |
value_type | T_mask (value_type n, value_type mask) |
Return \(T(n) = \frac{n}{2}\) if n even \(T(n) = \frac{(3n + 1) \& mask}{2}\) if n odd. More... | |
typedef value_type(* lib_3np1_mod::operation_mask_type) (value_type, value_type) |
Definition at line 60 of file lib_3np1_mod.hpp.
typedef value_type(* lib_3np1_mod::operation_type) (value_type) |
Definition at line 58 of file lib_3np1_mod.hpp.
typedef uint64_t lib_3np1_mod::value_type |
Definition at line 56 of file lib_3np1_mod.hpp.
|
inline |
Collatz C function.
\(C(n) = \frac{n}{2}\) if n even
\(C(n) = 3n + 1\) if n odd
n | <= (numeric_limits<value_type>::max() - 1)/3 |
Definition at line 24 of file lib_3np1_mod__inline.hpp.
|
inline |
Return \(C(n) = \frac{n}{2}\) if n even,
\(C(n) = (3n + 1) \& mask\) if n odd.
n | <= mask |
mask |
Definition at line 35 of file lib_3np1_mod__inline.hpp.
|
inline |
F odd function.
\(F(0) = 0\)
\(F(n) = \frac{n}{2^k}\) if n even
\(F(n) = \frac{3n + 1}{2^k}\) if n odd
which k as large as possible = \(m_2(...)\).
n | <= (numeric_limits<value_type>::max() - 1)/3 |
Definition at line 46 of file lib_3np1_mod__inline.hpp.
|
inline |
Return
\(F(0) = 0\)
\(F(n) = \frac{n}{2^k}\) if n even
\(F(n) = \frac{(3n + 1) \& mask}{2^k}\) if n odd
which k as large as possible = \(m_2(...)\).
n | <= mask |
mask |
Definition at line 61 of file lib_3np1_mod__inline.hpp.
|
inline |
\(m_2\) function.
Exponent of highest power of 2 dividing n = number of beginning 0 bits of n = 2-adic valuation of n.
n | != 0 |
Definition at line 76 of file lib_3np1_mod__inline.hpp.
std::set< value_type > lib_3np1_mod::search_mask_exceptions | ( | value_type | mask | ) |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo (mask + 1).
mask |
Definition at line 24 of file lib_3np1_mod.cpp.
std::set< value_type > lib_3np1_mod::search_mask_exceptions_32 | ( | ) |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\).
Definition at line 96 of file lib_3np1_mod.cpp.
std::set< value_type > lib_3np1_mod::search_mask_exceptions_64 | ( | ) |
Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\).
Definition at line 158 of file lib_3np1_mod.cpp.
std::vector< value_type > lib_3np1_mod::start_path_mask | ( | value_type | n, |
operation_mask_type | operation_mask, | ||
value_type | mask | ||
) |
Given operation, return the start of path from n to the first value < n or to the first repeated value.
n | <= mask |
operation_mask | must be C_mask, F_mask or T_mask |
mask |
Definition at line 220 of file lib_3np1_mod.cpp.
|
inline |
Terras T function.
\(T(n) = \frac{n}{2}\) if n even
\(T(n) = \frac{3n + 1}{2}\) if n odd
n | <= (numeric_limits<value_type>::max() - 1)/3 |
Definition at line 87 of file lib_3np1_mod__inline.hpp.
|
inline |
Return
\(T(n) = \frac{n}{2}\) if n even
\(T(n) = \frac{(3n + 1) \& mask}{2}\) if n odd.
n | <= mask |
mask |
Definition at line 98 of file lib_3np1_mod__inline.hpp.