Commit 26271f71 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Methods for arithmetic functions on foreign-arrays

Depend on Antik instead of GSD.  Add new methods for Antik functions
on foreign-arrays.  This permits algebra-style computation on arrays,
e.g.,
(in-package :antik-user)
(setf grid:*default-grid-type* 'grid:foreign-array)
(expt (* (rotate-3d :z #_15_deg) (rotate-3d :z #_45_deg)) -1)
#m((0.5 0.8660254037844386 0.0) (-0.8660254037844385 0.5000000000000001 -0.0)
   (0.0 0.0 1.0))
(rotate-3d :z #_-60_deg)
#m((0.5000000000000001 0.8660254037844386 0.0)
   (-0.8660254037844386 0.5000000000000001 0.0) (0.0 0.0 1.0))
parent 6010bde3
;; Define generic operators for GSL functions
;; Liam Healy 2011-01-01 09:51:47EST linear-algebra.lisp
;; Time-stamp: <2011-01-01 10:58:18EST linear-algebra.lisp>
;; $Id: $
(in-package :antik)
(defmethod *i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:matrix-product a b))
(defmethod *i ((a grid:foreign-array) (b number))
(gsl:scale b a))
(defmethod *i ((a number) (b grid:foreign-array))
(gsl:scale a b))
(defmethod /i ((a grid:foreign-array) (b number))
(gsl:scale (cl:/ b) a))
(defmethod +i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:elt+ a b))
(defmethod +i ((a grid:foreign-array) (b number))
(gsl:elt+ a b))
(defmethod +i ((a number) (b grid:foreign-array))
(gsl:elt+ b a))
(defmethod -i ((a grid:foreign-array) (b grid:foreign-array))
(gsl:elt- a b))
(defmethod -i ((a grid:foreign-array) (b number))
(gsl:elt+ a (cl:- b)))
(defmethod -i ((a number) (b grid:foreign-array))
(gsl:elt+ (- b) a))
(defmethod expt ((a grid:matrix) (b integer))
(cond ((= 1 b) a)
((plusp b) ; use addition-chain exponentiation
(* a (expt a (1- b))))
((minusp b)
(expt (gsl:invert-matrix a) (- b)))
;; zero exponent; need to figure out non-square matrix
(t (grid:identity-matrix (grid:dim0 a)))))
;; Definition of GSLL system
;; Liam Healy
;; Time-stamp: <2010-08-13 11:36:52EDT gsll.asd>
;; Time-stamp: <2011-01-01 10:57:50EST gsll.asd>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010 Liam M. Healy
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -30,7 +30,7 @@
:version "0"
:author "Liam M. Healy"
:licence "GPL v3"
:depends-on (foreign-array grid cffi cffi-grovel trivial-garbage #+fsbv fsbv)
:depends-on (antik cffi-grovel trivial-garbage #+fsbv fsbv)
:components
((:module init
:components
......@@ -266,4 +266,8 @@
:components
((cffi-grovel:grovel-file "mksa")
(cffi-grovel:grovel-file "cgsm")
(:file export)))))
(:file export)))
(:module antik
:depends-on (init linear-algebra)
:components
((:file "linear-algebra")))))
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