Skip to content

Matrices and linear algebra

Create matrices in Zlv with [1, 2; 3, 4] or the Matrix Builder (Ctrl+M), then compute determinants, inverses, solve linear systems and inspect results.

Zlv works with matrices and vectors as easily as with numbers. Type them inline, or build them visually with the Matrix Builder.

Writing a matrix

Put the values in square brackets. Separate values in a row with commas and rows with semicolons.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

[1, 2, 3] is a row vector and [4; 5; 6] is a column vector. The nested form [[1, 2], [3, 4]] is accepted too.

Arithmetic

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

A * B is matrix multiplication, and A ^ 2 multiplies A by itself.

Matrix functions

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

FunctionResult
det(A)Determinant
inv(A)Inverse
transpose(A)Rows and columns swapped
trace(A), rank(A)Trace and rank
eigenvalues(A)Eigenvalues
rref(A)Reduced row echelon form
solve(A, b)Solution x of A * x = b
norm(v), dot(u, v)Length and dot product
identity(n), zeros(r, c), ones(r, c)Special matrices
reshape(M, r, c), flatten(M)Change shape
rows(M), cols(M), dim(M)Size
row(M, i), col(M, j)Extract a row or column

Solving a linear system

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Building, reshaping and indexing

Indexes start at 1: A[1, 2] is row 1, column 2.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

The desktop engine adds cross, diag, vector indexing and random matrices:

Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Matrix Builder (desktop)

Press Ctrl+M (or search for Matrix Studio with Ctrl+K) to open the Matrix Builder.

  1. Enter a Name, such as A.
  2. Set Rows and Cols, from 1 to 8 each.
  3. Pick a preset to fill the grid: Custom, Zeros, Ones, Identity, Diagonal, Sequential, Random Int (1..9) or Random Float (0..1). Edit any cell by hand.
  4. Click Insert Matrix to add it at the cursor, or New Matrix Page to open it in a new tab.

Copy Code copies the Zlv matrix literal and Copy LaTeX copies it for use in documents.

Matrix Inspector (desktop)

Click a matrix result to open the 2D Matrix Inspector, which shows the matrix as a grid with its shape. From there you can copy it as Zlv code, CSV, LaTeX or a NumPy array.

All guides