RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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
    • cross
    • ctranspose
    • dot
    • mldivide
    • mpower
    • mrdivide
    • mtimes
    • pagemtimes
    • pagetranspose
    • trace
    • transpose

ctranspose — Conjugate-transpose arrays in MATLAB and RunMat.

B = ctranspose(A) (or A') swaps the first two dimensions of A and conjugates complex values. Real-valued inputs therefore behave like simple transpose, with MATLAB/RunMat Hermitian semantics for complex data.

Syntax

B = ctranspose(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input scalar/array value.

Returns

NameTypeDescription
BAnyInput value with first two dimensions swapped and complex conjugated.

Errors

IdentifierWhenMessage
RunMat:ctranspose:InvalidArgumentCall does not provide exactly one input argument.ctranspose: invalid argument
RunMat:ctranspose:InvalidInputInput type is unsupported for conjugate transpose, the input has a nonsingleton dimension above two, or the input uses complex integer storage.ctranspose: unsupported input type
RunMat:ctranspose:InternalRuntime cannot materialize conjugate-transpose output.ctranspose: internal runtime failure

How ctranspose works

  • Works for scalars, vectors, and matrices. N-D arrays with a nonsingleton dimension above two are rejected; use permute for N-D reordering.
  • Real numeric, logical, and character data are not changed by conjugation.
  • Complex single and double values receive element-wise conjugation after the transpose ((a + bi)' = a - bi), and remain complex even when every imaginary component is zero. Complex integer storage is rejected.
  • Dense real integer input preserves all eight integer classes. Integer-valued sparse storage is available only through the ctranspose-integer-sparse RunMat extension.
  • Character arrays and cell arrays preserve their types; ctranspose simply rearranges entries.
  • String scalars are passed through unchanged; string arrays transpose like MATLAB.
  • Empty arrays and singleton dimensions follow MATLAB's column-major semantics.

Does RunMat run ctranspose on the GPU?

Provider support: If the backend exposes both transpose (or permute) and unary_conj, real and complex-interleaved tensors complete on the device without a gather.

Partial hooks: If the transpose succeeds but conjugation fails, RunMat falls back to the host path while logging a warning so users know their backend is incomplete.

No hooks: RunMat gathers the tensor, applies the conjugate transpose on the CPU, and re-uploads the result when possible so downstream kernels can keep running on the GPU. Complex fallback preserves interleaved GPU storage metadata when the result remains complex.

GPU memory and residency

No additional residency management is required. If the planner keeps real or complex data on the GPU, ctranspose honours that residency and either executes on the device (when hooks are present) or performs a storage-preserving gather/transpose/upload round-trip automatically.

Examples

Conjugate transpose of a complex matrix

Z = [1+2i 3-4i; 5+0i 6-7i];
H = ctranspose(Z)

Expected output:

H =
   1 - 2i   5 - 0i
   3 + 4i   6 + 7i

Conjugate transpose of a real matrix equals the plain transpose

A = [1 2 3; 4 5 6];
B = ctranspose(A)

Expected output:

B =
     1     4
     2     5
     3     6

Conjugate transpose turns row vectors into column vectors

row = [1-2i, 3+4i, 5];
col = ctranspose(row);
size(col)

Expected output:

ans = [3 1]

Conjugate transpose of a complex scalar

z = 2 + 3i;
result = ctranspose(z)

Expected output:

result = 2 - 3i

Conjugate transpose of text data preserves characters

C = ['r' 'u' 'n'; 'm' 'a' 't'];
CT = ctranspose(C)

Expected output:

CT =
    'rm'
    'ua'
    'nt'

Conjugate transpose of a gpuArray without leaving the device

G = gpuArray(rand(1024, 64) + 1i * rand(1024, 64));
GT = ctranspose(G)

Using ctranspose with coding agents

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

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

FAQ

How is ctranspose different from transpose?⌄

transpose (A.') swaps dimensions without conjugation; ctranspose (A') also conjugates complex values. For purely real data they are identical.

Does ctranspose change logical or character arrays?⌄

Only their layout changes. Values remain logical or character, and conjugation has no effect.

What about higher-dimensional arrays?⌄

Use permute for higher-dimensional arrays. ctranspose accepts vectors and matrices, including explicit trailing singleton dimensions, and rejects nonsingleton dimensions above two.

Does the result share storage with the input?⌄

No. ctranspose materialises a fresh array, although fusion may eliminate the copy in optimised pipelines.

How are complex tensors handled on the GPU today?⌄

Complex gpuArray values use interleaved real/imaginary storage. Providers with transpose/permute and unary_conj hooks keep the conjugate transpose resident; fallback gathers and re-uploads through the same complex storage metadata.

Will ctranspose fuse with neighbouring kernels?⌄

Conjugate transposes currently act as fusion boundaries so that shape changes are visible to downstream kernels.

Can I rely on ctranspose inside linear-algebra routines (e.g., Hermitian products)?⌄

Yes for the supported numeric, logical, character, string, cell, scalar-struct, sparse, and resident array forms described above. On those inputs it preserves the conjugate-transpose semantics required by idioms such as A' * A.

What error do I get for unsupported types?⌄

Supported scalar structs are unchanged by transpose. Unsupported value kinds raise ctranspose: unsupported input type ...; external objects can provide their own ctranspose method.

Related Linalg functions

Ops

cross · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

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

  • View the source for ctranspose in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How ctranspose works
  • Does RunMat run ctranspose on the GPU?
  • GPU memory and residency
  • Examples
  • Conjugate transpose of a complex matrix
  • Conjugate transpose of a real matrix equals the plain transpose
  • Conjugate transpose turns row vectors into column vectors
  • Conjugate transpose of a complex scalar
  • Conjugate transpose of text data preserves characters
  • Conjugate transpose of a gpuArray without leaving the device
  • Using ctranspose with coding agents
  • FAQ
  • Related Linalg functions
  • Ops
  • Structure
  • Factor
  • Solve
  • Open-source implementation
  • About RunMat