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
    • abs
    • angle
    • bsxfun
    • complex
    • conj
    • double
    • erf
    • erfcinv
    • exp
    • expm1
    • factorial
    • flintmax
    • gamma
    • gammaln
    • heaviside
    • hypot
    • idivide
    • imag
    • intmax
    • intmin
    • ldivide
    • log
    • log10
    • log1p
    • log2
    • minus
    • nextpow2
    • plus
    • pow2
    • power
    • rdivide
    • real
    • realmax
    • realmin
    • realsqrt
    • rescale
    • sign
    • single
    • sqrt
    • swapbytes
    • times
    • typecast
    • uint16
    • uint32
    • uint8

conj — Compute complex conjugates element-wise in MATLAB and RunMat.

conj(x) negates the imaginary component of each element in x, while real values remain unchanged. The operation is element-wise for scalars and arrays, matching MATLAB behavior.

Syntax

Y = conj(X)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Numeric, logical, char, or complex input.

Returns

NameTypeDescription
YNumericArrayComplex conjugate of X.

Errors

IdentifierWhenMessage
RunMat:conj:InvalidInputInput cannot be interpreted as numeric, logical, char, or complex data.conj: invalid input
RunMat:conj:InternalInternal tensor conversion/allocation/provider interaction failed.conj: internal error

How conj works

  • Complex scalars and arrays have their imaginary components multiplied by -1 and remain complex values, including when the imaginary component is zero.
  • For typed complex integers, RunMat conservatively applies saturating imaginary-component negation; public evidence does not directly settle signed-minimum or unsigned-imaginary endpoints, so those cases remain evidence-open.
  • Purely real numeric inputs (double, single, integer) are returned unchanged.
  • Logical scalars and arrays are returned unchanged and retain logical class.
  • Character arrays are not part of the documented MATLAB input classes. RunMat mode accepts them as an explicit compatibility extension and returns double Unicode code points.
  • String arrays are not supported and raise an error.

Does RunMat run conj on the GPU?

Hook available: Real tensors stay GPU-resident and are processed by the owning provider (both the in-process provider used for tests and the WGPU provider expose this path).

Fusion and auto-offload: Because conj is tagged as an elementwise unary builtin, the fusion planner treats it as a pass-through for real-valued kernels. Native auto-offload therefore keeps fused expressions resident on the GPU whenever the surrounding ops are profitable.

Hook missing: RunMat transfers floating or paired complex-integer data exactly through the input handle's owner, applies the host semantics, and restores class-preserving output to that same provider. Providers may implement native floating complex-interleaved conjugation through the unary hook.

GPU memory and residency

You usually do not need to call gpuArray explicitly. RunMat's fusion planner and Accelerate layer manage residency and offload decisions automatically, keeping tensors on the GPU whenever device execution is beneficial. Explicit gpuArray and gather remain available for MATLAB compatibility or fine-grained residency control.

Examples

Complex conjugate of a scalar value in MATLAB

z = 3 + 4i;
result = conj(z)

Expected output:

result = 3 - 4i

Apply conj to every element of a complex matrix

Z = [1+2i, 4-3i; -5+0i, 7+8i];
C = conj(Z)

Expected output:

C =
   1 - 2i   4 + 3i
  -5 + 0i   7 - 8i

Ensure conj leaves real inputs unchanged

data = [-2.5 0 9.75];
unchanged = conj(data)

Expected output:

unchanged = [-2.5 0 9.75]

Use conj on a logical mask

mask = logical([0 1 0; 1 1 0]);
numeric = conj(mask)

Expected output:

numeric retains logical class and the same true/false values.

Conjugating character codes

chars = 'RunMat';
codes = conj(chars)
outputClass = class(codes)

Expected output:

codes = [82 117 110 77 97 116];
outputClass = 'double'

Compute conjugate on GPU-resident arrays

G = rand(4096, 256, "gpuArray");
H = conj(G)

Using conj with coding agents

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

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

FAQ

Does conj change purely real inputs?⌄

No. Real numeric and logical values retain their class and values. Character input is a RunMat-mode extension that returns double code points.

How does conj handle complex zeros?⌄

The value remains complex and its imaginary zero changes sign under negation.

Can I call conj on string arrays?⌄

No. MATLAB-compatible mode accepts numeric and logical inputs. RunMat mode additionally accepts character input as an explicit extension.

Does conj allocate a new array?⌄

Not necessarily. Real host values and resident integer or logical handles use an exact identity path. Floating and complex providers may allocate an output handle, while fusion can eliminate intermediate allocation.

What happens on the GPU without unary_conj?⌄

RunMat gathers floating data to host memory, applies the CPU semantics, and re-uploads the result through the handle's owning provider so residency is preserved.

Is GPU execution numerically identical to CPU?⌄

Yes. For real tensors the result is an exact copy; the conjugate matches CPU results bit-for-bit for supported precisions.

Does conj participate in fusion?⌄

Yes for supported floating real expressions. The fusion planner treats real conjugation as identity; complex and typed-integer cases use their dedicated runtime paths.

Related Math functions

Elementwise

abs · angle · bsxfun · complex · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · typecast · uint16 · uint32 · uint8

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Structure

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

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Rounding

ceil · fix · floor · mod · rem · round

Factor

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

Solve

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

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Ops

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

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

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

  • View the source for conj 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 conj works
  • Does RunMat run conj on the GPU?
  • GPU memory and residency
  • Examples
  • Complex conjugate of a scalar value in MATLAB
  • Apply conj to every element of a complex matrix
  • Ensure conj leaves real inputs unchanged
  • Use conj on a logical mask
  • Conjugating character codes
  • Compute conjugate on GPU-resident arrays
  • Using conj with coding agents
  • FAQ
  • Related Math functions
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Rounding
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat