From 5145dd3aa0c02c9fc496d1432fc4410674206e1d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:31 -0800 Subject: Import Upstream version 3a2 --- subarray.txi | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'subarray.txi') diff --git a/subarray.txi b/subarray.txi index 7d62ed6..1a0545f 100644 --- a/subarray.txi +++ b/subarray.txi @@ -36,31 +36,12 @@ shared. @end example @end defun -@defun subarray0 array select @dots{} -Behaves like @r{subarray}, but @r{align}s the returned array origin to -0 @dots{}. -@end defun - -@defun array-align array coord @dots{} +@defvar subarray0 +Legacy alias for @r{subarray}. +@end defvar -Returns an array shared with @var{array} but with a different origin. The @var{coords} -are the exact integer coordinates of the new origin. Indexes -corresponding to missing or #f coordinates are not realigned. - -For example: -@example -(define ra2 (create-array '#(5) '(5 9) '(-4 0))) -(array-shape ra2) @result{} ((5 9) (-4 0)) -(array-shape (array-align ra2 0 0)) @result{} ((0 4) (0 4)) -(array-shape (array-align ra2 0)) @result{} ((0 4) (-4 0)) -(array-shape (array-align ra2)) @result{} ((5 9) (-4 0)) -(array-shape (array-align ra2 0 #f)) @result{} ((0 4) (-4 0)) -(array-shape (array-align ra2 #f 0)) @result{} ((5 9) (0 4)) -@end example -@end defun - @defun array-trim array trim @dots{} @@ -73,22 +54,15 @@ bound. For example: @example -(array-trim '#(0 1 2 3 4) 1) @result{} #1A(1 2 3 4) ;; shape is ((0 3)) -(array-trim '#(0 1 2 3 4) -1) @result{} #1A(0 1 2 3) ;; shape is ((1 4)) +(array-trim '#(0 1 2 3 4) 1) @result{} #1A(1 2 3 4) +(array-trim '#(0 1 2 3 4) -1) @result{} #1A(0 1 2 3) (require 'array-for-each) (define (centered-difference ra) - (array-map - (array-trim ra 1) (array-trim ra -1))) -(define (forward-difference ra) - (array-map - (array-trim ra 1) ra)) -(define (backward-difference ra) - (array-map - ra (array-trim ra -1))) + (array-map ra - (array-trim ra 1) (array-trim ra -1))) (centered-difference '#(0 1 3 5 9 22)) - @result{} #1A(3 4 6 17) ;;shape is ((1 4)) -(backward-difference '#(0 1 3 5 9 22)) - @result{} #1A(1 2 2 4 13) ;; shape is ((1 5)) -(forward-difference '#(0 1 3 5 9 22)) - @result{} #(1 2 2 4 13) ;; shape is ((0 4)) + @result{} #(1 2 2 4 13) @end example @end defun + -- cgit v1.2.3