severalgos/3np1 mod problem C++  June 21, 2020
Typedefs | Functions
lib_3np1_mod Namespace Reference

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_typesearch_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_typesearch_mask_exceptions_32 ()
 Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\). More...
 
std::set< value_typesearch_mask_exceptions_64 ()
 Calculate and return all null and odd exceptions for the 3n + 1 problem with modulo \(2^32\). More...
 
std::vector< value_typestart_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 Documentation

◆ operation_mask_type

typedef value_type(* lib_3np1_mod::operation_mask_type) (value_type, value_type)

Definition at line 60 of file lib_3np1_mod.hpp.

◆ operation_type

typedef value_type(* lib_3np1_mod::operation_type) (value_type)

Definition at line 58 of file lib_3np1_mod.hpp.

◆ value_type

typedef uint64_t lib_3np1_mod::value_type

Definition at line 56 of file lib_3np1_mod.hpp.

Function Documentation

◆ C()

value_type lib_3np1_mod::C ( value_type  n)
inline

Collatz C function.

\(C(n) = \frac{n}{2}\) if n even
\(C(n) = 3n + 1\) if n odd

http://oeis.org/A006370

Parameters
n<= (numeric_limits<value_type>::max() - 1)/3

Definition at line 24 of file lib_3np1_mod__inline.hpp.

◆ C_mask()

value_type lib_3np1_mod::C_mask ( value_type  n,
value_type  mask 
)
inline

Return \(C(n) = \frac{n}{2}\) if n even,
\(C(n) = (3n + 1) \& mask\) if n odd.

Parameters
n<= mask
mask

Definition at line 35 of file lib_3np1_mod__inline.hpp.

◆ F()

value_type lib_3np1_mod::F ( value_type  n)
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(...)\).

http://oeis.org/A139391

Parameters
n<= (numeric_limits<value_type>::max() - 1)/3

Definition at line 46 of file lib_3np1_mod__inline.hpp.

◆ F_mask()

value_type lib_3np1_mod::F_mask ( value_type  n,
value_type  mask 
)
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(...)\).

Parameters
n<= mask
mask

Definition at line 61 of file lib_3np1_mod__inline.hpp.

◆ m2()

value_type lib_3np1_mod::m2 ( value_type  n)
inline

\(m_2\) function.

Exponent of highest power of 2 dividing n = number of beginning 0 bits of n = 2-adic valuation of n.

http://oeis.org/A007814

Parameters
n!= 0

Definition at line 76 of file lib_3np1_mod__inline.hpp.

◆ search_mask_exceptions()

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).

Parameters
mask

Definition at line 24 of file lib_3np1_mod.cpp.

◆ search_mask_exceptions_32()

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.

◆ search_mask_exceptions_64()

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.

◆ start_path_mask()

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.

Parameters
n<= mask
operation_maskmust be C_mask, F_mask or T_mask
mask

Definition at line 220 of file lib_3np1_mod.cpp.

◆ T()

value_type lib_3np1_mod::T ( value_type  n)
inline

Terras T function.

\(T(n) = \frac{n}{2}\) if n even
\(T(n) = \frac{3n + 1}{2}\) if n odd

http://oeis.org/A014682

Parameters
n<= (numeric_limits<value_type>::max() - 1)/3

Definition at line 87 of file lib_3np1_mod__inline.hpp.

◆ T_mask()

value_type lib_3np1_mod::T_mask ( value_type  n,
value_type  mask 
)
inline

Return
\(T(n) = \frac{n}{2}\) if n even
\(T(n) = \frac{(3n + 1) \& mask}{2}\) if n odd.

Parameters
n<= mask
mask

Definition at line 98 of file lib_3np1_mod__inline.hpp.