Repository navigation
Releases: mojomath/linamo
Release list
Linamo v0.3.0
Linamo v0.2.0
20261002 (v0.2.0)
Linamo v0.2.0 updates the package to Mojo v1.1.0 and adds complex matrices.
⭐️ New in v0.2.0
- Complex matrices.
Complex[d], with aliasesCFloat64andCFloat32, is a matrix element type.lu,det,solve,inv,matrix_power,cholesky,qrandlstsqsupport it, andfrom_stringreadsa+biliterals. It is notComparable, sosort,minandmaxare absent. conj_transpose, as a routine and a method, through the newConjugabletrait. It is the plain transpose for real element types.
🛠 Changed in v0.2.0
- Pivoting in
lu,det,solve,invandmatrix_powerranks by magnitude, not by order. Results are unchanged. Matrix.__init__(nrows, ncols, row_stride, col_stride)accepts anyNumericelement type.- A parameterised element type keeps its parameters in the printed header, e.g.
Matrix[Complex[float64]]. - Dependencies: Decimo
>=0.15.0,<0.16.0and MAX>=26.6.0,<26.7.0.
💔 Breaking in v0.2.0
- Linamo requires Mojo v1.1.0. Use v0.1.0 for Mojo v1.0.0.
Integeris no longer re-exported. UseBInt(orBigInt) instead.
Linamo v0.1.0
20260901 (v0.1.0)
Linamo v0.1.0 is the first release: linear algebra for Mojo, specialised for
two-dimensional matrices. It targets Mojo v1.0.0 and depends on
Decimo v0.13.0, whose Numeric and Parsable traits are what let a matrix
be parameterised on an element type rather than a DType — the same
operators and routines run over Float64 and over arbitrary-precision numbers.
Everything below is new, so this entry is an inventory of the surface rather
than a diff.
⭐️ New in v0.1.0
Types:
Matrix[T]— an owning, dense 2-D matrix in row- or column-major
layout. The data buffer is aList, not a raw pointer, so the type is
written in safe Mojo.MatrixView[T]— a non-owning window over aMatrix, with strides, so
a slice, a row, a column or a transpose costs no copy. Views are
read-only by default; a mutable view exists only through the
mutationmodule, which is what keeps an accidental write from reaching
the matrix behind someone else's view.StaticMatrix[T, rows, cols]— a matrix whose shape is a compile-time
parameter, so a shape mismatch is a compile error rather than a raise.
to_matrix()crosses over to the dynamic types.- The
MatrixLiketrait and the row/column iterators are shared by all
three.
Element types:
- Any Mojo scalar (
Float64,Int32, …), plusbool_for the masks that
comparisons return. - Decimo's exact numbers —
BInt,Decimal(BigDecimal) and
Decimal128— are re-exported, sola.matrix[Decimal]needs no second
import. Decomposition,det,solveandinvrun over them, which makes
exact elimination available where binary floating point cannot say0.3.
Creation: matrix, smatrix, from_list, from_string, zeros,
ones, full, empty, eye, identity, diag, arange, linspace, the
*_like forms, and rand / seed.
Operators and math: +, - and unary - are element-wise; * and @
are both the matrix product and ** is repeated multiplication
(A**-1 inverts). The element-wise product, quotient and power have no symbol
left, so they are the mul, div and pow methods and routines. Scalars,
reflected operands and the in-place forms are supported throughout, alongside
matmul, min, max, prod, sum, cumsum, cumprod, argmin, argmax,
sort, argsort and sort_inplace.
Comparison and logic: the comparison operators return a bool_ mask;
isclose / allclose compare approximately, the logical_* family combines
masks, and all / any reduce one to a verdict. Each has a scalar_* form
for a matrix against a single value.
Shape, layout and mutation: reshape, reshape_view, resize,
flatten, contiguous, reorder_layout, broadcast_to and astype. Writes
go through the mutation module — view_mut, rows_mut, cols_mut, fill,
assign, store — which is the library's only source of a mutable view.
Linear algebra: transpose, trace, lu (PA = LU), cholesky, qr,
det, solve, inv, matrix_power and lstsq. matmul dispatches over
four SIMD paths according to the contiguity of its operands.
Custom operations: fold and apply_along_axis express a reduction or a
per-row transform that the library does not name itself.
Interoperability and printing: from_numpy / to_numpy round-trip
through NumPy, and every type prints through one aligned grid that shows the
element type, the shape, and the strides when they are not the dense ones.
Large matrices elide rows and columns; long fractions are trimmed and marked.
Errors: linamo.errors re-exports the six kinds Linamo raises
(ConversionError, IndexError, KeyError, OverflowError, ValueError,
ZeroDivisionError) from decimo.errors, keeping call_location() pointing
at the Linamo line that raised.