Changeset 1230
- Timestamp:
- 2015-06-11T14:22:24-07:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/f4grobner/utils.lisp
r1229 r1230 22 22 (defpackage "UTILS" 23 23 (:use :cl) 24 (:export "MAKELIST-1" "MAKELIST" "SUMMATION" ))24 (:export "MAKELIST-1" "MAKELIST" "SUMMATION" "INNER-PRODUCT")) 25 25 26 26 (in-package :utils) … … 64 64 (declare (fixnum ,var)))))) 65 65 66 (defmacro summation (expr (var lo hi &optional (step 1)) &optional (add ition '+) (initval 0))66 (defmacro summation (expr (var lo hi &optional (step 1)) &optional (add '+) (init-val 0)) 67 67 (let ((r (gensym))) 68 `(do ((,r ,init val)68 `(do ((,r ,init-val) 69 69 (,var ,lo (+ ,var ,step))) 70 70 ((> ,var ,hi) ,r) 71 (setf ,r (,addition ,r ,expr))))) 71 (setf ,r (,add ,r ,expr))))) 72 73 (defmacro inner-product (x y &optional (add '+) (mult '*)) 74 (let ((i (gensym))) 75 `(summation (,mult (elt ,x ,i) (elt ,y ,i)) (,i 0 (1- (length ,x)))))) 72 76 73 77
Note:
See TracChangeset
for help on using the changeset viewer.