Commit 141dbe9b authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Create grids from index/indices

Two new functions in new file grid/index-functions.lisp
    make-grid-from-index
    make-grid-sequential-elements
will create grids from the index or indices. The first one is general,
the second one creates elements as an affine transformation
(step/offset) of the indices. These functions are more general than
and replace the test-grid-double-float and offset-ifd which were
written for test grid generation.
parent 86671c4e
;; Tests of grid composition functions on foreign-array ;; Tests of grid composition functions on foreign-array
;; Liam Healy 2009-11-28 17:12:53EST compose.lisp ;; Liam Healy 2009-11-28 17:12:53EST compose.lisp
;; Time-stamp: <2010-07-15 09:37:51EDT compose.lisp> ;; Time-stamp: <2013-12-28 11:00:56EST compose.lisp>
;; ;;
;; Copyright 2009, 2010 Liam M. Healy ;; Copyright 2009, 2010, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
;; ;;
;; This program is free software: you can redistribute it and/or modify ;; This program is free software: you can redistribute it and/or modify
...@@ -27,10 +27,18 @@ ...@@ -27,10 +27,18 @@
(lisp-unit:define-test drop-fa (lisp-unit:define-test drop-fa
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 10.0d0 20.0d0 30.0d0 40.0d0) '(0.0d0 10.0d0 20.0d0 30.0d0 40.0d0)
(contents (drop (test-grid-double-float 'foreign-array '(5 1))))) (contents (drop
(make-grid-sequential-elements
:dimensions '(5 1)
:grid-type 'foreign-array
:element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0) '(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0)
(contents (drop (test-grid-double-float 'foreign-array '(1 5)))))) (contents (drop
(make-grid-sequential-elements
:dimensions '(1 5)
:grid-type 'foreign-array
:element-type 'double-float)))))
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Subgrid ;;;; Subgrid
...@@ -39,28 +47,28 @@ ...@@ -39,28 +47,28 @@
(lisp-unit:define-test subgrid-fa (lisp-unit:define-test subgrid-fa
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 1.0d0 2.0d0 3.0d0) '(0.0d0 1.0d0 2.0d0 3.0d0)
(contents (row (test-grid-double-float 'foreign-array '(3 4)) 0))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 0)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(10.0d0 11.0d0 12.0d0 13.0d0) '(10.0d0 11.0d0 12.0d0 13.0d0)
(contents (row (test-grid-double-float 'foreign-array '(3 4)) 1))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(20.0d0 21.0d0 22.0d0 23.0d0) '(20.0d0 21.0d0 22.0d0 23.0d0)
(contents (row (test-grid-double-float 'foreign-array '(3 4)) 2))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 10.0d0 20.0d0) '(0.0d0 10.0d0 20.0d0)
(contents (column (test-grid-double-float 'foreign-array '(3 4)) 0))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 0)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(1.0d0 11.0d0 21.0d0) '(1.0d0 11.0d0 21.0d0)
(contents (column (test-grid-double-float 'foreign-array '(3 4)) 1))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(2.0d0 12.0d0 22.0d0) '(2.0d0 12.0d0 22.0d0)
(contents (column (test-grid-double-float 'foreign-array '(3 4)) 2))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(3.0d0 13.0d0 23.0d0) '(3.0d0 13.0d0 23.0d0)
(contents (column (test-grid-double-float 'foreign-array '(3 4)) 3))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) 3)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((12.0d0 13.0d0) (22.0d0 23.0d0)) '((12.0d0 13.0d0) (22.0d0 23.0d0))
(contents (subgrid (test-grid-double-float 'foreign-array '(3 4)) '(2 2) '(1 2))))) (contents (subgrid (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) '(2 2) '(1 2)))))
(lisp-unit:define-test subgrid-setf-fa (lisp-unit:define-test subgrid-setf-fa
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
...@@ -138,10 +146,13 @@ ...@@ -138,10 +146,13 @@
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0) (1.0d0 11.0d0 21.0d0) '((0.0d0 10.0d0 20.0d0) (1.0d0 11.0d0 21.0d0)
(2.0d0 12.0d0 22.0d0) (3.0d0 13.0d0 23.0d0)) (2.0d0 12.0d0 22.0d0) (3.0d0 13.0d0 23.0d0))
(contents (transpose (test-grid-double-float 'foreign-array '(3 4))))) (contents (transpose (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0 30.0d0 40.0d0)) '((0.0d0 10.0d0 20.0d0 30.0d0 40.0d0))
(contents (transpose (test-grid-double-float 'foreign-array '(5 1))))) (contents (transpose (make-grid-sequential-elements
:dimensions '(5 1)
:grid-type 'foreign-array
:element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0 0.0d0 0.0d0) '((0.0d0 10.0d0 20.0d0 0.0d0 0.0d0)
(1.0d0 11.0d0 21.0d0 0.0d0 0.0d0) (1.0d0 11.0d0 21.0d0 0.0d0 0.0d0)
...@@ -149,7 +160,7 @@ ...@@ -149,7 +160,7 @@
(3.0d0 13.0d0 23.0d0 0.0d0 0.0d0) (3.0d0 13.0d0 23.0d0 0.0d0 0.0d0)
(0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)) (0.0d0 0.0d0 0.0d0 0.0d0 0.0d0))
(contents (transpose (contents (transpose
(test-grid-double-float 'foreign-array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float)
:destination :destination
(make-array '(5 5) :element-type 'double-float :initial-element 0.0d0)))) (make-array '(5 5) :element-type 'double-float :initial-element 0.0d0))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
...@@ -159,7 +170,7 @@ ...@@ -159,7 +170,7 @@
(0.0d0 2.0d0 12.0d0 22.0d0 0.0d0) (0.0d0 2.0d0 12.0d0 22.0d0 0.0d0)
(0.0d0 3.0d0 13.0d0 23.0d0 0.0d0)) (0.0d0 3.0d0 13.0d0 23.0d0 0.0d0))
(contents (transpose (contents (transpose
(test-grid-double-float 'foreign-array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float)
:destination :destination
(make-array '(5 5) :element-type 'double-float :initial-element 0.0d0) (make-array '(5 5) :element-type 'double-float :initial-element 0.0d0)
:start '(1 1))))) :start '(1 1)))))
...@@ -171,22 +182,22 @@ ...@@ -171,22 +182,22 @@
(lisp-unit:define-test diagonal-fa (lisp-unit:define-test diagonal-fa
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 11.0d0 22.0d0) '(0.0d0 11.0d0 22.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4))))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(1.0d0 12.0d0 23.0d0) '(1.0d0 12.0d0 23.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4)) :offset 1))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) :offset 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(2.0d0 13.0d0) '(2.0d0 13.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4)) :offset 2))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) :offset 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(3.0d0) '(3.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4)) :offset 3))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) :offset 3)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(10.0d0 21.0d0) '(10.0d0 21.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4)) :offset -1))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) :offset -1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(20.0d0) '(20.0d0)
(contents (diagonal (test-grid-double-float 'foreign-array '(3 4)) :offset -2))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float) :offset -2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((1.0d0 0.0d0 0.0d0) (0.0d0 2.0d0 0.0d0) (0.0d0 0.0d0 3.0d0)) '((1.0d0 0.0d0 0.0d0) (0.0d0 2.0d0 0.0d0) (0.0d0 0.0d0 3.0d0))
(let ((arr3x3 (make-grid '((foreign-array 3 3) double-float) (let ((arr3x3 (make-grid '((foreign-array 3 3) double-float)
...@@ -216,18 +227,20 @@ ...@@ -216,18 +227,20 @@
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(-77.7d0 -77.7d0 -77.7d0 0.0d0 11.0d0 22.0d0) '(-77.7d0 -77.7d0 -77.7d0 0.0d0 11.0d0 22.0d0)
(contents (contents
(map-grid :source (test-grid-double-float 'foreign-array '(3 4)) (let ((source (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float)))
:source-affi (affi:diagonal (affi (test-grid-double-float 'foreign-array '(3 4)))) (map-grid :source source
:destination-affi (affi:make-affi '(6) 3) :source-affi (affi:diagonal (affi source))
:initial-element -77.7d0))) :destination-affi (affi:make-affi '(6) 3)
:initial-element -77.7d0))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(-77.7d0 -77.7d0 -77.7d0 -77.7d0 -66.7d0 -55.7d0) '(-77.7d0 -77.7d0 -77.7d0 -77.7d0 -66.7d0 -55.7d0)
(contents (contents
(map-grid :source (test-grid-double-float 'foreign-array '(3 4)) (let ((source (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'foreign-array :element-type 'double-float)))
:source-affi (affi:diagonal (affi (test-grid-double-float 'foreign-array '(3 4)))) (map-grid :source source
:destination-affi (affi:make-affi '(6) 3) :source-affi (affi:diagonal (affi source))
:initial-element -77.7d0 :destination-affi (affi:make-affi '(6) 3)
:combination-function '+)))) :initial-element -77.7d0
:combination-function '+)))))
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Concatenate ;;;; Concatenate
......
;; Antik system definition ;; Antik system definition
;; Liam Healy 2010-12-24 09:43:28EST antik.asd ;; Liam Healy 2010-12-24 09:43:28EST antik.asd
;; Time-stamp: <2013-11-24 12:25:02EST grid.asd> ;; Time-stamp: <2013-12-25 16:00:14EST grid.asd>
;; Copyright 2011, 2012, 2013 Liam M. Healy ;; Copyright 2011, 2012, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -48,9 +48,7 @@ ...@@ -48,9 +48,7 @@
(:file "copy") (:file "copy")
(:file "iterate" :depends-on ("compose")) (:file "iterate" :depends-on ("compose"))
(:file "mathematics" :depends-on ("map")) (:file "mathematics" :depends-on ("map"))
(:module tests (:file "index-functions")))))
:components
((:file "grids")))))))
(asdf:defsystem-connection #:grid-tests (asdf:defsystem-connection #:grid-tests
:serial t :serial t
......
;; Function to make grids based on functions of the indices
;; Liam Healy 2013-12-25 12:56:53EST index-functions.lisp
;; Time-stamp: <2013-12-28 11:09:32EST index-functions.lisp>
;; Copyright 2013 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
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :grid)
(export '(make-grid-from-index make-grid-sequential-elements))
;;; Needed:
;;; Tests with destination
;;; Tests without destination
;;; Documentation/examples
;;; Examples
;;; (make-grid-from-index (lambda (i j) (+ j (* 10 i))) :dimensions '(4 4))
;;; (make-grid-from-index (lambda (i) (+ 4 (* 3 i))))
;;; (make-grid-sequential-elements :dimensions '(4 4) :grid-type 'foreign-array)
;;; (make-grid-sequential-elements :dimensions '(4 4) :element-type '(signed-byte 64))
;;; (make-grid-sequential-elements :dimensions '(4 4) :grid-type 'array)
;;; (make-grid-sequential-elements :dimensions '(4 4) :grid-type 'array :element-type 'fixnum)
;;; #2A((0 1 2 3) (10 11 12 13) (20 21 22 23) (30 31 32 33))
(defun make-grid-from-index
(function
&key
destination
destination-specification
(grid-type *default-grid-type*)
(dimensions *default-dimensions*)
(element-type *default-element-type*))
"Make or set a grid from the index or indices. The function gets the indices as arguments, and returns a value that will become the element at that index."
(grid:map-grid
:source function
:destination-specification
(or destination-specification (make-specification grid-type dimensions element-type))
:destination destination))
(defun make-grid-sequential-elements
(&rest args &key (offset 0) (step-col 1) (step-row 10) &allow-other-keys)
"Create or set values in a grid with a value based on an affine transformation of the index or indices."
(apply
#'make-grid-from-index
(lambda (i &optional j)
(if j
(+ offset (* step-col j) (* step-row i))
(+ offset (* step-col i))))
(alexandria:remove-from-plist args :offset :step-col :step-row)))
;; Iterate ;; Iterate
;; Norman Werner 2009-05-26 22:23:40EDT iterate.lisp ;; Norman Werner 2009-05-26 22:23:40EDT iterate.lisp
;; Time-stamp: <2013-06-23 22:46:42EDT iterate.lisp> ;; Time-stamp: <2013-12-25 15:40:34EST iterate.lisp>
;; ;;
;; Copyright 2009, 2013 Norman Werner, Liam M. Healy ;; Copyright 2009, 2013 Norman Werner, Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#| #|
As an example try: As an example try:
(defparameter *array-3-4-double-float* (test-grid-double-float 'array '(3 4))) (defparameter *array-3-4-double-float* (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float))
(iter:iter (iter:for e :matrix-element *array-3-4-double-float*) (iter:iter (iter:for e :matrix-element *array-3-4-double-float*)
(princ e) (princ " ")) (princ e) (princ " "))
......
;; Tests of grid composition functions ;; Tests of grid composition functions
;; Liam Healy 2009-11-28 17:12:53EST compose.lisp ;; Liam Healy 2009-11-28 17:12:53EST compose.lisp
;; Time-stamp: <2010-07-15 09:41:17EDT compose.lisp> ;; Time-stamp: <2013-12-28 10:22:46EST compose.lisp>
;; ;;
;; Copyright 2009 Liam M. Healy ;; Copyright 2009, 2010, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
;; ;;
;; This program is free software: you can redistribute it and/or modify ;; This program is free software: you can redistribute it and/or modify
...@@ -27,10 +27,16 @@ ...@@ -27,10 +27,16 @@
(lisp-unit:define-test drop (lisp-unit:define-test drop
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 10.0d0 20.0d0 30.0d0 40.0d0) '(0.0d0 10.0d0 20.0d0 30.0d0 40.0d0)
(contents (drop (test-grid-double-float 'array '(5 1))))) (contents (drop (make-grid-sequential-elements
:dimensions '(5 1)
:grid-type 'array
:element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0) '(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0)
(contents (drop (test-grid-double-float 'array '(1 5)))))) (contents (drop (make-grid-sequential-elements
:dimensions '(1 5)
:grid-type 'array
:element-type 'double-float)))))
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Subgrid ;;;; Subgrid
...@@ -39,28 +45,28 @@ ...@@ -39,28 +45,28 @@
(lisp-unit:define-test subgrid (lisp-unit:define-test subgrid
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 1.0d0 2.0d0 3.0d0) '(0.0d0 1.0d0 2.0d0 3.0d0)
(contents (row (test-grid-double-float 'array '(3 4)) 0))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 0)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(10.0d0 11.0d0 12.0d0 13.0d0) '(10.0d0 11.0d0 12.0d0 13.0d0)
(contents (row (test-grid-double-float 'array '(3 4)) 1))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(20.0d0 21.0d0 22.0d0 23.0d0) '(20.0d0 21.0d0 22.0d0 23.0d0)
(contents (row (test-grid-double-float 'array '(3 4)) 2))) (contents (row (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 10.0d0 20.0d0) '(0.0d0 10.0d0 20.0d0)
(contents (column (test-grid-double-float 'array '(3 4)) 0))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 0)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(1.0d0 11.0d0 21.0d0) '(1.0d0 11.0d0 21.0d0)
(contents (column (test-grid-double-float 'array '(3 4)) 1))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(2.0d0 12.0d0 22.0d0) '(2.0d0 12.0d0 22.0d0)
(contents (column (test-grid-double-float 'array '(3 4)) 2))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(3.0d0 13.0d0 23.0d0) '(3.0d0 13.0d0 23.0d0)
(contents (column (test-grid-double-float 'array '(3 4)) 3))) (contents (column (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) 3)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((12.0d0 13.0d0) (22.0d0 23.0d0)) '((12.0d0 13.0d0) (22.0d0 23.0d0))
(contents (subgrid (test-grid-double-float 'array '(3 4)) '(2 2) '(1 2))))) (contents (subgrid (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) '(2 2) '(1 2)))))
(lisp-unit:define-test subgrid-setf (lisp-unit:define-test subgrid-setf
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
...@@ -138,10 +144,13 @@ ...@@ -138,10 +144,13 @@
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0) (1.0d0 11.0d0 21.0d0) '((0.0d0 10.0d0 20.0d0) (1.0d0 11.0d0 21.0d0)
(2.0d0 12.0d0 22.0d0) (3.0d0 13.0d0 23.0d0)) (2.0d0 12.0d0 22.0d0) (3.0d0 13.0d0 23.0d0))
(contents (transpose (test-grid-double-float 'array '(3 4))))) (contents (transpose (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0 30.0d0 40.0d0)) '((0.0d0 10.0d0 20.0d0 30.0d0 40.0d0))
(contents (transpose (test-grid-double-float 'array '(5 1))))) (contents (transpose (make-grid-sequential-elements
:dimensions '(5 1)
:grid-type 'array
:element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((0.0d0 10.0d0 20.0d0 0.0d0 0.0d0) '((0.0d0 10.0d0 20.0d0 0.0d0 0.0d0)
(1.0d0 11.0d0 21.0d0 0.0d0 0.0d0) (1.0d0 11.0d0 21.0d0 0.0d0 0.0d0)
...@@ -149,7 +158,7 @@ ...@@ -149,7 +158,7 @@
(3.0d0 13.0d0 23.0d0 0.0d0 0.0d0) (3.0d0 13.0d0 23.0d0 0.0d0 0.0d0)
(0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)) (0.0d0 0.0d0 0.0d0 0.0d0 0.0d0))
(contents (transpose (contents (transpose
(test-grid-double-float 'array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:destination :destination
(make-array '(5 5) :element-type 'double-float :initial-element 0.0d0)))) (make-array '(5 5) :element-type 'double-float :initial-element 0.0d0))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
...@@ -159,7 +168,7 @@ ...@@ -159,7 +168,7 @@
(0.0d0 2.0d0 12.0d0 22.0d0 0.0d0) (0.0d0 2.0d0 12.0d0 22.0d0 0.0d0)
(0.0d0 3.0d0 13.0d0 23.0d0 0.0d0)) (0.0d0 3.0d0 13.0d0 23.0d0 0.0d0))
(contents (transpose (contents (transpose
(test-grid-double-float 'array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:destination :destination
(make-array '(5 5) :element-type 'double-float :initial-element 0.0d0) (make-array '(5 5) :element-type 'double-float :initial-element 0.0d0)
:start '(1 1)))) :start '(1 1))))
...@@ -170,7 +179,7 @@ ...@@ -170,7 +179,7 @@
0.0d0 2.0d0 12.0d0 22.0d0 0.0d0 0.0d0 3.0d0 13.0d0 23.0d0 0.0d0 2.0d0 12.0d0 22.0d0 0.0d0 0.0d0 3.0d0 13.0d0 23.0d0
0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)) 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0))
(transpose (transpose
(test-grid-double-float 'array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:destination :destination
(make-grid '((list 5) (list 5) double-float)))) (make-grid '((list 5) (list 5) double-float))))
#+(or) ; not yet ready for composite grids #+(or) ; not yet ready for composite grids
...@@ -180,7 +189,7 @@ ...@@ -180,7 +189,7 @@
0.0d0 2.0d0 12.0d0 22.0d0 0.0d0 0.0d0 3.0d0 13.0d0 23.0d0 0.0d0 2.0d0 12.0d0 22.0d0 0.0d0 0.0d0 3.0d0 13.0d0 23.0d0
0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0)) 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0 0.0d0))
(transpose (transpose
(test-grid-double-float 'array '(3 4)) (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:destination :destination
(make-grid '((list 5) (array 5) double-float))))) (make-grid '((list 5) (array 5) double-float)))))
...@@ -191,22 +200,22 @@ ...@@ -191,22 +200,22 @@
(lisp-unit:define-test diagonal (lisp-unit:define-test diagonal
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(0.0d0 11.0d0 22.0d0) '(0.0d0 11.0d0 22.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4))))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float))))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(1.0d0 12.0d0 23.0d0) '(1.0d0 12.0d0 23.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4)) :offset 1))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) :offset 1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(2.0d0 13.0d0) '(2.0d0 13.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4)) :offset 2))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) :offset 2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(3.0d0) '(3.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4)) :offset 3))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) :offset 3)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(10.0d0 21.0d0) '(10.0d0 21.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4)) :offset -1))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) :offset -1)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(20.0d0) '(20.0d0)
(contents (diagonal (test-grid-double-float 'array '(3 4)) :offset -2))) (contents (diagonal (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float) :offset -2)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'((1.0d0 0.0d0 0.0d0) (0.0d0 2.0d0 0.0d0) (0.0d0 0.0d0 3.0d0)) '((1.0d0 0.0d0 0.0d0) (0.0d0 2.0d0 0.0d0) (0.0d0 0.0d0 3.0d0))
(let ((arr3x3 (make-grid '((array 3 3) double-float) (let ((arr3x3 (make-grid '((array 3 3) double-float)
...@@ -236,15 +245,15 @@ ...@@ -236,15 +245,15 @@
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(-77.7d0 -77.7d0 -77.7d0 0.0d0 11.0d0 22.0d0) '(-77.7d0 -77.7d0 -77.7d0 0.0d0 11.0d0 22.0d0)
(contents (contents
(map-grid :source (test-grid-double-float 'array '(3 4)) (map-grid :source (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:source-affi (affi:diagonal (affi (test-grid-double-float 'array '(3 4)))) :source-affi (affi:diagonal (affi (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)))
:destination-affi (affi:make-affi '(6) 3) :destination-affi (affi:make-affi '(6) 3)
:initial-element -77.7d0))) :initial-element -77.7d0)))
(lisp-unit:assert-numerical-equal (lisp-unit:assert-numerical-equal
'(-77.7d0 -77.7d0 -77.7d0 -77.7d0 -66.7d0 -55.7d0) '(-77.7d0 -77.7d0 -77.7d0 -77.7d0 -66.7d0 -55.7d0)
(contents (contents
(map-grid :source (test-grid-double-float 'array '(3 4)) (map-grid :source (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)
:source-affi (affi:diagonal (affi (test-grid-double-float 'array '(3 4)))) :source-affi (affi:diagonal (affi (make-grid-sequential-elements :dimensions '(3 4) :grid-type 'array :element-type 'double-float)))
:destination-affi (affi:make-affi '(6) 3) :destination-affi (affi:make-affi '(6) 3)
:initial-element -77.7d0 :initial-element -77.7d0
:combination-function '+)))) :combination-function '+))))
...@@ -262,20 +271,20 @@ ...@@ -262,20 +271,20 @@
(10.5d0 11.5d0 12.5d0 13.5d0)) (10.5d0 11.5d0 12.5d0 13.5d0))
(contents