by mikera

mikera / vectorz-clj

Fast matrix and vector maths library for Clojure - as a core.matrix implementation

196 Stars 20 Forks Last release: Not found 1.0K Commits 69 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Join the chat at

Clojars Project

Build Status Dependency Status

Fast vector and matrix library for Clojure, building on the Vectorz library and designed to work with the core.matrix array programming API.

is designed so that you don't have to compromise, offering both:
  • An idiomatic high-level Clojure API using core.matrix
  • General purpose multi-dimensional arrays
  • High performance (about as fast as you can get on the JVM). vectorz-clj is currently the fastest pure-JVM vector/matrix library available for Clojure

The library was originally designed for games, simulations and machine learning applications, but should be applicable for any situations where you need numerical


Important features:

  • "Pure" functions for an idiomatic functional programming style are provided. These return new vectors without mutating their arguments.
  • Primitive-backed special purpose vectors and matrices for performance, e.g.
    for fast 3D maths.
  • Flexible DSL-style functions for manipulating vectors and matrices, e.g. the ability to create a "view" into a subspace of a large vector.
  • core.matrix fully supported - see:
  • Pure cross-platform JVM code - no native dependencies
  • "Impure" functions that mutate vectors are available for performance when you need it: i.e. you can use a nice functional style most of the time, but switch to mutation when you hit a bottleneck.


vectorz-clj is intended to be used primarily as a

implementation. As such, the main API to understand is
itself. See the
wiki for more information:

For more information about the specific details of vectorz-clj itself, see the vectorz-clj Wiki.


requires Clojure 1.4 or above, Java 1.7 or above, and an up to date version of core.matrix

is reasonably stable, and implements all of the core.matrix API feature set.



is licensed under the LGPL license:


Follow the instructions to install with Leiningen / Maven from Clojars:


You can then use

as a standard
implementation. Example:
    (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]]))
=&gt; #<matrix22>

;; define a length 2 vector (a 1D matrix is considered equivalent to a vector in core.matrix)
(def v (matrix [1 2]))
=&gt; #<vector2>

;; Matrix x Vector elementwise multiply
(mul M v)
=&gt; #<matrix22>

;; Matrix x Vector matrix multiply (inner product)
(inner-product M v)
=&gt; #<vector2>

For more examples see Wiki Examples

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.