Commit 5fabe0c0 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Relocation generic math functions and methods

The definition of generic math functions (addition, multiplication,
etc.) has been moved from grid/generic.lisp to init/generic.lisp, and
so is loaded before grid is loaded, with the methods that use grid
functions moved to grid/functions.lisp.  This eliminates two warnings
that were appearing in compilation.
parent 72dbd9c1
;; Antik system definition
;; Liam Healy 2010-12-24 09:43:28EST antik.asd
;; Time-stamp: <2011-08-26 10:31:40EDT antik.asd>
;; Time-stamp: <2011-09-09 22:59:38EDT antik.asd>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -39,134 +39,134 @@
:serial t
:defsystem-depends-on (#:asdf-system-connections)
:depends-on (#:iterate #:alexandria #:split-sequence #:cl-ppcre
#:cffi #:trivial-garbage
#+static-vectors static-vectors
;; temporary need fsbv until convert is split out of fsbv
#:fsbv
#:drakma)
#:cffi #:trivial-garbage
#+static-vectors static-vectors
;; temporary need fsbv until convert is split out of fsbv
#:fsbv
#:drakma)
:components
((:module init
:serial t
:components
((:file "package")
(:file "utility")
(:file "conditions")
(:file "object")
(:file "iterate")
(:file "intermediate"))) ; temporary
:serial t
:components
((:file "package")
(:file "utility")
(:file "conditions")
(:file "object")
(:file "iterate")
(:file "intermediate") ; temporary
(:file "generic")))
(:module grid
:depends-on (init)
:components
((:file "util")
(:module affi ; Affine indexing
:components
((:file "package")
(:file "utility" :depends-on ("package"))
(:file "affi" :depends-on ("utility"))
(:file "transformers" :depends-on ("affi"))))
(:file "functions" :depends-on ("util" affi))
(:file "generic" :depends-on ("functions"))
(:file "specification" :depends-on ("util" "functions" affi))
(:file "array" :depends-on ("functions" affi))
(:file "map" :depends-on (affi "functions"))
(:file "compose" :depends-on ("functions" affi))
(:file "slice" :depends-on (affi))
(:file "higher" :depends-on (affi "functions" "generic"))
(:file "copy")
(:file "iterate" :depends-on ("compose"))
(:file "mathematics" :depends-on ("map"))
(:module tests
:components
((:file "grids")))))
:depends-on (init)
:components
((:file "util")
(:module affi ; Affine indexing
:components
((:file "package")
(:file "utility" :depends-on ("package"))
(:file "affi" :depends-on ("utility"))
(:file "transformers" :depends-on ("affi"))))
(:file "functions" :depends-on ("util" affi))
(:file "specification" :depends-on ("util" "functions" affi))
(:file "array" :depends-on ("functions" affi))
(:file "map" :depends-on (affi "functions"))
(:file "compose" :depends-on ("functions" affi))
(:file "slice" :depends-on (affi))
(:file "higher" :depends-on (affi "functions"))
(:file "copy")
(:file "iterate" :depends-on ("compose"))
(:file "mathematics" :depends-on ("map"))
(:module tests
:components
((:file "grids")))))
(:module input-output
:serial t
:components
((:file "parameters")
(:file "format-output")
(:file "float")
(:file "matlab")
(:file "read") ; cl-ppcre
))
:serial t
:components
((:file "parameters")
(:file "format-output")
(:file "float")
(:file "matlab")
(:file "read") ; cl-ppcre
))
(:module foreign-array
:depends-on (grid input-output)
:components
((:file "types")
(:file "complex-types" :depends-on ("types"))
(:file "element-types" :depends-on ("types" "complex-types"))
(:file "symbol-type")
(:file "number-conversion"
:depends-on ("complex-types" "symbol-type"))
(:file "subclass" :depends-on ("element-types"))
(:file "foreign-array" :depends-on ("types" "element-types"))
(:file "vector-matrix" :depends-on ("element-types" "subclass"))
(:file "methods" :depends-on ("foreign-array" "vector-matrix"))))
:depends-on (grid input-output)
:components
((:file "types")
(:file "complex-types" :depends-on ("types"))
(:file "element-types" :depends-on ("types" "complex-types"))
(:file "symbol-type")
(:file "number-conversion"
:depends-on ("complex-types" "symbol-type"))
(:file "subclass" :depends-on ("element-types"))
(:file "foreign-array" :depends-on ("types" "element-types"))
(:file "vector-matrix" :depends-on ("element-types" "subclass"))
(:file "methods" :depends-on ("foreign-array" "vector-matrix"))))
(:module physical-quantities
:depends-on (init input-output)
:components
((:file "units")
(:file "scalar" :depends-on ("units"))
(:file "grid" :depends-on ("scalar"))
(:file "funcall")
(:file "unit-definitions" :depends-on ("units" "grid" "funcall"))
(:file "sysunit-definitions"
:depends-on ("units" "unit-definitions"))
(:file "physical-quantities" :depends-on ("units" "scalar"))
(:file "undimension" :depends-on ("physical-quantities"))
(:file "arithmetic" :depends-on ("units" "undimension"))
(:file "iso8601")
(:file "dtspec" :depends-on ("iso8601"))
(:file "time-interval"
:depends-on
("sysunit-definitions" "physical-quantities" "iso8601" "dtspec"))
(:file "angle"
:depends-on
;; Dependency to force loading of everything needed
;; to put #_1_unit into source code.
("physical-quantities" ; needs split-sequence
"arithmetic"
"undimension"
"unit-definitions"
"sysunit-definitions" "dtspec" "time-interval"))
(:file "angle-component"
:depends-on
("physical-quantities"
"undimension"
"unit-definitions"
"sysunit-definitions"))
(:file "state" :depends-on ("units"))
(:file "timepoint"
:depends-on
("unit-definitions"
"sysunit-definitions"
"physical-quantities" "arithmetic"
"dtspec" "iso8601" "time-interval"))
(:file "relative-time" :depends-on ("timepoint"))
(:file "read-time" :depends-on ("timepoint"))
(:file "formats" :depends-on ("read-time"))
(:file "convert-timescale"
;; Dependency to force loading of everything needed ;
;; to put #_1_unit into source code. ;
:depends-on
("physical-quantities" ; needs split-sequence ;
"arithmetic" "undimension" "unit-definitions"
"sysunit-definitions" "time-interval" "timepoint" "read-time"))
(:file "dtmath"
:depends-on ("dtspec" "read-time" "timepoint" "convert-timescale"))))
:depends-on (init input-output)
:components
((:file "units")
(:file "scalar" :depends-on ("units"))
(:file "grid" :depends-on ("scalar"))
(:file "funcall")
(:file "unit-definitions" :depends-on ("units" "grid" "funcall"))
(:file "sysunit-definitions"
:depends-on ("units" "unit-definitions"))
(:file "physical-quantities" :depends-on ("units" "scalar"))
(:file "undimension" :depends-on ("physical-quantities"))
(:file "arithmetic" :depends-on ("units" "undimension"))
(:file "iso8601")
(:file "dtspec" :depends-on ("iso8601"))
(:file "time-interval"
:depends-on
("sysunit-definitions" "physical-quantities" "iso8601" "dtspec"))
(:file "angle"
:depends-on
;; Dependency to force loading of everything needed
;; to put #_1_unit into source code.
("physical-quantities" ; needs split-sequence
"arithmetic"
"undimension"
"unit-definitions"
"sysunit-definitions" "dtspec" "time-interval"))
(:file "angle-component"
:depends-on
("physical-quantities"
"undimension"
"unit-definitions"
"sysunit-definitions"))
(:file "state" :depends-on ("units"))
(:file "timepoint"
:depends-on
("unit-definitions"
"sysunit-definitions"
"physical-quantities" "arithmetic"
"dtspec" "iso8601" "time-interval"))
(:file "relative-time" :depends-on ("timepoint"))
(:file "read-time" :depends-on ("timepoint"))
(:file "formats" :depends-on ("read-time"))
(:file "convert-timescale"
;; Dependency to force loading of everything needed ;
;; to put #_1_unit into source code. ;
:depends-on
("physical-quantities" ; needs split-sequence ;
"arithmetic" "undimension" "unit-definitions"
"sysunit-definitions" "time-interval" "timepoint" "read-time"))
(:file "dtmath"
:depends-on ("dtspec" "read-time" "timepoint" "convert-timescale"))))
(:module mathematics
:serial t
:components
((:file "trigonometry")
(:file "integers")))
:serial t
:components
((:file "trigonometry")
(:file "integers")))
(:module cartesian
:serial t
:components
((:file "cartesian")
(:file "polar")
(:file "rotation")))
:serial t
:components
((:file "cartesian")
(:file "polar")
(:file "rotation")))
(:module tests
:serial t
:components
((:file "format-grid")))))
:serial t
:components
((:file "format-grid")))))
(asdf:defsystem-connection #:degree-symbol
:serial t
......
;; Functions on grids
;; Liam Healy 2010-06-19 22:25:17EDT functions.lisp
;; Time-stamp: <2011-08-20 17:36:46EDT functions.lisp>
;; Time-stamp: <2011-09-09 23:03:11EDT functions.lisp>
;; Copyright 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -222,6 +222,52 @@
(loop for ind from 0 below (total-size grid)
always (antik:zerop (aref* grid ind))))
(defmethod antik::+i ((a sequence) b) ; b is a scalar
(if (gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (antik::+i x b)) a)))
(defmethod antik::+i (a (b sequence)) ; a is a scalar
(if (gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (antik::+i a x)) b)))
(defmethod antik::-i ((a sequence) b) ; b is a scalar
(if (gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (antik::-i x b)) a)))
(defmethod antik::-i (a (b sequence)) ; a is a scalar
(if (null b)
(antik::*i -1 a)
(if (gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (antik::-i a x)) b))))
;; Scalar multiplication of sequences
(defmethod antik::*i ((a sequence) b) ; b is a scalar
(if (gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (antik::*i x b)) a)))
(defmethod antik::*i (a (b sequence)) ; a is a scalar
(if (null b)
a ; null second arg - return first
(if (gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (antik::*i a x)) b))))
;; Scalar division of sequences
(defmethod antik::/i ((a sequence) b)
(if (gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (antik::/i x b)) a)))
(defmethod antik::/i (a (b sequence))
(if (gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (antik::/i a x)) b)))
;;;;****************************************************************************
;;;; Element reference
;;;;****************************************************************************
......
;; Generic functions for generalized numbers
;; Liam Healy Tue Feb 9 1999 - 21:38
;; Time-stamp: <2011-06-03 10:06:13EDT generic.lisp>
;; Time-stamp: <2011-09-09 22:58:09EDT generic.lisp>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -76,15 +76,7 @@
(cl:+ a b))
(:method (a b) (funcall-dyadic '+i a b 'zerop))
(:method ((a sequence) (b sequence))
(map (type-of a) #'+i a b))
(:method ((a sequence) b) ; b is a scalar
(if (grid:gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (+i x b)) a)))
(:method (a (b sequence)) ; a is a scalar
(if (grid:gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (+i a x)) b))))
(map (type-of a) #'+i a b)))
(defun + (&rest args)
"Addition of generalized or regular numbers with an
......@@ -103,17 +95,7 @@
(:method ((a sequence) (b sequence))
(if (null b)
(*i -1 a)
(map (type-of a) #'-i a b)))
(:method ((a sequence) b) ; b is a scalar
(if (grid:gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (-i x b)) a)))
(:method (a (b sequence)) ; a is a scalar
(if (null b)
(*i -1 a)
(if (grid:gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (-i a x)) b)))))
(map (type-of a) #'-i a b))))
(defun - (&rest args)
"Subtraction of generalized or regular numbers."
......@@ -132,18 +114,7 @@
(progn
(assert (eq (length a) (length b)) (a b)
"Sequence arguments are not of the same length.")
(map (type-of a) #'*i a b))))
;; Scalar multiplication of sequences
(:method ((a sequence) b) ; b is a scalar
(if (grid:gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (*i x b)) a)))
(:method (a (b sequence)) ; a is a scalar
(if (null b)
a ; null second arg - return first
(if (grid:gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (*i a x)) b)))))
(map (type-of a) #'*i a b)))))
(defun * (&rest args)
"Multiplication of generalized or regular numbers with an
......@@ -168,17 +139,6 @@
"Sequence arguments are not of the same length.")
(map (type-of a) #'/i a b))))
;; Scalar division of sequences
(defmethod /i ((a sequence) b)
(if (grid:gridp b)
(call-next-method)
(map (type-of a) (lambda (x) (/i x b)) a)))
(defmethod /i (a (b sequence))
(if (grid:gridp a)
(call-next-method)
(map (type-of b) (lambda (x) (/i a x)) b)))
(defun / (&rest args)
"Division of generalized or regular numbers for an
arbitrary number of arguments."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment