rcond — Estimate reciprocal condition numbers in MATLAB and RunMat.
rc = rcond(A) estimates the reciprocal 1-norm condition number of square matrix A, preserving the Single class for Single input.
Syntax
c = rcond(A)Inputs
A- Type
Any- Required
- Yes
- Description
- Input square matrix.
Returns
c- Type
NumericScalar- Description
- Reciprocal condition number estimate.
Errors
RunMat:rcond:InvalidInput- When
- Input shape/type is unsupported for reciprocal condition estimation.
- Message
rcond: invalid input
RunMat:rcond:Internal- When
- Runtime fails while computing rcond or executing fallback/upload paths.
- Message
rcond: internal runtime failure
Behavior
Inputs must be square matrices (scalars count as 1 × 1). Non-square inputs trigger the error "rcond: input must be a square matrix."
For the empty matrix (0 × 0) the reciprocal condition number is Inf.
rcond(0) returns 0. Non-zero scalars return 1.
Public MATLAB matrix classes are single and double. RunMat mode separately admits logical matrices and all eight real integer classes through named extensions; integer values cross only after exact binary64 representability checks.
Complex matrices use the same 1-norm estimator with adjoint solves; host Single input retains Single output class.
Host execution estimates the reciprocal 1-norm condition from pivoted LU solves without forming an inverse matrix.
Resident integer input bypasses floating provider condition-estimation kernels, gathers through its exact owner, and restores the double result to that owner when supported.
Acceleration and residency
When a provider exposes the rcond hook, the shipping backends gather to the host, use the shared 1-norm estimator, and restore the scalar to the source class when possible.
When that hook is unavailable, the Runtime gathers through the exact owner and runs the same 1-norm estimator; a linsolve 2-norm condition hint is not substituted.
Explicit device placement requires a class-preserving resident result or a typed capability error; no output is silently relabelled.
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
Reciprocal condition of the identity matrix
A = eye(3);
rc = rcond(A)Expected output:
rc = 1Detecting a nearly singular matrix
A = diag([1, 1e-8]);
rc = rcond(A)Expected output:
rc = 1e-8Reciprocal condition of a singular matrix
A = [1 2; 2 4];
rc = rcond(A)Expected output:
rc = 0Reciprocal condition for a complex matrix
A = [1+2i 0; 3i 2-1i];
rc = rcond(A)Expected output:
rc ≈ 0.1824Handling the empty matrix
rc = rcond([])Expected output:
rc = InfEstimating conditioning on GPU data
G = gpuArray([2 0; 0 0.5]);
rc_gpu = rcond(G);
rc = gather(rc_gpu)Expected output:
rc = 0.25Using rcond with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how rcond changes the result.
Run a small rcond example, explain the result, then change one input and compare the output.
FAQ
What range of values should I expect from rcond?⌄
rcond returns a value in [0, 1]. Values near 1 indicate a well-conditioned matrix. Values near 0 indicate singular or ill-conditioned matrices.
Why does rcond return Inf for the empty matrix?⌄
The empty matrix is perfectly conditioned by convention, so the reciprocal condition number is Inf (1 / 0).
Does rcond warn me about singular systems automatically?⌄
rcond itself does not issue warnings. Use the value to decide whether the matrix is singular to working precision, similar to MATLAB workflows (if rcond(A) < eps, ...).
How is the reciprocal condition estimated?⌄
RunMat uses a pivoted LU factorization and a bounded inverse 1-norm estimate, without forming the inverse matrix. This is separate from the SVD tolerance used by pinv and rank.
Will calling rcond move my data off the GPU?⌄
The shipping providers gather to the shared host estimator and restore a class-preserving scalar. A future provider may implement the same 1-norm contract directly.
Related Linalg functions
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 rcond is executed, line by line, in Rust.
- View the source for rcond 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.