Commit d1b8b428 authored by Liam Healy's avatar Liam Healy

Define the outer product of grids

parent bb03e233
;; Inner product, norms
;; Liam Healy 2009-12-13 12:23:01EST inner.lisp
;; Time-stamp: <2012-12-02 23:54:34EST norm-vector-product.lisp>
;; Time-stamp: <2016-01-06 17:45:51EST norm-vector-product.lisp>
;;
;; Copyright 2009, 2010, 2012 Liam M. Healy
;; Copyright 2009, 2010, 2012, 2016 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
......@@ -24,7 +24,7 @@
;;;; Vector products
;;;;****************************************************************************
(export '(cross inner euclidean norm normalize))
(export '(cross inner euclidean norm normalize outer))
(defun cross (grid0 grid1)
"The cross product of two vectors, using the first three components of each."
......@@ -75,6 +75,27 @@
(when norm
(values (antik:/ grid norm) norm))))
(defgeneric outer (grid0 grid1)
(:documentation "The outer product of two grids.")
;; For now, the grids are presumed to be one dimensional.
(:method ((grid0 t) (grid1 t))
(let ((w0 (affi:make-walker (affi grid0)))
(product
;; Perhaps a "make grid like" function is needed
(make-simple-grid
:dimensions (list (dim0 grid0) (dim0 grid1))
:element-type (element-type grid0)
:grid-type (grid::top-spec-type (grid:specification grid0)))))
(loop for e0 = (funcall w0)
while e0
do
(let ((w1 (affi:make-walker (affi grid1))))
(loop for e1 = (funcall w1)
while e1
do (setf (aref product e0 e1)
(antik:* (aref* grid0 e0) (aref* grid1 e1))))))
product)))
;;;;****************************************************************************
;;;; Make a matrix out of column vectors
;;;;****************************************************************************
......
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