Skip to content


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation


Clojars Project

Build Status Dependency Status

The core.matrix library provides array programming as a language extension for Clojure/Clojurescript, with a focus on numerical computing.

core.matrix will become an official part of Clojure Contrib now that the API is mature and proven, at which point this repo will move to org.clojure/core.matrix

The central objective of core.matrix is to make matrix and array programming idiomatic, productive, elegant and fast in the Clojure environment.

(+ [[1 2]
    [3 4]]
   (* (identity-matrix 2) 3.0))

=> [[4.0 2.0]
    [3.0 7.0]]

(shape [[2 3 4] [5 6 7]]) ; => [2 3]

  (array [[2 2] [3 3]])
  (array [[4 4] [5 5]])) ; => [[18 18] [27 27]]

;; Note: nested Clojure vectors can be used as matrices

Key goals of core.matrix:

  • Provide a clear, standard API / abstraction for matrix and array programming in Clojure
  • Enable pluggable support for different underlying matrix library implementations
  • Provide general purpose n-dimensional array implementations
  • Provide a foundation for other projects in the ecosystem (e.g. Incanter)
  • Enable high performance numerical computing
  • Allow idiomatic Clojure coding for numerical code


For general core.matrix documentation and examples see the Wiki:

API documentation is available here

For a general introduction, the slide and video from the 2013 Clojure Conj talk are available here:


To develop for clojurescript you will need to use the cljs-dev profile like this:

lein with-profile +cljs-dev repl

or using figwheel:

lein with-profile +cljs-dev figwheel

To build the Clojurescript unit tests you can run:

lein with-profile +cljs cljsbuild once

and then load resources/public/test.html in a browser to run the tests.


A Docker setup is available for quick reproducable envivironment.

Sample Commands

To build the dev environment image. This is currently based on clojure:openjdk-11-lein-buster image.

`docker build -f ./docker/Dockerfile . -t core.matrix-dev`

To run the build after the dev image is ready

`docker run --rm core.matrix-dev`

To run interactive bash shell for adhoc build commands

`docker run -it --entrypoint bash core.matrix-dev`


core.matrix is fully functional and usable in production applications. As well as supporting the standard Clojure data structures, multiple back end implementations exist that provide optimised matrix implementations. The most mature implementations are currently:

  • vectorz-clj : a fast pure-JVM matrix library for Clojure, supporting full ND arrays
  • Clatrix : native code matrix library using BLAS
  • NDArray : a general purpose pure Clojure N-dimensional array implementation, included as part of core.matrix itself
  • nd4clj : This is a wrapper around the Nd4j api a native code and GPU accelerated matrix library

For Clojurescript:

  • aljabr : a cljc matrix library supporting Clojurescript

The API is relatively mature but still subject to some changes at present (at least up until release 1.0.0), so users should be prepared to deal with potential breaking changes when updating to future releases.


All contributions / ideas welcome!

There are a number of proposed enhancements listed as GitHub issues: these are a good place to start if you wish to contribute to core.matrix:

If you wish to contribute code, please ensure you have a Clojure Contributors Agreement signed and on file. For more information see:

Discussions related to core.matrix generally take place on the "Numerical Clojure" group:

If you are interested in writing a core.matrix implementation, see:

You can also find a protocol implementation summary here:


YourKit is kindly supporting this open source project with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.


core.matrix : Multi-dimensional array programming API for Clojure







No packages published