RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
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

A
Type
Any
Required
Yes
Description
Input matrix.
NameTypeRequiredDefaultDescription
AAnyYes—Input matrix.

Returns

d
Type
NumericScalar
Description
Determinant of A.
NameTypeDescription
dNumericScalarDeterminant of A.

Errors

RunMat:det:InvalidInput
When
Input shape/type or numeric domain is unsupported for determinant evaluation.
Message
det: invalid input
RunMat:det:Internal
When
Runtime fails while evaluating determinant or device fallback paths.
Message
det: internal runtime failure
RunMat:det:TooManyOutputs
When
More than one output is requested.
Message
det: too many output arguments
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

Behavior

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.

Acceleration and residency

Uses owner-resolved provider LU for floating storage. Typed integer, logical, and complex storage use an explicit gathered fallback; restoration requires the owner to physically support the computed precision, and results are validated against input owner/device and computed shape/storage/precision.

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.

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.

Implementation and validation

Original GPU declarations: precisions f32, f64; elementwise false; reduction false; broadcasting none.

Original fusion declarations: elementwise false; reduction false; max inputs 1; constants inline.

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 · decomposition.ctranspose · decomposition.mldivide · decomposition.mrdivide · decomposition.mtimes · decomposition.rdivide · decomposition.subsref · decomposition.times · decomposition.uminus · decomposition.uplus · eig · eigs · gmres · ichol · ilu · lu · ordeig · ordqz · ordschur · pcg · qr · qz · rsf2csf · schur · svd

Ops

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

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Behavior
  • Acceleration and residency
  • Implementation and validation
  • 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
  • Source you can read
  • About RunMat