NZMATH  1.2.0
About: NZMATH is a Python based number theory oriented calculation system.
  Fossies Dox: NZMATH-1.2.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

nzmath.arith1 Namespace Reference

Classes

class  _Issquare
 

Functions

def floorsqrt (a)
 
def floorpowerroot (n, k, return_power=False)
 
def powerDetection (n, largest_exp=False)
 
def legendre (a, m)
 
def modsqrt (n, p, e=1)
 
def expand (n, m)
 
def inverse (x, n)
 
def CRT (nlist)
 
def AGM (a, b)
 
def vp (n, p, k=0)
 
def log (n, base=2)
 
def _log10 (n)
 
def product (iterable, init=None)
 

Variables

 issquare = _Issquare()
 
int POWERS_LIST_LENGTH = 4096
 
list POWERS_OF_2 = [2**i for i in range(POWERS_LIST_LENGTH)]
 

Detailed Description

Miscellaneous arithmetic functions

Function Documentation

◆ _log10()

def nzmath.arith1._log10 (   n)
private

Definition at line 364 of file arith1.py.

Referenced by nzmath.arith1.log().

◆ AGM()

def nzmath.arith1.AGM (   a,
  b 
)
Arithmetic-Geometric Mean.

Definition at line 226 of file arith1.py.

◆ CRT()

def nzmath.arith1.CRT (   nlist)
This function is Chinese Remainder Theorem using Algorithm 2.1.7
of C.Pomerance and R.Crandall's book.

For example:
>>> CRT([(1,2),(2,3),(3,5)])
23

Definition at line 197 of file arith1.py.

References nzmath.arith1.inverse(), and nzmath.bigrange.range().

Referenced by nzmath.lattice.Lattice.isIdeal().

◆ expand()

def nzmath.arith1.expand (   n,
  m 
)
This function returns m-adic expansion of n.
n and m should satisfy 0 <= n, 2 <= m.

Definition at line 171 of file arith1.py.

◆ floorpowerroot()

def nzmath.arith1.floorpowerroot (   n,
  k,
  return_power = False 
)
Return the floor of k-th power root of the given integer n.
Use Newton method.

Definition at line 27 of file arith1.py.

References nzmath.arith1.floorsqrt(), and nzmath.arith1.log().

Referenced by nzmath.arith1.powerDetection().

◆ floorsqrt()

def nzmath.arith1.floorsqrt (   a)
Return the floor of square root of the given integer.

Definition at line 12 of file arith1.py.

References nzmath.arith1.log().

Referenced by nzmath.arith1._Issquare.__call__(), and nzmath.arith1.floorpowerroot().

◆ inverse()

◆ legendre()

def nzmath.arith1.legendre (   a,
  m 
)
This function returns the Legendre symbol (a/m).
If m is an odd composite then this is the Jacobi symbol.

Definition at line 103 of file arith1.py.

Referenced by nzmath.arith1.modsqrt().

◆ log()

def nzmath.arith1.log (   n,
  base = 2 
)
Return the integer part of logarithm of the given natural number
'n' to the 'base'.  The default value for 'base' is 2.

Definition at line 328 of file arith1.py.

References nzmath.arith1._log10().

Referenced by nzmath.arith1.floorpowerroot(), nzmath.arith1.floorsqrt(), and nzmath.arith1.powerDetection().

◆ modsqrt()

def nzmath.arith1.modsqrt (   n,
  p,
  e = 1 
)
This function returns one of the square roots of n for mod p**e.
p must be an odd prime.
e must be a positive integer.
If 1 < e then n must be relatively prime with p.

Definition at line 123 of file arith1.py.

References nzmath.arith1.inverse(), nzmath.arith1.legendre(), nzmath.bigrange.range(), and nzmath.arith1.vp().

◆ powerDetection()

def nzmath.arith1.powerDetection (   n,
  largest_exp = False 
)
param positive integer n
param boolean largest_exp
return integer x, k s.t. n == x ** k
       (2 <= k if exist else x, k == n, 1)
       if largest_exp is true then return largest k

Definition at line 81 of file arith1.py.

References nzmath.arith1.floorpowerroot(), nzmath.prime.generator_eratosthenes(), and nzmath.arith1.log().

◆ product()

def nzmath.arith1.product (   iterable,
  init = None 
)
product(iterable) is a product of all elements in iterable.  If
init is given, the multiplication starts with init instead of the
first element in iterable. If the iterable is empty, then init or
1 will be returned.

If iterable is an iterator, it will be exhausted.

Definition at line 367 of file arith1.py.

◆ vp()

def nzmath.arith1.vp (   n,
  p,
  k = 0 
)
Return p-adic valuation and indivisible part of given integer.

For example:
>>> vp(100, 2)
(2, 25)

That means, 100 is 2 times divisible by 2, and the factor 25 of
100 is indivisible by 2.

The optional argument k will be added to the valuation.

Definition at line 261 of file arith1.py.

Referenced by nzmath.arith1.modsqrt().

Variable Documentation

◆ issquare

nzmath.arith1.issquare = _Issquare()

Definition at line 320 of file arith1.py.

◆ POWERS_LIST_LENGTH

int nzmath.arith1.POWERS_LIST_LENGTH = 4096

Definition at line 325 of file arith1.py.

◆ POWERS_OF_2

list nzmath.arith1.POWERS_OF_2 = [2**i for i in range(POWERS_LIST_LENGTH)]

Definition at line 326 of file arith1.py.