-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Right now, the Clatrix has inconsistency in how it represent rows when executing seq/map/filter & other related operations. Clatrix uses the 1x2 matrices to represent rows, while other implementations (like, vectorz-clj) use the separate types to represent them. This lead to problem when trying to create matrix from the result of the map or filter - the dimensionality returns 3 instead of correct 2, like in other implementations, and this lead to exception when trying to construct matrix (in functions clatrix & construct-clatrix).
incanter.core> (set-current-implementation :clatrix)
:clatrix
incanter.core> (def m (matrix [[1 0] [2 1]]))
#'incanter.core/m
incanter.core> (m/dimensionality (map identity m))
3
incanter.core> (map identity m)
( A 1x2 matrix
-------------
1.00e+00 0.00e+00
A 1x2 matrix
-------------
2.00e+00 1.00e+00
)
incanter.core> (set-current-implementation :vectorz)
:vectorz
incanter.core> (def m (matrix [[1 0] [2 1]]))
#'incanter.core/m
incanter.core> (m/dimensionality (map identity m))
2
incanter.core> (map identity m)
(#<ArraySubVector [1.0,0.0]> #<ArraySubVector [2.0,1.0]>)
I have a small workaround for clatrix & construct-clatrix that checks if the every element is 1xN matrix, and the use the join to merge results together, but the correct solution will be the use of separate type (existing Vector type) to represent rows when calling seq.