clatrix icon indicating copy to clipboard operation
clatrix copied to clipboard

Element map (emap) on matrix returns LazySeq

Open mars0i opened this issue 12 years ago • 4 comments

Applying emap to a clatrix.core.Matrix returns a LazySeq, rather than returning something that preserves the matrix's shape.

(def M (matrix [[1 2][3 4]]))
#'user/M

M
 A 2x2 matrix
 -------------
 1.00e+00  2.00e+00 
 3.00e+00  4.00e+00 

(def Mi (emap inc M))
#'user/Mi

Mi
(2.0 3.0 4.0 5.0)

(type Mi)
clojure.lang.LazySeq

Maybe this is related to issue 36?

(Feel free to let me know if I'm not doing something correctly here. First issue not for my own project.)

mars0i avatar Oct 17 '13 04:10 mars0i

Yep looks like a bug to me: emap should always return a amtrix of the same shape. I'll take a quick look

mikera avatar Oct 17 '13 07:10 mikera

Fixed (I think) in this PR:

https://github.com/tel/clatrix/pull/43

mikera avatar Oct 20 '13 05:10 mikera

The issue is still (again?) there: (emap identity (matrix :clatrix [[1 2][3 4]])) :=> (1.0 2.0 3.0 4.0)

mschuene avatar Apr 26 '14 09:04 mschuene

Hmmm I think my latest PR has a fix for this: https://github.com/tel/clatrix/pull/50

mikera avatar Apr 26 '14 13:04 mikera