diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-19 11:40:32 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-19 11:40:32 +0100 |
| commit | 82a74ebfa988ed1e5236db2db3bba85143bd27a2 (patch) | |
| tree | 8c2b2da83f798f76f46f2e9b842ddb286cb3178e | |
| parent | 35026000bb66a2ab5ddc46c730618ce67f100e70 (diff) | |
| parent | 55cf3d26bf042a203feab137f9ac938b0aadc986 (diff) | |
Merge branch 'master' of https://github.com/odin-lang/Odin
| -rw-r--r-- | core/math/big/build.bat | 4 | ||||
| -rw-r--r-- | core/math/big/common.odin | 2 | ||||
| -rw-r--r-- | core/math/big/example.odin | 2 | ||||
| -rw-r--r-- | core/math/big/helpers.odin | 2 | ||||
| -rw-r--r-- | core/math/big/internal.odin | 2 | ||||
| -rw-r--r-- | core/math/big/logical.odin | 2 | ||||
| -rw-r--r-- | core/math/big/prime.odin | 2 | ||||
| -rw-r--r-- | core/math/big/private.odin | 16 | ||||
| -rw-r--r-- | core/math/big/public.odin | 2 | ||||
| -rw-r--r-- | core/math/big/radix.odin | 2 | ||||
| -rw-r--r-- | core/math/big/test.odin | 2 | ||||
| -rw-r--r-- | core/math/big/test.py | 53 | ||||
| -rw-r--r-- | core/math/big/tune.odin | 2 |
13 files changed, 48 insertions, 45 deletions
diff --git a/core/math/big/build.bat b/core/math/big/build.bat index 7e2f15e1a..f66f98192 100644 --- a/core/math/big/build.bat +++ b/core/math/big/build.bat @@ -1,9 +1,9 @@ @echo off
-:odin run . -vet -o:size
+odin run . -vet -o:size
: -o:size
:odin build . -build-mode:shared -show-timings -o:minimal -no-bounds-check -define:MATH_BIG_EXE=false && python test.py -fast-tests
:odin build . -build-mode:shared -show-timings -o:size -no-bounds-check -define:MATH_BIG_EXE=false && python test.py -fast-tests
:odin build . -build-mode:shared -show-timings -o:size -define:MATH_BIG_EXE=false && python test.py -fast-tests
-odin build . -build-mode:shared -show-timings -o:speed -no-bounds-check -define:MATH_BIG_EXE=false && python test.py
+:odin build . -build-mode:shared -show-timings -o:speed -no-bounds-check -define:MATH_BIG_EXE=false && python test.py
: -fast-tests
:odin build . -build-mode:shared -show-timings -o:speed -define:MATH_BIG_EXE=false && python test.py -fast-tests
\ No newline at end of file diff --git a/core/math/big/common.odin b/core/math/big/common.odin index 57fa32c9d..ce1f7d77f 100644 --- a/core/math/big/common.odin +++ b/core/math/big/common.odin @@ -2,7 +2,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/example.odin b/core/math/big/example.odin index d36fe1477..f3e648880 100644 --- a/core/math/big/example.odin +++ b/core/math/big/example.odin @@ -3,7 +3,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. A BigInt implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/helpers.odin b/core/math/big/helpers.odin index e50579ac0..8ce1b2811 100644 --- a/core/math/big/helpers.odin +++ b/core/math/big/helpers.odin @@ -2,7 +2,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin index ac2c0d3db..256bf03d4 100644 --- a/core/math/big/internal.odin +++ b/core/math/big/internal.odin @@ -3,7 +3,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. A BigInt implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/logical.odin b/core/math/big/logical.odin index 42b262488..64f3b0898 100644 --- a/core/math/big/logical.odin +++ b/core/math/big/logical.odin @@ -2,7 +2,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/prime.odin b/core/math/big/prime.odin index b022870a6..7d33a4068 100644 --- a/core/math/big/prime.odin +++ b/core/math/big/prime.odin @@ -2,7 +2,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/private.odin b/core/math/big/private.odin index 24fb2110f..ca2d016de 100644 --- a/core/math/big/private.odin +++ b/core/math/big/private.odin @@ -2,7 +2,7 @@ package math_big /*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-2 license.
+ Made available under Odin's BSD-3 license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
@@ -1540,6 +1540,8 @@ _private_int_log :: proc(a: ^Int, base: DIGIT, allocator := context.allocator) - }
+
+
/*
hac 14.61, pp608
*/
@@ -1708,9 +1710,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc /*
2. [modified] `b` must be odd.
*/
- if internal_is_even(b) {
- return .Invalid_Argument;
- }
+ if internal_is_even(b) { return .Invalid_Argument; }
/*
Init all our temps.
@@ -1730,9 +1730,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc /*
If one of `x`, `y` is zero return an error!
*/
- if internal_is_zero(x) || internal_is_zero(y) {
- return .Invalid_Argument;
- }
+ if internal_is_zero(x) || internal_is_zero(y) { return .Invalid_Argument; }
/*
3. `u` = `x`, `v` = `y`, `A` = 1, `B` = 0, `C` = 0, `D` = 1
@@ -1812,9 +1810,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc /*
If not zero goto step 4.
*/
- if internal_is_zero(u) {
- break;
- }
+ if internal_is_zero(u) { break; }
}
/*
diff --git a/core/math/big/public.odin b/core/math/big/public.odin index 7804978a5..218e567cf 100644 --- a/core/math/big/public.odin +++ b/core/math/big/public.odin @@ -2,7 +2,7 @@ package math_big /*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
- Made available under Odin's BSD-2 license.
+ Made available under Odin's BSD-3 license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
diff --git a/core/math/big/radix.odin b/core/math/big/radix.odin index e7eee9513..bf1d4d5a2 100644 --- a/core/math/big/radix.odin +++ b/core/math/big/radix.odin @@ -2,7 +2,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/test.odin b/core/math/big/test.odin index a57625d79..2734894b1 100644 --- a/core/math/big/test.odin +++ b/core/math/big/test.odin @@ -3,7 +3,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. An arbitrary precision mathematics implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. diff --git a/core/math/big/test.py b/core/math/big/test.py index 4798d110f..ccda9f258 100644 --- a/core/math/big/test.py +++ b/core/math/big/test.py @@ -14,6 +14,7 @@ parser = argparse.ArgumentParser( epilog = "By default we run regression and random tests with preset parameters.",
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
)
+
#
# Normally, we report the number of passes and fails. With this option set, we exit at first fail.
#
@@ -22,10 +23,10 @@ parser.add_argument( help = "Exit when a test fails",
action = "store_true",
)
+
#
# We skip randomized tests altogether if this is set.
#
-
no_random = parser.add_mutually_exclusive_group()
no_random.add_argument(
@@ -33,13 +34,13 @@ no_random.add_argument( help = "No random tests",
action = "store_true",
)
+
#
# Normally we run a given number of cycles on each test.
# Timed tests budget 1 second per 20_000 bits instead.
#
# For timed tests we budget a second per `n` bits and iterate until we hit that time.
#
-
timed_or_fast = no_random.add_mutually_exclusive_group()
timed_or_fast.add_argument(
@@ -55,6 +56,7 @@ parser.add_argument( default = 20_000,
help = "Timed tests. Every `BITS` worth of input is given a second of running time.",
)
+
#
# For normal tests (non-timed), `-fast-tests` cuts down on the number of iterations.
#
@@ -136,7 +138,6 @@ gc.disable() #
# Set up exported procedures
#
-
try:
l = cdll.LoadLibrary(LIB_PATH)
except:
@@ -159,29 +160,28 @@ print("initialize_constants: ", initialize_constants()) error_string = load(l.test_error_string, [c_byte], c_char_p)
-add = load(l.test_add, [c_char_p, c_char_p], Res)
-sub = load(l.test_sub, [c_char_p, c_char_p], Res)
-mul = load(l.test_mul, [c_char_p, c_char_p], Res)
-sqr = load(l.test_sqr, [c_char_p ], Res)
-div = load(l.test_div, [c_char_p, c_char_p], Res)
+add = load(l.test_add, [c_char_p, c_char_p], Res)
+sub = load(l.test_sub, [c_char_p, c_char_p], Res)
+mul = load(l.test_mul, [c_char_p, c_char_p], Res)
+sqr = load(l.test_sqr, [c_char_p ], Res)
+div = load(l.test_div, [c_char_p, c_char_p], Res)
# Powers and such
-int_log = load(l.test_log, [c_char_p, c_longlong], Res)
-int_pow = load(l.test_pow, [c_char_p, c_longlong], Res)
-int_sqrt = load(l.test_sqrt, [c_char_p ], Res)
-int_root_n = load(l.test_root_n, [c_char_p, c_longlong], Res)
+int_log = load(l.test_log, [c_char_p, c_longlong], Res)
+int_pow = load(l.test_pow, [c_char_p, c_longlong], Res)
+int_sqrt = load(l.test_sqrt, [c_char_p ], Res)
+int_root_n = load(l.test_root_n, [c_char_p, c_longlong], Res)
# Logical operations
-
-int_shl_digit = load(l.test_shl_digit, [c_char_p, c_longlong], Res)
-int_shr_digit = load(l.test_shr_digit, [c_char_p, c_longlong], Res)
-int_shl = load(l.test_shl, [c_char_p, c_longlong], Res)
-int_shr = load(l.test_shr, [c_char_p, c_longlong], Res)
+int_shl_digit = load(l.test_shl_digit, [c_char_p, c_longlong], Res)
+int_shr_digit = load(l.test_shr_digit, [c_char_p, c_longlong], Res)
+int_shl = load(l.test_shl, [c_char_p, c_longlong], Res)
+int_shr = load(l.test_shr, [c_char_p, c_longlong], Res)
int_shr_signed = load(l.test_shr_signed, [c_char_p, c_longlong], Res)
-int_factorial = load(l.test_factorial, [c_uint64], Res)
-int_gcd = load(l.test_gcd, [c_char_p, c_char_p], Res)
-int_lcm = load(l.test_lcm, [c_char_p, c_char_p], Res)
+int_factorial = load(l.test_factorial, [c_uint64], Res)
+int_gcd = load(l.test_gcd, [c_char_p, c_char_p], Res)
+int_lcm = load(l.test_lcm, [c_char_p, c_char_p], Res)
def test(test_name: "", res: Res, param=[], expected_error = Error.Okay, expected_result = "", radix=16):
passed = True
@@ -561,6 +561,13 @@ if __name__ == '__main__': print("\n---- math/big tests ----")
print()
+ max_name = 0
+ for test_proc in TESTS:
+ max_name = max(max_name, len(test_proc.__name__))
+
+ fmt_string = "{name:>{max_name}}: {count_pass:7,} passes and {count_fail:7,} failures in {timing:9.3f} ms."
+ fmt_string = fmt_string.replace("{max_name}", str(max_name))
+
for test_proc in TESTS:
count_pass = 0
count_fail = 0
@@ -583,7 +590,7 @@ if __name__ == '__main__': count_fail += 1
total_failures += 1
- print("{name}: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
+ print(fmt_string.format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
for BITS, ITERATIONS in BITS_AND_ITERATIONS:
print()
@@ -665,12 +672,12 @@ if __name__ == '__main__': else:
count_fail += 1; total_failures += 1
- print("{name}: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
+ print(fmt_string.format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
print()
print("---- THE END ----")
print()
- print("total: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(count_pass=total_passes, count_fail=total_failures, timing=TOTAL_TIME * 1_000))
+ print(fmt_string.format(name="total", count_pass=total_passes, count_fail=total_failures, timing=TOTAL_TIME * 1_000))
if total_failures:
exit(1)
\ No newline at end of file diff --git a/core/math/big/tune.odin b/core/math/big/tune.odin index 14e10e483..700a5e74a 100644 --- a/core/math/big/tune.odin +++ b/core/math/big/tune.odin @@ -3,7 +3,7 @@ package math_big /* Copyright 2021 Jeroen van Rijn <nom@duclavier.com>. - Made available under Odin's BSD-2 license. + Made available under Odin's BSD-3 license. A BigInt implementation in Odin. For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3. |