Returns a vector-of-vectors if the given matrix is two-dimensional
and a flat vector if the matrix is one-dimensional. This is a bit
slower than the to-list function.
(defn to-vect
" Returns a vector-of-vectors if the given matrix is two-dimensional
and a flat vector if the matrix is one-dimensional. This is a bit
slower than the to-list function. "
([^Matrix mat]
(into [] (cond
(= (.columns mat) 1)
(first (map #(into [] (seq %)) (seq (.toArray (.viewDice mat)))))
(= (.rows mat) 1)
(first (map #(into [] (seq %)) (seq (.toArray mat))))
:else
(map #(into [] (seq %)) (seq (.toArray mat)))))))
Comments top
No comments for to-vect. Log in to add a comment.