istril — Determine whether a matrix is lower triangular in MATLAB and RunMat.

istril(A) returns true when every element above the main diagonal of matrix A is zero.

Syntax

tf = istril(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYesInput numeric, logical, complex, sparse, or gpuArray matrix.

Returns

NameTypeDescription
tfLogicalArrayTrue when the input matrix satisfies the requested structure predicate.

Errors

IdentifierWhenMessage
RunMat:istril:InvalidInputInput cannot be interpreted as a supported numeric, logical, sparse, complex, or gpuArray matrix.istril: invalid input
RunMat:istril:InternalRuntime fails while gathering GPU input or constructing an internal matrix view.istril: internal runtime failure

How istril works

  • Scalars are lower triangular.
  • Diagonal and all-zero matrices are lower triangular.
  • Rectangular matrices are supported.
  • Dense real, logical, complex, sparse, and gpuArray inputs are supported.
  • Complex entries count as nonzero when either real or imaginary part is nonzero.
  • NaN values count as nonzero when testing matrix structure.
  • Arrays with a non-singleton dimension beyond the second return false, matching MATLAB matrix-predicate behavior.

Does RunMat run istril on the GPU?

istril is registered as a structure-analysis fusion sink. GPU-resident real/logical inputs use provider bandwidth (upper == 0) instead of gathering the full matrix when the active provider supports it.

GPU memory and residency

The result is always a host logical scalar. For real/logical gpuArray inputs, RunMat keeps the matrix on the provider and uses the bandwidth hook to read back only lower/upper bandwidth metadata. Complex-interleaved GPU inputs and providers without bandwidth support fall back to the host path.

Examples

Checking a lower-triangular matrix

A = [1 0 0; 2 3 0; 4 5 6];
tf = istril(A)

Expected output:

tf = logical
   1

Detecting a value above the main diagonal

B = [1 7; 0 2];
tf = istril(B)

Expected output:

tf = logical
   0

Checking a rectangular matrix

C = [1 0; 2 3; 4 5];
tf = istril(C)

Expected output:

tf = logical
   1

Inspecting a GPU-resident matrix

G = gpuArray(tril(ones(3)));
tf = istril(G)

Expected output:

tf = logical
   1

Using istril with coding agents

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

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

FAQ

What entries does istril inspect?

Only entries above the main diagonal can make the predicate false.

Are diagonal matrices lower triangular?

Yes. Diagonal matrices have zeros above the main diagonal, so istril returns true.

How are sparse matrices handled?

RunMat scans stored sparse entries without densifying and returns false only when a stored nonzero appears above the main diagonal.

Factor

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

Solve

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

Open-source implementation

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

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.