Skip to content

NuMojo

A library for numerical computing in Mojo 🔥 — fast, vectorized, and GPU-ready. Inspired by NumPy and SciPy.


What is NuMojo?

NuMojo provides fast, vectorized numerical routines for Mojo — the same role NumPy and SciPy play in the Python ecosystem, but built from the ground up to exploit Mojo's native SIMD, parallelism, and (future) GPU acceleration.

NuMojo is not a machine learning library and will never include back-propagation.


Core types

Type Description
NDArray General-purpose N-dimensional array for tensors, grids, batches
Matrix Dedicated 2-D array optimized for linear-algebra workflows
ComplexNDArray N-dimensional array of complex numbers

Highlights

import numojo as nm
from numojo.prelude import *

fn main() raises:
    var A = nm.random.randn(Shape(1000, 1000))
    var B = nm.random.randn(Shape(1000, 1000))
    var C = A @ B
    var I = nm.inv(A)
    var s = A[1:3, 4:19]
    print(nm.sum(A))
from numojo import Matrix
import numojo as nm

fn main() raises:
    var A = Matrix.rand(shape=(1000, 1000))
    var B = Matrix.rand(shape=(1000, 1))
    var x = nm.solve(A, B)
    print(x)
import numojo as nm
from numojo.prelude import *

fn main() raises:
    var z = CScalar[cf32](5)
    var A = nm.full[cf32](Shape(4, 4), fill_value=z)
    var B = nm.ones[cf32](Shape(4, 4))
    print(A * B)

Routines at a glance

  • Creationzeros, ones, arange, linspace, fromstring, random, …
  • Manipulationreshape, transpose, flip, broadcast_to, …
  • Mathsin, cos, exp, log, sqrt, arithmetic, rounding, …
  • Linear algebramatmul, inv, solve, lstsq, det, norm, decompositions, …
  • Logicall, any, comparison, logical ops, …
  • Statisticsmean, std, var, sum, prod, min, max, …
  • Sorting & searchingsort, argsort, argmin, argmax, …
  • I/O — file read/write, formatting, …
  • Science — interpolation, signal processing, …

Installation

The fastest way to get started:

[workspace]
channels = ["https://repo.prefix.dev/modular-community"]

[dependencies]
numojo = "=0.8.0"
pixi install

See the full installation guide for all methods.


Version compatibility

NuMojo Mojo
v0.8.0 ==25.7
v0.7.0 ==25.3
v0.6.1 ==25.2

License

Apache 2.0 with LLVM Exceptions. See LICENSE.

Contributors

Contributors