modulepackage
0.0.0-20181122101859-297441e03548
Repository: https://github.com/cznic/mathutil.git
Documentation: pkg.go.dev
# README
This is a goinstall-able mirror of modified code already published at: http://git.nic.cz/redmine/projects/gornd/repository
Packages in this repository:
Install: $ go get github.com/cznic/mathutil Godocs: http://godoc.org/github.com/cznic/mathutil
Install: $ go get github.com/cznic/mathutil/mersenne Godocs: http://godoc.org/github.com/cznic/mathutil/mersenne
# Packages
Package mersenne collects utilities related to Mersenne numbers[1] and/or some
of their properties.
# Functions
AddUint128_64 returns the uint128 sum of uint64 a and b.
BinaryLog computes the binary logarithm of n.
BitLen returns the bit width of the non zero part of n.
BitLenByte returns the bit width of the non zero part of n.
BitLenUint returns the bit width of the non zero part of n.
BitLenUint16 returns the bit width of the non zero part of n.
BitLenUint32 returns the bit width of the non zero part of n.
BitLenUint64 returns the bit width of the non zero part of n.
BitLenUintptr returns the bit width of the non zero part of n.
Clamp returns a value restricted between lo and hi.
ClampByte returns a value restricted between lo and hi.
ClampInt16 returns a value restricted between lo and hi.
ClampInt32 returns a value restricted between lo and hi.
ClampInt64 returns a value restricted between lo and hi.
ClampInt8 returns a value restricted between lo and hi.
ClampUint16 returns a value restricted between lo and hi.
ClampUint32 returns a value restricted between lo and hi.
ClampUint64 returns a value restricted between lo and hi.
Envelope is an utility for defining simple curves using a small (usually) set of data points.
FactorInt returns prime factorization of n > 1 or nil otherwise.
GCDByte returns the greatest common divisor of a and b.
GCDUint16 returns the greatest common divisor of a and b.
GCDUint32 returns the greatest common divisor of a and b.
GCDUint64 returns the greatest common divisor of a and b.
IsPrime returns true if n is prime.
IsPrimeUint16 returns true if n is prime.
IsPrimeUint64 returns true if n is prime.
ISqrt returns floor(sqrt(n)).
Log2Byte returns log base 2 of n.
Log2Uint16 returns log base 2 of n.
Log2Uint32 returns log base 2 of n.
Log2Uint64 returns log base 2 of n.
Max returns the larger of a and b.
MaxByte returns the larger of a and b.
MaxBytePtr returns a pointer to the larger of a and b, or nil.
MaxByteVal returns the largest argument passed.
MaxInt16 returns the larger of a and b.
MaxInt16Ptr returns a pointer to the larger of a and b, or nil.
MaxInt16Val returns the largest argument passed.
MaxInt32 returns the larger of a and b.
MaxInt32Ptr returns a pointer to the larger of a and b, or nil.
MaxInt32Val returns the largest argument passed.
MaxInt64 returns the larger of a and b.
MaxInt64Ptr returns a pointer to the larger of a and b, or nil.
MaxInt64Val returns the largest argument passed.
MaxInt8 returns the larger of a and b.
MaxInt8Ptr returns a pointer to the larger of a and b, or nil.
MaxInt8Val returns the largest argument passed.
MaxPtr returns a pointer to the larger of a and b, or nil.
MaxUint16 returns the larger of a and b.
MaxUint16Ptr returns a pointer to the larger of a and b, or nil.
MaxUint16Val returns the largest argument passed.
MaxUint32 returns the larger of a and b.
MaxUint32Ptr returns a pointer to the larger of a and b, or nil.
MaxUint32Val returns the largest argument passed.
MaxUint64 returns the larger of a and b.
MaxUint64Ptr returns a pointer to the larger of a and b, or nil.
MaxUint64Val returns the largest argument passed.
MaxVal returns the largest argument passed.
Min returns the smaller of a and b.
MinByte returns the smaller of a and b.
MinBytePtr returns a pointer to the smaller of a and b, or nil.
MinByteVal returns the smallest argument passed.
MinInt16 returns the smaller of a and b.
MinInt16Ptr returns a pointer to the smaller of a and b, or nil.
MinInt16Val returns the smallest argument passed.
MinInt32 returns the smaller of a and b.
MinInt32Ptr returns a pointer to the smaller of a and b, or nil.
MinInt32Val returns the smallest argument passed.
MinInt64 returns the smaller of a and b.
MinInt64Ptr returns a pointer to the smaller of a and b, or nil.
MinInt64Val returns the smallest argument passed.
MinInt8 returns the smaller of a and b.
MinInt8Ptr returns a pointer to the smaller of a and b, or nil.
MinInt8Val returns the smallest argument passed.
MinPtr returns a pointer to the smaller of a and b, or nil.
MinUint16 returns the smaller of a and b.
MinUint16Ptr returns a pointer to the smaller of a and b, or nil.
MinUint16Val returns the smallest argument passed.
MinUint32 returns the smaller of a and b.
MinUint32Ptr returns a pointer to the smaller of a and b, or nil.
MinUint32Val returns the smallest argument passed.
MinUint64 returns the smaller of a and b.
MinUint64Ptr returns a pointer to the smaller of a and b, or nil.
MinUint64Val returns the smallest argument passed.
MinVal returns the smallest argument passed.
ModPowBigInt computes (b^e)%m.
ModPowByte computes (b^e)%m.
ModPowUint16 computes (b^e)%m.
ModPowUint32 computes (b^e)%m.
ModPowUint64 computes (b^e)%m.
MulUint128_64 returns the uint128 bit product of uint64 a and b.
NewFC32 returns a newly created FC32 adjusted for the closed interval [lo, hi] or an Error if any.
NewFCBig returns a newly created FCBig adjusted for the closed interval [lo, hi] or an Error if any.
NextPrime returns first prime > n and true if successful or an undefined value and false if there is no next prime in the uint32 limits.
NextPrimeUint16 returns first prime > n and true if successful or an undefined value and false if there is no next prime in the uint16 limits.
NextPrimeUint64 returns first prime > n and true if successful or an undefined value and false if there is no next prime in the uint64 limits.
PermutationFirst generates the first permutation of data.
PermutationNext generates the next permutation of data if possible and return true.
PopCount returns population count of n (number of bits set in n).
PopCountBigInt returns population count of |n| (number of bits set in |n|).
PopCountByte returns population count of n (number of bits set in n).
PopCountUint returns population count of n (number of bits set in n).
PopCountUint16 returns population count of n (number of bits set in n).
PopCountUint32 returns population count of n (number of bits set in n).
PopCountUint64 returns population count of n (number of bits set in n).
PopCountUintptr returns population count of n (number of bits set in n).
PowerizeBigInt returns (e, p) such that e is the smallest number for which p == b^e is greater or equal n.
PowerizeUint32BigInt returns (e, p) such that e is the smallest number for which p == b^e is greater or equal n.
PrimorialProductsUint32 returns a slice of numbers in [lo, hi] which are a product of max 'max' primorials.
ProbablyPrimeBigInt returns true if n is prime or n is a pseudoprime to base a.
ProbablyPrimeBigInt_32 returns true if n is prime or n is a pseudoprime to base a.
ProbablyPrimeUint32 returns true if n is prime or n is a pseudoprime to base a.
ProbablyPrimeUint64_32 returns true if n is prime or n is a pseudoprime to base a.
QCmpUint32 compares a/b and c/d and returns:
-1 if a/b < c/d 0 if a/b == c/d +1 if a/b > c/d
.
QScaleUint32 returns a such that a/b >= c/d.
QuadPolyDiscriminant returns the discriminant of a quadratic polynomial in one variable of the form a*x^2+b*x+c with integer coefficients a, b, c, or an error on overflow.
QuadPolyDiscriminantBig returns the discriminant of a quadratic polynomial in one variable of the form a*x^2+b*x+c with integer coefficients a, b, c.
QuadPolyFactors returns the content and the irreducible factors of the primitive part of a quadratic polynomial in one variable with integer coefficients a, b, c of the form a*x^2+b*x+c in integers, or an error on overflow.
QuadPolyFactorsBig returns the content and the irreducible factors of the primitive part of a quadratic polynomial in one variable with integer coefficients a, b, c of the form a*x^2+b*x+c in integers.
SqrtBig returns floor(sqrt(n)).
SqrtUint64 returns floor(sqrt(n)).
ToBase produces n in base b.
UClamp returns a value restricted between lo and hi.
UintptrBits returns the bit width of an uintptr at the executing machine.
UMax returns the larger of a and b.
UMaxPtr returns a pointer to the larger of a and b, or nil.
UMaxVal returns the largest argument passed.
UMin returns the smaller of a and b.
UMinPtr returns a pointer to the smaller of a and b, or nil.
UMinVal returns the smallest argument passed.
# Constants
Architecture and/or implementation specific integer limits and bit widths.
As named.
Architecture and/or implementation specific integer limits and bit widths.
Architecture and/or implementation specific integer limits and bit widths.
Architecture and/or implementation specific integer limits and bit widths.
Smooth for all derivations.
Architecture and/or implementation specific integer limits and bit widths.
# Structs
FactorTerm is one term of an integer factorization.
FC32 is a full cycle PRNG covering the 32 bit signed integer range.
FCBig is a full cycle PRNG covering ranges outside of the int32 limits.
Int128 is an 128 bit integer.
PolyFactor describes an irreducible factor of a polynomial in one variable with integer coefficients P, Q of the form P*x+Q.
PolyFactorBig describes an irreducible factor of a polynomial in one variable with integer coefficients P, Q of the form P*x+Q.
# Type aliases
Approximation type determines approximation methods used by e.g.
FactorTerms represent a factorization of an integer.