mikera / vectorz-clj

Fast matrix and vector maths library for Clojure - as a core.matrix implementation
203 stars 19 forks source link

Successful broadcasting by comparison operators depends on operand order #68

Open cguenthner opened 5 years ago

cguenthner commented 5 years ago
(require '[clojure.core.matrix :as m])

(m/set-current-implementation :vectorz)

(def vect (m/array [1 0]))
(def mat (m/array [[0 0] [1 1]]))

(m/eq mat vect) ;; => [[0 1] [1 0]]
(m/eq vect mat) ;; java.lang.IllegalArgumentException
                ;; Can't broadcast Matrix with shape [2,2] to shape: [2]

The above exception does not occur with the ndarray core.matrix implementation. With vectorz, it occurs with at least some of the other comparison operators (e.g. ne, gt) but not with at least some of the other arithmetic operators (e.g. add).