issymmetric — Test matrix symmetry in MATLAB and RunMat.

issymmetric(A) returns true when matrix A is symmetric about its main diagonal. Optional skew-symmetric mode and tolerance behavior follow MATLAB semantics.

Syntax

tf = issymmetric(A)
tf = issymmetric(A, option)
tf = issymmetric(A, flag, tol)
tf = issymmetric(A, tol, flag)

Inputs

NameTypeRequiredDefaultDescription
AAnyYesInput matrix.
optionAnyNoSymmetry flag or tolerance scalar.
flagAnyNoSymmetry flag (for example "skew" or "symmetric").
tolNumericScalarNoTolerance for element-wise symmetry checks.

Returns

NameTypeDescription
tfLogicalArrayTrue when the matrix satisfies the selected symmetry predicate.

Errors

IdentifierWhenMessage
RunMat:issymmetric:InvalidArgumentFlag/tolerance arguments are malformed, duplicated, or unsupported.issymmetric: invalid argument
RunMat:issymmetric:InvalidInputInput shape/type cannot be interpreted as a numeric or logical 2-D matrix.issymmetric: invalid input
RunMat:issymmetric:InternalRuntime fails while creating internal tensors or coercing values.issymmetric: internal runtime failure

How issymmetric works

  • Works with scalars, vectors (treated as matrices), and higher-rank arrays whose trailing dimensions are singleton (MATLAB-compatible matrix semantics). An error is raised when the input has more than two non-singleton dimensions.
  • Non-square matrices immediately return false.
  • Logical inputs are promoted to double precision (true → 1.0, false → 0.0) before testing.
  • Complex inputs are compared without conjugation; use ishermitian for conjugate symmetry.
  • Floating-point tolerance can be supplied to account for numerical noise.
  • Pass 'skew' to test skew-symmetry (A == -A.'). Diagonal entries must be zero (within the tolerance) when skew mode is active.

Does RunMat run issymmetric on the GPU?

RunMat keeps GPU tensors resident whenever feasible. When the active acceleration provider exposes a symmetry predicate hook (issymmetric), the test runs entirely on the device and returns a host logical scalar. Providers without that hook gracefully fall back to downloading the matrix, so results remain correct even without GPU specialisation.

GPU memory and residency

Manual gpuArray / gather calls are optional. When a provider implements the symmetry hook, RunMat executes the predicate in-place on the GPU and only transfers the scalar result. Otherwise the runtime gathers the tensor transparently and reuses the CPU path, preserving correctness with a minor residency cost.

Examples

Checking whether a matrix is symmetric

A = [2 1 1; 1 3 4; 1 4 5];
tf = issymmetric(A)

Expected output:

tf = logical
   1

Allowing numerical noise with a tolerance

A = [1 1+1e-12; 1-1e-12 1];
tf = issymmetric(A, 1e-9)

Expected output:

tf = logical
   1

Detecting a skew-symmetric matrix

B = [0 -2 4; 2 0 -3; -4 3 0];
tf = issymmetric(B, 'skew')

Expected output:

tf = logical
   1

Handling non-square matrices

C = [1 2 3; 4 5 6];
tf = issymmetric(C)

Expected output:

tf = logical
   0

Working with complex-valued matrices

Z = [1+2i 3-4i; 3-4i 5+6i];
tf = issymmetric(Z)

Expected output:

tf = logical
   1

Inspecting a GPU-resident matrix

G = gpuArray([0 5; 5 9]);
tf = issymmetric(G)

Expected output:

tf = logical
   1

Using issymmetric with coding agents

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

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

FAQ

Does issymmetric accept tolerance arguments?

Yes. Pass a non-negative scalar tolerance as the second or third argument. The comparison uses an absolute tolerance on the element-wise difference (or sum for skew tests).

What strings are accepted for the skew flag?

Use 'skew' to test skew-symmetry and 'nonskew' (or omit the flag) for the default symmetry test.

How are diagonal elements handled in skew mode?

Diagonal elements must be zero (within the tolerance) because a skew-symmetric matrix satisfies A(i,i) = -A(i,i).

Are NaN values considered symmetric?

No. Any NaN encountered off or on the diagonal causes the test to return false, matching MATLAB behaviour.

Do logical matrices work?

Yes. Logical inputs are promoted to double precision and checked using the same rules as numeric matrices.

Does issymmetric conjugate complex inputs?

No. The builtin compares complex entries without conjugation. Use ishermitian if you need conjugate symmetry.

What happens with higher-dimensional arrays?

issymmetric raises an error when the input has more than two non-singleton dimensions. Reshape the data to a 2-D matrix before calling it.

Can I combine the skew flag and tolerance?

Yes. You can call issymmetric(A, 'skew', tol) or issymmetric(A, tol, 'skew'). The order of the optional arguments does not matter.

Is an empty matrix symmetric?

Yes. Empty square matrices (0x0) return logical true, while non-square empty matrices return false.

Does the result depend on GPU availability?

No. You receive the same logical answer regardless of whether a GPU provider is registered. Only the execution strategy changes (device-side predicate vs. host fallback).

Factor

chol · eig · lu · qr · svd

Solve

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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how issymmetric 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.