Beispiel #1
0
func BenchmarkJacobiSymbolStandard(b *testing.B) {
	benchmarkOdd, _ := new(big.Int).SetString("3ba9a88eb20cfdfe4a380607f5025cdcd0f0bbb73b6f8d45bb0d7bdcd7d485b513d4f8c3d0d572f47ea6f32b4d19978c1a578f919c126e997548b8d0acc64284287a3a321e292e1be9614bf21254011a25df84b77b7411d41e65fd50298fc4660651580b5bd3f38377e2a6260021694cb4096873762f45ba41562ed1cddaca69", 16)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		big.Jacobi(benchmarkPrime, benchmarkOdd)
	}
}
Beispiel #2
0
// Jacobi returns the Jacobi symbol (x/y), either +1, -1, or 0.
// Both x and y arguments must be integers (i.e., scale <= zero).
// The y argument must be an odd integer.
func Jacobi(x, y *Decimal) int {
	if x.scale > 0 || y.scale > 0 {
		panic("decimal: invalid arguments to decimal.Jacobi: Jacobi requires integer values")
	}
	if x.compact != overflown {
		if y.compact != overflown {
			return jacobiCompact(x, y)
		}
		return jacobiHalf(x, y)
	}
	if y.compact != overflown {
		return jacobiHalf(y, x)
	}
	return big.Jacobi(&x.mantissa, &y.mantissa)
}
Beispiel #3
0
func jacobiHalf(comp, nc *Decimal) int {
	return big.Jacobi(big.NewInt(comp.compact), &nc.mantissa)
}