RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • cond
    • det
    • inv
    • linsolve
    • norm
    • null
    • pinv
    • rank
    • rcond
    • rref
    • vecnorm

det — Compute determinants of square matrices in MATLAB and RunMat.

det(A) returns the determinant of real or complex square matrix A. Scalar and empty-matrix cases (det([]) = 1) follow MATLAB and RunMat conventions.

Syntax

d = det(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input matrix.

Returns

NameTypeDescription
dNumericScalarDeterminant of A.

Errors

IdentifierWhenMessage
RunMat:det:InvalidInputInput shape/type or numeric domain is unsupported for determinant evaluation.det: invalid input
RunMat:det:InternalRuntime fails while evaluating determinant or device fallback paths.det: internal runtime failure
RunMat:det:TooManyOutputsMore than one output is requested.det: too many output arguments

How det works

  • Inputs must be 2-D square matrices. RunMat rejects non-square or higher-rank inputs with the MATLAB error "det: input must be a square matrix."
  • Determinants are computed from an LU factorization with partial pivoting, ensuring numerical behavior that mirrors MATLAB. Singular matrices return 0 (within floating-point round-off).
  • MATLAB documents single and double matrices. Integer and logical matrices are separately gated RunMat-only extensions; integer values must be exactly representable as double rather than silently rounded.
  • Single input produces a single result. Complex input retains complex result storage and its single/double class.
  • The determinant of the empty matrix ([]) is 1.

Does RunMat run det on the GPU?

RunMat resolves the provider from the input handle rather than a global provider. Floating matrices use its lu hook when possible; typed integer, logical, complex, and unsupported-provider cases gather explicitly. Re-uploaded results must match the input owner/device and the computed shape, storage, and precision or they are freed and rejected.

GPU memory and residency

You usually do NOT need to call gpuArray yourself in RunMat. Floating storage uses the owning provider's lu hook when available. Explicit fallback paths gather through that owner and restore real or complex scalar results to the same device while preserving single/double precision.

Examples

Determinant Of A 2x2 Matrix

A = [4 -2; 1 3];
d = det(A)

Expected output:

d = 14

Checking Zero Determinant For Singular Matrix

B = [1 2; 2 4];
d = det(B)

Expected output:

d = 0

Determinant Of A Complex Matrix

C = [1+2i 0; 3i 4-1i];
d = det(C)

Expected output:

d = 6 + 7i

Determinant Equals Product Of Diagonal For Triangular Matrix

U = [3 2 1; 0 5 -1; 0 0 2];
d = det(U)

Expected output:

d = 30

Determinant Of An Empty Matrix

d = det([])

Expected output:

d = 1

Using det With gpuArray Data

G = gpuArray([2 0 0; 0 3 0; 1 0 4]);
d_gpu = det(G);     % stays on the GPU when a provider is active
d = gather(d_gpu)

Expected output:

d = 24

Using det with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how det changes the result.

Run a small det example, explain the result, then change one input and compare the output.

FAQ

Why does det require square matrices?⌄

The determinant is only defined for square matrices. RunMat mirrors MATLAB by rejecting non-square inputs with "det: input must be a square matrix."

What is det([])?⌄

The determinant of the empty matrix ([]) is 1, matching MATLAB's convention for the product of an empty diagonal.

Does det warn for nearly singular matrices?⌄

No. RunMat returns the floating-point result of the LU-based determinant. Very small magnitudes indicate near singularity, just as in MATLAB.

How does det handle complex matrices?⌄

Complex matrices are factorized in complex arithmetic. The result is complex; if the imaginary part happens to be zero, it is still reported through the complex number interface.

Will the result stay on the GPU?⌄

Yes, when a GPU provider is active RunMat re-uploads the scalar determinant so that subsequent GPU code continues to operate on device-resident data. Providers without LU support fall back to the CPU path and return a host scalar.

Can det overflow or underflow?⌄

Large determinants can overflow or underflow double precision just as in MATLAB. RunMat does not rescale the matrix; if you require scaling, consider log(det(A)) via lu or chol.

Do logical inputs work?⌄

Logical matrices are a named RunMat-only extension. Strict MATLAB compatibility mode rejects them before data access.

Is the determinant computed exactly?⌄

No. The LU factorization works in floating-point, so the result is subject to round-off. The behavior matches MATLAB's det.

Related Linalg functions

Solve

cond · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how det is executed, line by line, in Rust.

  • View the source for det in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How det works
  • Does RunMat run det on the GPU?
  • GPU memory and residency
  • Examples
  • Determinant Of A 2x2 Matrix
  • Checking Zero Determinant For Singular Matrix
  • Determinant Of A Complex Matrix
  • Determinant Equals Product Of Diagonal For Triangular Matrix
  • Determinant Of An Empty Matrix
  • Using det With gpuArray Data
  • Using det with coding agents
  • FAQ
  • Related Linalg functions
  • Solve
  • Structure
  • Factor
  • Ops
  • Open-source implementation
  • About RunMat