Fast matrix and vector maths library for Clojure - as a core.matrix implementation
vectorz-cljis designed so that you don't have to compromise, offering both:
The library was originally designed for games, simulations and machine learning applications, but should be applicable for any situations where you need numerical
Vector3for fast 3D maths.
vectorz-clj is intended to be used primarily as a
core.matriximplementation. As such, the main API to understand is
core.matrixitself. See the
core.matrixwiki for more information:
For more information about the specific details of vectorz-clj itself, see the vectorz-clj Wiki.
vectorz-cljrequires Clojure 1.4 or above, Java 1.7 or above, and an up to date version of core.matrix
vectorz-cljis reasonably stable, and implements all of the core.matrix API feature set.
vectorz-cljis licensed under the LGPL license:
Follow the instructions to install with Leiningen / Maven from Clojars:
You can then use
Vectorzas a standard
(use 'clojure.core.matrix) (use 'clojure.core.matrix.operators) ;; overrides *, + etc. for matrices
(set-current-implementation :vectorz) ;; use Vectorz as default matrix implementation ;; define a 2x2 Matrix (def M (matrix [[1 2] [3 4]])) M => #<matrix22> ;; define a length 2 vector (a 1D matrix is considered equivalent to a vector in core.matrix) (def v (matrix [1 2])) v => #<vector2> ;; Matrix x Vector elementwise multiply (mul M v) => #<matrix22> ;; Matrix x Vector matrix multiply (inner product) (inner-product M v) => #<vector2>
For more examples see Wiki Examples