RunMat
GitHub

issymmetric — Test whether a matrix is symmetric or skew-symmetric, optionally within a tolerance.

issymmetric(A) returns logical true when a numeric or logical matrix A is symmetric about its main diagonal (A == A.') and false otherwise.

How issymmetric works in RunMat

  • 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.

How issymmetric runs 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

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).

These functions work well alongside issymmetric. Each page has runnable examples you can try in the browser.

bandwidth, chol, eig, gpuArray, gather, ishermitian, symrcm

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat — free, no sign-up

Start running MATLAB code immediately in your browser.