Skip to content
Browse files

Added RESHAPE-ROW and RESHAPE-COL.

  • Loading branch information...
1 parent 294bea1 commit 2ed742e602dc70a8921f56dc73b009b5dd45e709 @tpapp committed Oct 8, 2012
Showing with 15 additions and 3 deletions.
  1. +8 −0 src/displacement.lisp
  2. +3 −1 src/package.lisp
  3. +4 −2 tests/tests.lisp
View
8 src/displacement.lisp
@@ -169,3 +169,11 @@ on demand."
(let* ((size (array-total-size array))
(dimensions (fill-in-dimensions dimensions (- size offset))))
(displace array dimensions offset)))
+
+(defun reshape-col (array)
+ "Array reshaped as an Nx1 matrix."
+ (reshape array '(t 1)))
+
+(defun reshape-row (array)
+ "Array reshaped as an 1xN matrix."
+ (reshape array '(1 t)))
View
4 src/package.lisp
@@ -16,7 +16,9 @@
#:partition
#:combine
#:subvec
- #:reshape)
+ #:reshape
+ #:reshape-col
+ #:reshape-row)
(:export ; transformations
#:generate*
#:generate
View
6 tests/tests.lisp
@@ -74,8 +74,10 @@
(ensure-same (setf (ao:subvec b 3 5) #(7 9)) #(7 9))
(ensure-same b #(0 1 2 7 9 5))
(ensure-error (setf (ao:subvec b 3 5) #(7))))
- ;; reshape
- (ensure-same (ao:reshape a '(2 3)) #2A((0 1 2) (3 4 5)))))
+ ;; reshape & variances
+ (ensure-same (ao:reshape a '(2 3)) #2A((0 1 2) (3 4 5)))
+ (ensure-same (ao:reshape-row a) #2A((0 1 2 3 4 5)))
+ (ensure-same (ao:reshape-col a) #2A((0) (1) (2) (3) (4) (5)))))

0 comments on commit 2ed742e

Please sign in to comment.
Something went wrong with that request. Please try again.