mikera / vectorz-clj

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

(matrix/set-current-implementation :vectorz) or (set-current-implementation :vectorz); which one is correct? #72

Open madeinquant opened 3 years ago

madeinquant commented 3 years ago

What is the difference between both statements?

  1. with a ns matrix, (matrix/set-current-implementation :vectorz)
  2. without a ns matrix , (matrix/set-current-implementation :vectorz)

dependencies

[net.mikera/core.matrix "0.62.0"]
[net.mikera/vectorz-clj "0.48.0"]

Create a matrix successfully.

(use 'clojure.core.matrix)
(use 'clojure.core.matrix.random)
(use 'clojure.core.matrix.operators)  ;; for +, -, * etc.
**(matrix/set-current-implementation :vectorz)**
(def v (matrix [1 2]))

#'cljsl.ch1.examples/v

Create a matrix unsuccessfully.

(use 'clojure.core.matrix)
(use 'clojure.core.matrix.random)
(use 'clojure.core.matrix.operators)  ;; for +, -, * etc.
**(set-current-implementation :vectorz)**
(def v (matrix [1 2]))

Execution error at clojure.core.matrix.implementations/get-canonical-object (implementations.clj:64).
Unable to find implementation: [:vectorz]
mikera commented 3 years ago

They should be equivalent, so this is a bit surprising.

However the latter error strongly suggests that the :vectorz implementation hasn't yet been loaded. There could be some dependency issue or namespaces weren't properly loaded. core.matrix makes a "best efforts" attempt to find the implementation but will fail if it can't find it.

It might be possible to require one of the vectorz namespaces explicitly (maybe with :reload?) to force it to register the implementation?