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.2, Nov 26, 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

cond — Compute matrix condition numbers in MATLAB and RunMat.

k = cond(A) returns the condition number of matrix A, measuring sensitivity of linear-system solutions to perturbations. By default, it computes the 2-norm condition number from singular-value extrema, following MATLAB semantics.

Syntax

c = cond(A)
c = cond(A, p)

Inputs

A
Type
Any
Required
Yes
Description
Input matrix.
p
Type
Any
Required
No
Description
Norm selector (1, 2, inf, or "fro").
NameTypeRequiredDefaultDescription
AAnyYes—Input matrix.
pAnyNo—Norm selector (1, 2, inf, or "fro").

Returns

c
Type
NumericScalar
Description
Condition number estimate of A.
NameTypeDescription
cNumericScalarCondition number estimate of A.

Errors

RunMat:cond:InvalidArgument
When
Norm selector argument is malformed or unsupported.
Message
cond: invalid argument
RunMat:cond:InvalidInput
When
Input shape/type cannot be processed for condition-number evaluation.
Message
cond: invalid input
RunMat:cond:Internal
When
Runtime fails while computing cond or executing fallback/upload paths.
Message
cond: internal runtime failure
IdentifierWhenMessage
RunMat:cond:InvalidArgumentNorm selector argument is malformed or unsupported.cond: invalid argument
RunMat:cond:InvalidInputInput shape/type cannot be processed for condition-number evaluation.cond: invalid input
RunMat:cond:InternalRuntime fails while computing cond or executing fallback/upload paths.cond: internal runtime failure

Behavior

cond(A) and cond(A, 2) use the singular values of A, so rectangular matrices are supported.

cond(A, 1), cond(A, Inf), and cond(A, 'fro') require a square, invertible matrix and use the definition norm(A, p) * norm(inv(A), p) with MATLAB's norm semantics.

Scalars behave like 1x1 matrices. Non-zero scalars have condition number 1, while cond(0) = Inf.

Empty matrices return 0, matching MATLAB's convention.

Singular or rank-deficient matrices return Inf.

Any NaN or infinite matrix element returns NaN, matching the current MATLAB nonfinite-input convention.

Single-precision host input returns a native single scalar; double input returns double. Resident output retains the owning provider's selected precision, including integer gather-fallback results re-uploaded through that provider.

Complex inputs are handled in full complex arithmetic.

The documented matrix domain is single or double. Typed-integer and logical matrices are independent RunMat-only extensions; integer matrices must be exactly representable as binary64 before crossing the floating linear-algebra boundary.

Typed-integer norm selectors are a separate RunMat-only structural extension. They are decoded exactly and accept only 1 or 2 without entering matrix arithmetic.

Acceleration and residency

RunMat uses the input handle's owning provider. When its cond hook is unavailable, RunMat gathers to host and re-uploads the scalar through that same provider; upload failures are reported rather than silently changing residency.

When the input already lives on a GPU, RunMat first looks for an acceleration provider that exposes the custom cond hook registered below. Current providers gather the matrix to host memory, reuse the shared CPU implementation, and then re-upload the scalar so downstream GPU computations preserve residency. This mirrors MATLAB semantics while keeping the user-facing API uniform.

`matlab:runnable

G = gpuArray([]); % Empty 0x0 matrix on the GPU

k = cond(G); % Returns 0 and keeps residency when possible

result = gather(k);

`

Expected output:

`matlab

result = 0

`

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

Condition number of the identity matrix

A = eye(3);
k = cond(A)

Expected output:

k = 1

Diagnosing an ill-conditioned diagonal matrix

D = diag([1, 1e-8]);
k = cond(D)

Expected output:

k = 1.0e+8

Condition number of a rectangular matrix (2-norm)

A = [1 0; 0 1; 1 1];
k = cond(A, 2)

Expected output:

k = 1.7321

Using a different norm specification

A = [4 -1; 2 3];
k1 = cond(A, 1)
kInf = cond(A, Inf)

Expected output:

k1   = 2.1429
kInf = 2.1429

Complex-valued matrices

A = [1+2i 0; 3i 4-1i];
k = cond(A)

Expected output:

k = 3.0327

Empty inputs and GPU residency

G = gpuArray([]);      % Empty 0x0 matrix on the GPU
k = cond(G);           % Returns 0 and keeps residency when possible
result = gather(k)

Expected output:

result = 0

Using cond with coding agents

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

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

FAQ

What does a large condition number mean?⌄

Large condition numbers (>> 1) indicate that small perturbations in the input can produce large changes in the solution of a linear system involving A. Values close to 1 indicate a well- conditioned matrix.

Why does cond return Inf for singular matrices?⌄

Singular matrices have at least one zero singular value (or an undefined inverse), so the condition number is mathematically infinite. RunMat mirrors MATLAB and returns Inf in these cases.

Does cond support rectangular matrices?⌄

Yes for the default 2-norm: cond(A) uses singular values and accepts any two-dimensional matrix. Norms 1, Inf, and 'fro' require a square, invertible matrix because they are defined using the matrix inverse.

How does cond handle empty matrices?⌄

All norm choices return 0 for empty matrices (0x0), matching MATLAB's behaviour.

Will calling cond move my data off the GPU?⌄

Only when the owning provider lacks a dedicated implementation. RunMat then gathers, computes on the host, and uploads the scalar through that same provider; an upload failure is reported rather than silently changing residency.

Related Linalg functions

Solve

det · 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 cond is executed, line by line, in Rust.

  • View the source for cond 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
  • Condition number of the identity matrix
  • Diagnosing an ill-conditioned diagonal matrix
  • Condition number of a rectangular matrix (2-norm)
  • Using a different norm specification
  • Complex-valued matrices
  • Empty inputs and GPU residency
  • Using cond with coding agents
  • FAQ
  • Related Linalg functions
  • Solve
  • Structure
  • Factor
  • Ops
  • Source you can read
  • About RunMat