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

typecast — Reinterpret numeric bytes as another class without converting values.

Y = typecast(X, newtype) preserves the native byte sequence of a full numeric or logical scalar or vector and decodes it as newtype. Y = typecast(X, "like", prototype) selects the host output class and complexity from a prototype.

Syntax

Y = typecast(X, newtype)
Y = typecast(X, "like", prototype)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYes—Full numeric or logical scalar or vector.
newtypeStringScalarYes—Numeric or logical output class.
likeStringScalarYes—Literal string "like".
prototypeLikePrototypeYes—Host output class and complexity prototype.

Returns

NameTypeDescription
YNumericArrayReinterpreted scalar or vector.

Errors

IdentifierWhenMessage
RunMat:typecast:InvalidArgumentThe requested class, prototype, or argument list is invalid.typecast: invalid argument
RunMat:typecast:InvalidInputThe input is sparse, is not a scalar or vector, or has an incompatible byte count.typecast: invalid input
RunMat:typecast:GpuUnsupportedA GPU call uses complex or logical input or the like syntax.typecast: unsupported gpuArray form
RunMat:typecast:InternalExact gather, reconstruction, or resident restoration fails.typecast: internal error

How typecast works

  • The input must be a full scalar or vector. Sparse arrays and nonscalar matrices are rejected.
  • The input byte count must be divisible by the requested output element width.
  • Row inputs produce rows and column inputs produce columns; changing element width changes the element count without changing the byte sequence.
  • Double, single, logical, and all eight integer classes use their authoritative native storage and the platform's native byte order.
  • The like form can produce real or complex host output and groups adjacent decoded values into real and imaginary components for a complex prototype.
  • Character input and output are not currently available because RunMat's character value representation cannot preserve every raw UTF-16 code unit.
  • Real numeric gpuArray input preserves exact bytes, output class, shape orientation, and the owning provider. Unsupported GPU forms fail terminally rather than gathering through the general dispatcher.

Examples

Inspect the native bytes of unsigned integers

bytes = typecast(uint32([1 256]), "uint8")

Round-trip wide integer bit patterns exactly

values = uint64([9007199254740993 intmax("uint64")]);
copy = typecast(typecast(values, "uint8"), "uint64")

Select paired complex integer output with a prototype

z = typecast(int16([-1 2 -3 4]), "like", complex(int16(0)))

Using typecast with coding agents

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

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

Related Math functions

Elementwise

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

  • View the source for typecast 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 typecast works
  • Examples
  • Inspect the native bytes of unsigned integers
  • Round-trip wide integer bit patterns exactly
  • Select paired complex integer output with a prototype
  • Using typecast with coding agents
  • Related Math functions
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Signal
  • Rounding
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat