This file implements functions for radix integer arithmetic
Function or value | Description |
Full Usage:
ChangeBaseOfComplementNumber x oldB newB
Parameters:
int[]
oldB : int
newB : int
Returns: BigInteger * int[]
|
Converting the base of a given B-complement number: Given the digits x of a B-complemnt number to base oldB, the function computes (dVal,y) where dVal is a BigInteger that denotes the value of the given number in decimal and y are the digits of the B-complement representation of that number to the new radix newB.
|
Full Usage:
ChangeBaseOfRadixNumber x oldB newB
Parameters:
int[]
oldB : int
newB : int
Returns: BigInteger * int[]
|
Converting the base of a given radix-B number: Given the digits x of a radix-B number to base oldB, the function computes (dVal,y) where dVal is a BigInteger that denotes the value of the radix-B number in decimal and y are the digits of that number to the new radix newB.
|
Full Usage:
ComplementNumber2Int x radixBase
Parameters:
int[]
radixBase : int
Returns: int
|
|
|
convolution of two vectors x and y (which is the result of the Fourier transform of x and y if these are doubled in size by padding zeros to the higher indices)
|
Full Usage:
DecodeRNS quiet primes rnsNums
Parameters:
bool
primes : BigInteger[]
rnsNums : BigInteger[][]
Returns: BigInteger[]
|
Decode an array of given RNS numbers rnsNums for the RNS base primes, i.e., primes are the relatively prime numbers that form the RNS base, and the function computes for every rnsNums[j] a value X[j] such that rnsNums[j][i] = X[j] mod prime[i] for all i.
|
Full Usage:
ExtEuclid a b
Parameters:
BigInteger
b : BigInteger
Returns: BigInteger * BigInteger * BigInteger
|
ExtEuclid implements the extended Euclidean algorithm (see also Lemma of Bézout): For given integers a and b, it computes numbers u,v,g such that u*a + v*b = g = gcd(a,b).
|
|
|
|
Generate the (inverse) 2^p x 2^p Fourier matrix in the ring ZF[2^{2^n}+1]. Note that w = 2^{2^{n+1-p}} is a principal (2^p)-th root of unity and that w^{-1} = 2^{2^{n+1}-2^{n+1-p}} is its multiplicative inverse (for w=2, we would use p=n+1).
|
Full Usage:
FromFloatingPoint (s, e, m) B
Parameters:
bool
e : int[]
m : int[]
B : int
Returns: float
|
Convert a given floating point representation (without hidden bits) given as triple (s,e,m) where s is the sign, e the exponent and m the mantissa (exponent and mantissa were given as radix-B numbers). The result is the corresponding floating point number.
|
Full Usage:
Int2ComplementNumber x radixBase
Parameters:
int
radixBase : int
Returns: int[]
|
|
Full Usage:
Int2RadixNumber x radixBase
Parameters:
int
radixBase : int
Returns: int[]
|
|
Full Usage:
IntDivRestore ostr doPrint B x y
Parameters:
TextWriter
doPrint : bool
B : int
x : int[]
y : int[]
Returns: int[] * int[]
|
This function implements a restoring division for B-complement numbers. In case argument doPrint is true, it will print the calculation to stream ostr, otherwise, it just returns the quotient q and remainder r as (q,r).
|
Full Usage:
IntNatAddCRA isBC B x y
Parameters:
bool
B : int
x : int[]
y : int[]
Returns: int[] * int[]
|
This function implements a carry-ripple adder that can be configured via input isBC to work with B-complement or radix-B numbers in that it applies functions alpha/beta to the most significant digits or not. It is required that the operands have the same number of digits (you may use functions ZeroEqualize and SignEqualize to achieve this). The output is a pair of B-complement or radix-B numbers (c,s) where c and s holds the carry and sum digits, respectively.
|
Full Usage:
IntNatMultCRA isBC B x y
Parameters:
bool
B : int
x : int[]
y : int[]
Returns: int[,] * int[,] * int[]
|
This function implements a multiplier array that can be configured via input isBC to work with B-complement or radix-B numbers in that may apply functions alpha/beta to the most significant digits. The output is a pair of B-complement or radix-B numbers (pp,cp,p) where pp holds the partial products, cp are the carry digits for computing rowise additions, and p is the final product, respectively.
|
Full Usage:
IntNatMultCSA isBC B x y
Parameters:
bool
B : int
x : int[]
y : int[]
Returns: int[,] * int[,] * int[] * int[]
|
This function implements a multiplier array using carry-save addition that can be configured via input isBC to work with B-complement or radix-B numbers in that may apply functions alpha/beta to the most significant digits. The output is a pair of B-complement or radix-B numbers (pp,cp,cr,p) where pp holds the partial products, cp are the carry digits for computing rowise additions, cr are the carry bits for the final additiona, and p is the final product, respectively.
|
Full Usage:
IntNatSubCRA isBC B x y
Parameters:
bool
B : int
x : int[]
y : int[]
Returns: int[] * int[]
|
This function is a carry-ripple subtraction that can be configured via input isBC to work with B-complement or radix-B numbers in that it applies functions alpha/beta to the most significant digits or not. It is required that the operands have the same number of digits (you may use functions ZeroEqualize and SignEqualize to achieve this). The output is a pair of B-complement or radix-B numbers (c,s) where c and s holds the carry and sum digits, respectively.
|
|
Compute multiplicative inverse b which satisfies (a*b) mod p = 1 for a given number a and a number p such that gcd(a,p) = 1. This is done by (ExtEuclid a p) which yields numbers (x,y,g) such that a*x+p*y = gcd(a,p) = 1 holds, thus a*x mod p = 1
|
Full Usage:
NatDivRestore ostr doPrint B x y
Parameters:
TextWriter
doPrint : bool
B : int
x : int[]
y : int[]
Returns: int[] * int[]
|
This function implements a restoring division for radix-B numbers. In case argument doPrint is true, it will print the calculation to stream ostr, otherwise, it just returns the quotient q and remainder r as (q,r).
|
|
|
Full Usage:
ParseNumber s
Parameters:
string
Returns: int[] * int
|
parsing numbers: a number is expected as "<[C;F;3;2]>16" where instead semicola also comma are allowed, and in case of a base less than 35, the digits 0..9 A..Z may be directly concatenated. One may even use "<...>" and "[...]" instead of "<[...]>" for the digit list.
|
|
positive wrapped convolution of two vectors x and y (which is the result of the Fourier transform of x and y)
|
|
|
|
|
|
|
Full Usage:
RadixNumber2Int x radixBase
Parameters:
int[]
radixBase : int
Returns: int
|
|
|
|
|
|
|
|
|
|
Full Usage:
SignEqualize B x y
Parameters:
int
x : int[]
y : int[]
Returns: int[] * int[]
|
|
Full Usage:
SignExtend B n x
Parameters:
int
n : int
x : int[]
Returns: int[]
|
|
Full Usage:
SignReduce B x
Parameters:
int
x : int[]
Returns: int[]
|
|
|
|
Full Usage:
ToFloatingPoint noPrint isNegative x y B mDigits eDigits
Parameters:
bool
isNegative : bool
x : int[]
y : int[]
B : int
mDigits : int
eDigits : int
Returns: (string * (bool * int[] * int[]) option) list
|
Given radix-B numbers x and y, this function computes several floating point representations of number x/y where additionally the sign is determined by input isNegative. The floating point numbers will all have mDigits digits for the mantissa and eDigits digits for the exponent, and both are given in base B also. The result is a list of pairs of the form (mode,f) where f is an optional triple (sign,mantissa,exponent) where mode is one of the following rounding modes:
|
Full Usage:
ZeroEqualize x y
Parameters:
int[]
y : int[]
Returns: int[] * int[]
|
|
Full Usage:
ZeroExtend n x
Parameters:
int
x : int[]
Returns: int[]
|
|
Full Usage:
ZeroReduce x
Parameters:
int[]
Returns: int[]
|
|
Full Usage:
num2Str x B
Parameters:
int[]
B : int
Returns: string
|
converting number x given to base B to a string; for bases less than 36, notation without semicola and commata is preferred for the digit list
|
Full Usage:
printAddCRA ostr printVars isBC B x y
Parameters:
TextWriter
printVars : bool
isBC : bool
B : int
x : int[]
y : int[]
|
This function prints a carry-ripple adder as a SVG graphics. Input printVars is used to control whether variables like "x[2]" are printed or whether their values are printed in the svg graphics.
|
Full Usage:
printMultCRA ostr printVars isBC B x y
Parameters:
TextWriter
printVars : bool
isBC : bool
B : int
x : int[]
y : int[]
|
This function prints a carry-ripple multiplier array as a SVG figure. Input printVars is used to control whether variables like "x[2]" are printed or whether their values are printed in the svg graphics.
|
Full Usage:
printMultCSA ostr printVars isBC B x y
Parameters:
TextWriter
printVars : bool
isBC : bool
B : int
x : int[]
y : int[]
|
This function prints a carry-save multiplier array as a SVG figure. Input printVars is used to control whether variables like "x[2]" are printed or whether their values are printed in the svg graphics.
|
Full Usage:
printSubCRA ostr printVars isBC B x y
Parameters:
TextWriter
printVars : bool
isBC : bool
B : int
x : int[]
y : int[]
|
This function prints a carry-ripple adder as a SVG figure. Input printVars is used to control whether variables like "x[2]" are printed or whether their values are printed in the svg graphics.
|