aboutsummaryrefslogtreecommitdiff
path: root/core/math/big/example.odin
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-03 14:48:16 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-03 14:50:26 +0200
commit70e12f7a1c58adb01875cd972731acebefbdb918 (patch)
treeb2f0653dfc3cea3e2d3e8d3c71b6174df6a2dcf7 /core/math/big/example.odin
parent11ae87cc2fec12d5bda0052ecc29d91d60b68a22 (diff)
big: Fix internal_int_mod for inputs with opposite signs.
This threw off Frobenius-Underwood.
Diffstat (limited to 'core/math/big/example.odin')
-rw-r--r--core/math/big/example.odin14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/math/big/example.odin b/core/math/big/example.odin
index fb1e51053..9c5fd6bc7 100644
--- a/core/math/big/example.odin
+++ b/core/math/big/example.odin
@@ -84,16 +84,20 @@ print :: proc(name: string, a: ^Int, base := i8(10), print_name := true, newline
}
}
-printf :: fmt.printf;
+//printf :: fmt.printf;
demo :: proc() {
a, b, c, d, e, f, res := &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{};
defer destroy(a, b, c, d, e, f, res);
- err: Error;
+ err: Error;
+ frob: bool;
prime: bool;
- set(a, "3317044064679887385961981"); // Composite: 1287836182261 × 2575672364521
+ // USE_MILLER_RABIN_ONLY = true;
+
+ // set(a, "3317044064679887385961979"); // Composite: 17 × 1709 × 1366183751 × 83570142193
+ set(a, "359334085968622831041960188598043661065388726959079837"); // 6th Bell prime
trials := number_of_rabin_miller_trials(internal_count_bits(a));
{
SCOPED_TIMING(.is_prime);
@@ -101,7 +105,9 @@ demo :: proc() {
}
print("Candidate prime: ", a);
fmt.printf("%v Miller-Rabin trials needed.\n", trials);
- fmt.printf("Is prime: %v, Error: %v\n", prime, err);
+
+ frob, err = internal_int_prime_frobenius_underwood(a);
+ fmt.printf("Frobenius-Underwood: %v, Prime: %v, Error: %v\n", frob, prime, err);
}
main :: proc() {