Documentation ¶
Index ¶
- Constants
- func AddInt16(a int16, b int16) (int16, bool)
- func AddInt32(a int32, b int32) (int32, bool)
- func AddInt64(a int64, b int64) (int64, bool)
- func AddInt8(a int8, b int8) (int8, bool)
- func AddModInt64(a int64, b int64, m int64) int64
- func AddUint16(a uint16, b uint16) (uint16, bool)
- func AddUint32(a uint32, b uint32) (uint32, bool)
- func AddUint64(a uint64, b uint64) (uint64, bool)
- func AddUint8(a uint8, b uint8) (uint8, bool)
- func DivModInt64(a int64, b int64) (int64, int64)
- func DotProductInt16(S1 []int16, S2 []int16, x *big.Int) (int16, bool, *big.Int)
- func DotProductInt32(S1 []int32, S2 []int32, x *big.Int) (int32, bool, *big.Int)
- func DotProductInt64(S1 []int64, S2 []int64, x *big.Int) (int64, bool, *big.Int)
- func DotProductInt64ModInt64(S1 []int64, S2 []int64, m int64) int64
- func ExpModInt64(a int64, k int64, m int64) int64
- func MulModInt64(a int64, z int64, m int64) int64
- func MulModInt64Trial(a int64, b int64, m int64) int64
- func MulThenAddModInt64(a int64, b int64, c int64, m int64) int64
- func MultiplyInt16(a int16, b int16) (int16, bool)
- func MultiplyInt32(a int32, b int32) (int32, bool)
- func MultiplyInt64(a int64, b int64) (int64, bool)
- func MultiplyInt8(a int8, b int8) (int8, bool)
- func MultiplyUint16(a uint16, b uint16) (uint16, bool)
- func MultiplyUint32(a uint32, b uint32) (uint32, bool)
- func MultiplyUint64(a uint64, b uint64) (uint64, bool)
- func MultiplyUint8(a uint8, b uint8) (uint8, bool)
- func PowerInt64(a int64, b int64) (int64, bool)
- func ProductInt64ModInt64(S []int64, m int64) int64
- func QuotientAndRemainderInt64(a int64, b int64) (q int64, r int64)
- func SubtractInt16(a int16, b int16) (int16, bool)
- func SubtractInt32(a int32, b int32) (int32, bool)
- func SubtractInt64(a int64, b int64) (int64, bool)
- func SubtractInt8(a int8, b int8) (int8, bool)
- func SubtractUint16(a uint16, b uint16) (uint16, bool)
- func SubtractUint32(a uint32, b uint32) (uint32, bool)
- func SubtractUint64(a uint64, b uint64) (uint64, bool)
- func SubtractUint8(a uint8, b uint8) (uint8, bool)
- func SumInt64ModInt64(S []int64, m int64) int64
- func XGCDOfPairInt64(a int64, b int64) (int64, int64, int64)
Constants ¶
const MaxInt = int64(int(^uint(0) >> 1))
MaxInt defines the maximum size of an int.
const MaxUint = uint64(^uint(0))
MaxUint defines the maximum size of a uint.
const MinInt = -MaxInt - 1
MinInt defines the minimum size of an int.
Variables ¶
This section is empty.
Functions ¶
func AddInt16 ¶
AddInt16 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddInt32 ¶
AddInt32 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddInt64 ¶
AddInt64 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddInt8 ¶
AddInt8 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddModInt64 ¶
AddModInt64 returns a+b modulo m. The modulus m is required to be positive; this will panic otherwise.
func AddUint16 ¶
AddUint16 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddUint32 ¶
AddUint32 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddUint64 ¶
AddUint64 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func AddUint8 ¶
AddUint8 calculates a+b with accumulation at the maximum and minimum values for their type. That is, it returns a+b,true if the sum lies with the range for the type, and max/min of range,false otherwise.
func DivModInt64 ¶
DivModInt64 returns q, r where a = q b+r and 0 <= r < b. We require that b is positive, and panic if this is not the case
func DotProductInt16 ¶
DotProductInt16 attempts to return the dot-product of the slices S1 and S2. That is, it returns S1[0] * S2[0] + ... + S1[k] * S2[k], where k+1 is the minimum of len(S1) and len(S2). The dot-product of two empty slices is 0. If the dot-product fits in an int16, then this will be returned followed by true, nil. If the dot-product does not fit in an int16, then the min/max will be returned followed by false, x. The argument x is an optional *big.Int which will be set to the value of the dot-product and returned as the third return value only if the argument x is non-nil and the result does not fit in an int16.
func DotProductInt32 ¶
DotProductInt32 attempts to return the dot-product of the slices S1 and S2. That is, it returns S1[0] * S2[0] + ... + S1[k] * S2[k], where k+1 is the minimum of len(S1) and len(S2). The dot-product of two empty slices is 0. If the dot-product fits in an int32, then this will be returned followed by true, nil. If the dot-product does not fit in an int32, then the min/max will be returned followed by false, x. The argument x is an optional *big.Int which will be set to the value of the dot-product and returned as the third return value only if the argument x is non-nil and the result does not fit in an int32.
func DotProductInt64 ¶
DotProductInt64 attempts to return the dot-product of the slices S1 and S2. That is, it returns S1[0] * S2[0] + ... + S1[k] * S2[k], where k+1 is the minimum of len(S1) and len(S2). The dot-product of two empty slices is 0. If the dot-product fits in an int64, then this will be returned followed by true, nil. If the dot-product does not fit in an int64, then the min/max will be returned followed by false, x. The argument x is an optional *big.Int which will be set to the value of the dot-product and returned as the third return value only if the argument x is non-nil and the result does not fit in an int64.
func DotProductInt64ModInt64 ¶
DotProductInt64ModInt64 returns the dot-product of the slices S1 and S2, computed modulo m. That is, it returns S1[0] * S2[0] + ... + S1[n] * S2[n] mod m, where n+1 is the minimum of len(S1) and len(S2). The dot-product of two empty slices is the zero element. DotProductInt64ModInt64 will panic if m is not positive.
func ExpModInt64 ¶
ExpModInt64 returns a^k mod m. m is required to be positive; this will panic otherwise. k is required to be non-negative; this will panic otherwise. The return value is always in the range [0,m-1].
func MulModInt64 ¶
MulModInt64 returns a*z mod m. m is required to be positive; this will panic otherwise. The return value is always in the range [0,m-1].
func MulModInt64Trial ¶
MulModInt64Trial returns a*b mod m. m is required to be positive; this will panic otherwise. The return value is always in the range [0,m-1].
func MulThenAddModInt64 ¶
MulThenAddModInt64 returns a*b+c modulo m. The modulus m is required to be positive; this will panic otherwise.
func MultiplyInt16 ¶
MultiplyInt16 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyInt32 ¶
MultiplyInt32 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyInt64 ¶
MultiplyInt64 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyInt8 ¶
MultiplyInt8 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyUint16 ¶
MultiplyUint16 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyUint32 ¶
MultiplyUint32 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyUint64 ¶
MultiplyUint64 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func MultiplyUint8 ¶
MultiplyUint8 calculates a*b with accumulation at the maximum and minimum values for their type. That is, it returns a*b,true if the product lies with the range for the type, and max/min of range,false otherwise.
func PowerInt64 ¶
PowerInt64 calculates a^b. It returns a^b,true if the power could be computed, and 0,false otherwise. This will panic if the exponent b is < 0 and a is not a unit. Important: This function guarantees correctness of the result, however a return value of 0,false does NOT necessarily mean that the result doesn't fit in an int64.
func ProductInt64ModInt64 ¶
ProductInt64ModInt64 returns the product of S computed modulo m. The product of the empty slice is 1.
func QuotientAndRemainderInt64 ¶
QuotientAndRemainderInt64 returns the quotient q and remainder r such that a = q b+r, where 0 <= r < b if b > 0, and b < r <= 0 if b < 0. This will panic if b is zero.
func SubtractInt16 ¶
SubtractInt16 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractInt32 ¶
SubtractInt32 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractInt64 ¶
SubtractInt64 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractInt8 ¶
SubtractInt8 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractUint16 ¶
SubtractUint16 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractUint32 ¶
SubtractUint32 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractUint64 ¶
SubtractUint64 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SubtractUint8 ¶
SubtractUint8 calculates a-b with accumulation at the maximum and minimum values for their type. That is, it returns a-b,true if the difference lies with the range for the type, and max/min of range,false otherwise.
func SumInt64ModInt64 ¶
SumInt64ModInt64 returns the sum of S computed modulo m. The sum of the empty slice is zero.
func XGCDOfPairInt64 ¶
XGCDOfPairInt64 returns the greatest common divisor of a and b, along with integers u and v such that u a + v b = gcd. The gcd is always non-negative. The gcd of 0 and n is defined to be |n|, so in particular, the gcd of 0 and 0 is 0. We require that a and b are both greater than math.MinInt64 (=-2^63) as otherwise the calculation could overflow an int64; it panics in this case.
Types ¶
This section is empty.