modular-arithmetic

Check-in [8bb517f3c0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ported the egg to CHICKEN 5
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | chicken-5
Files: files | file ages | folders
SHA3-256: 8bb517f3c0f67eb6402040bb5bc9ef898740d8cab02ab063727aa36f10db52ec
User & Date: murphy 2018-08-18 16:26:17
Context
2018-08-18
16:30
Added release information file check-in: b47b80eccd user: murphy tags: chicken-5
16:26
Ported the egg to CHICKEN 5 check-in: 8bb517f3c0 user: murphy tags: chicken-5
15:58
imported v1.0.2 Leaf check-in: 0850058f44 user: murphy tags: trunk, v1.0.2
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Name change from modular-arithmetic.meta to modular-arithmetic.egg.

1
2
3
4
5
6
7
8
9







((egg "modular-arithmetic.egg")
 (files "modular-arithmetic.setup" "modular-arithmetic.meta" "modular-arithmetic.release-info" "modular-arithmetic.scm" "tests/run.scm")
 (needs numbers matchable)
 (test-depends test)
 (category math)
 (synopsis "Modular Arithmetic on Finite Fields")
 (author "Thomas Chust")
 (doc-from-wiki)
 (license "BSD"))







<
<
<
<
|


<
|
>
>
>
>
>
>
>




1
2
3

4
5
6
7
8
9
10
11




((category math)
 (synopsis "Modular Arithmetic on Finite Fields")
 (author "Thomas Chust")

 (license "BSD")
 (version "1.0.3")
 (dependencies srfi-1 matchable)
 (test-dependencies test)
 (components
   (extension modular-arithmetic)))

;; vim: set ai et ts=8 sts=2 sw=2 ft=scheme: ;;

Changes to modular-arithmetic.scm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

23
24
25


26
27
28
29
30
31
32
33
..
94
95
96
97
98
99
100


(require-library
 srfi-1
 numbers matchable)

(module modular-arithmetic
  (xgcd mod+ mod- mod* mod/ modexpt with-modulus)
  (import
   (except scheme
	   + - * / = > < >= <=
	   number->string string->number
	   exp log sin cos tan asin acos atan expt sqrt
	   quotient modulo remainder numerator denominator
	   abs max min gcd lcm
	   positive? negative? odd? even? zero? exact? inexact?
	   floor ceiling truncate round
	   inexact->exact exact->inexact
	   number? complex? real? rational? integer?
	   real-part imag-part magnitude)
   (except chicken
	   add1 sub1 signum
	   bitwise-and bitwise-ior bitwise-xor bitwise-not
	   arithmetic-shift)

   srfi-1
   numbers)
  (import-for-syntax


   scheme chicken matchable)

;; Extended GCD
(define (xgcd a b)
  (let-values ([(q m) (quotient&modulo a b)])
    (if (zero? m)
	(values 0 1)
	(let-values ([(x y) (xgcd b m)])
................................................................................
			[sub1 (lambda (n) (- n 1))]
			[* (,(rename 'mod*) ,~modulus)]
			[/ (,(rename 'mod/) ,~modulus)]
			[expt (,(rename 'modexpt) ,~modulus)])
               ,@body)))]))))

)


<
<
<
<



|
<
<
<
<
<
<
<
<
<
<
|
<
<
<
>
|
<

>
>
|







 







>
>




1
2
3
4










5



6
7

8
9
10
11
12
13
14
15
16
17
18
..
79
80
81
82
83
84
85
86
87




(module modular-arithmetic
  (xgcd mod+ mod- mod* mod/ modexpt with-modulus)
  (import
    scheme










    (chicken base)



    (chicken bitwise)
    srfi-1)

  (import-for-syntax
    scheme
    (chicken base)
    matchable)

;; Extended GCD
(define (xgcd a b)
  (let-values ([(q m) (quotient&modulo a b)])
    (if (zero? m)
	(values 0 1)
	(let-values ([(x y) (xgcd b m)])
................................................................................
			[sub1 (lambda (n) (- n 1))]
			[* (,(rename 'mod*) ,~modulus)]
			[/ (,(rename 'mod/) ,~modulus)]
			[expt (,(rename 'modexpt) ,~modulus)])
               ,@body)))]))))

)

;; vim: set ai et ts=8 sts=2 sw=2 ft=scheme: ;;

Deleted modular-arithmetic.setup.

1
2
3
4
5
6
7
8
9
(compile -s -O2 -d1 "modular-arithmetic.scm" -j modular-arithmetic)
(compile -c -O2 -d1 "modular-arithmetic.scm" -j modular-arithmetic -unit modular-arithmetic)
(compile -s -O2 -d0 "modular-arithmetic.import.scm")

(install-extension
 'modular-arithmetic
 '("modular-arithmetic.so" "modular-arithmetic.o" "modular-arithmetic.import.so")
 '((version 1.0.2)
   (static "modular-arithmetic.o")))
<
<
<
<
<
<
<
<
<


















Changes to tests/run.scm.

1
2
3
4
5
6
7
8
9
(require-extension
 test modular-arithmetic)

(test-group "Modular Arithmetic"

  (test "Extended GCD"
    '(3 -2)
    (receive (xgcd 15 21)))

|
|







1
2
3
4
5
6
7
8
9
(import
  modular-arithmetic test)

(test-group "Modular Arithmetic"

  (test "Extended GCD"
    '(3 -2)
    (receive (xgcd 15 21)))