- Timestamp:
- 2015-06-17T19:58:44-07:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/ring.lisp
r2097 r2098 49 49 (in-package :ring) 50 50 51 #| 52 53 (defstruct (ring) 54 "Defines a RING structure, whose fields 55 are common ring operations necessary to implement 56 Groebner bases." 57 (parse #'identity :type function) 58 (unit #'identity :type function) 59 (zerop #'identity :type function) 60 (add #'identity :type function) 61 (sub #'identity :type function) 62 (uminus #'identity :type function) 63 (mul #'identity :type function) 64 (div #'identity :type function) 65 (lcm #'identity :type function) 66 (ezgcd #'identity :type function) 67 (gcd #'identity :type function)) 68 69 (defparameter +ring-of-integers+ 70 (make-ring 71 :parse #'identity 72 :unit #'(lambda () 1) 73 :zerop #'zerop 74 :add #'+ 75 :sub #'- 76 :uminus #'- 77 :mul #'* 78 :div #'/ 79 :lcm #'lcm 80 :ezgcd #'(lambda (x y &aux (c (gcd x y))) (values c (/ x c) (/ y c))) 81 :gcd #'gcd 82 ) 83 "The ring of integers.") 84 |# 85 86 (defgeneric ring-parse (object) 51 (defgeneric parse (object) 87 52 (:method ((object t)) object)) 88 53 89 (defgeneric ring-unit-for (object)54 (defgeneric unit-for (object) 90 55 (:method ((self number)) 1)) 91 56 92 (defgeneric ring-zerop (object)57 (defgeneric zerop (object) 93 58 (:method ((self number)) (zerop self))) 94 59 95 (defgeneric ring-add (x y)60 (defgeneric add (x y) 96 61 (:method ((x number) (y number)) (+ x y))) 97 62 98 (defgeneric ring-mul (x y)63 (defgeneric mul (x y) 99 64 (:method ((x number) (y number)) (* x y))) 100 65 101 (defgeneric ring-tensor-mul (x y))66 (defgeneric tensor-mul (x y)) 102 67 103 (defgeneric ring-div (x y)68 (defgeneric div (x y) 104 69 (:method ((x number) (y number)) (/ x y))) 105 70 106 (defgeneric ring-lcm (x y)71 (defgeneric lcm (x y) 107 72 (:method ((x integer) (y integer)) (lcm x y))) 108 73 109 (defgeneric ring-ezgcd (x y)74 (defgeneric ezgcd (x y) 110 75 (:method ((x integer) (y integer) 111 76 &aux (c (gcd x y))) 112 77 (values c (/ x c) (/ y c)))) 113 78 114 (defgeneric ring-gcd (x y)79 (defgeneric gcd (x y) 115 80 (:method ((x integer) (y integer)) 116 81 (gcd x y)))
Note:
See TracChangeset
for help on using the changeset viewer.