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

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

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.

LicensePrivacy
/
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

double — Convert values to double precision in MATLAB and RunMat.

double(X) converts supported scalars and arrays to MATLAB’s default double-precision representation (float64) while preserving shape and layout. Numeric, logical, character, and GPU-resident values follow MATLAB/RunMat conversion semantics.

Syntax

Y = double(X)
Y = double(X, "like", prototype)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Input scalar/array value to convert.
likeStringScalarYes—Literal string "like".
prototypeLikePrototypeYes—Output class/device prototype.

Returns

NameTypeDescription
YNumericArrayDouble-precision output value.

Errors

IdentifierWhenMessage
RunMat:double:InvalidArgumentOptional arguments are malformed or unsupported.double: invalid argument
RunMat:double:InvalidInputInput value or prototype cannot be converted to double.double: invalid input
RunMat:double:GpuUnsupportedGPU output via "like" is requested but no compatible float64 provider is active.double: gpu output not supported
RunMat:double:InternalInternal conversion, gather, or provider upload failed.double: internal error

How double works

  • Numeric inputs that are already double precision are returned unchanged; single-precision and all eight integer classes are converted without altering shapes. Wide int64 and uint64 values follow ordinary IEEE binary64 rounding.
  • Logical inputs become dense double arrays containing 0 and 1, matching MATLAB’s promotion rules used by arithmetic on logical masks.
  • Sparse inputs preserve their sparse structure while stored values are converted to double.
  • Character arrays are converted to their Unicode code points and returned as doubles ('A' becomes 65).
  • Complex scalars and arrays remain complex, but both components are stored as double precision.
  • Empty arrays stay empty, orientation is preserved, and singleton dimensions are untouched.
  • String scalars and arrays convert each element as one numeric value; elements that do not represent one number become NaN.
  • Complex inputs preserve complexity even when the converted imaginary component is zero, matching the compatibility target's rule.
  • double(X, "like", prototype) is a separately declared RunMat-only compatibility extension and is rejected when RunMat extensions are disabled.

Does RunMat run double on the GPU?

RunMat resolves GPU conversion only through an owner whose reported device matches the handle; a global-provider fallback for an unknown device is not accepted as ownership. Float64-capable owners may use unary_double; malformed native results trigger the gather fallback, while malformed RunMat-only 'like' uploads return an error. Outputs that alias an input or prototype are rejected and never freed as provider-owned results. Other rejected allocations are freed only through a proven actual owner. The 'like' upload path also validates prototype device, result shape, real/complex storage, float64 precision, and absence of integer/logical metadata. Integer handles gather exact native storage before conversion when a native float cast is unavailable. Float32-only providers cannot represent the documented double result, so RunMat returns a host double tensor as an explicit backend limitation. The input handle remains owned by the caller.

GPU memory and residency

RunMat keeps tensors on the GPU whenever the active provider supports double precision. You only need explicit gpuArray / gather calls when interfacing with legacy code or when you must force residency. On float32-only providers, double returns host data, matching MATLAB systems where the GPU lacks native double support.

Examples

Convert integers to double precision

ints = int32([1 2 3]);
doubles = double(ints)

Expected output:

doubles = [1 2 3]

Promote logical masks for arithmetic

mask = logical([0 1 0 1]);
weights = double(mask)

Expected output:

weights = [0 1 0 1]

Convert character arrays to Unicode code points

codes = double('RunMat')

Expected output:

codes = [82 117 110 77 97 116]

Preserve complex numbers while promoting precision

z = [1+2i, 3-4i];
result = double(z)

Expected output:

result = [1+2i  3-4i]

Convert single-precision gpuArray data to double

G = single(gpuArray(1:4));
H = double(G);
gather(H)

Expected output:

ans = [1 2 3 4]

Preserve sparse structure while converting stored values

S = sparse([1 3], [1 2], [4 -1], 3, 2);
A = double(S);
[issparse(A), nnz(A)]

Expected output:

ans = [1 2]

Handle double precision with 'like' prototypes

proto = gpuArray.zeros(1, 1, 'double');
out = double([pi 0], 'like', proto)

Expected output:

out =
  1×2 gpuArray  double
    3.1416         0

Promote matrices without changing shape

A = single([1.5 2.25; 3.75 4.5]);
B = double(A)

Expected output:

B = [1.5 2.25; 3.75 4.5]

Using double with coding agents

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

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

FAQ

Does double change values that are already double precision?⌄

No. Existing double data is passed through unchanged; the builtin only promotes other types.

How are logical inputs handled?⌄

Logical masks become numeric 0/1 doubles, making it easy to apply arithmetic or linear algebra without extra casts.

What happens to NaN or Inf values?⌄

IEEE special values survive promotion exactly. NaNs stay NaN, and ±Inf remain ±Inf.

Can I convert strings with double?⌄

Yes. Each string element is parsed as one numeric value; text that does not represent one numeric value produces NaN. Character arrays instead convert to Unicode code values.

What happens to sparse inputs?⌄

Sparse structure is preserved and its stored values are converted to double.

Will double keep results on the GPU?⌄

Yes when the provider supports float64. Otherwise the runtime documents the gather fallback and returns a host tensor.

Does double allocate new memory?⌄

Yes. Results are materialised in a new tensor or, for scalars, a new numeric value. Fusion may fold the cast with neighbouring elementwise operations.

Can I request GPU residency with 'like'?⌄

In RunMat extension mode, pass 'like', prototype to mirror host or GPU residency when the selected provider supports true float64 storage. This overload is not part of the current public MATLAB double syntax and is rejected when RunMat extensions are disabled.

How does double interact with complex inputs?⌄

Complex values keep both components intact; the builtin simply ensures they are stored as double precision.

Related Math functions

Elementwise

abs · angle · bsxfun · complex · conj · 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 double is executed, line by line, in Rust.

  • View the source for double 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 double works
  • Does RunMat run double on the GPU?
  • GPU memory and residency
  • Examples
  • Convert integers to double precision
  • Promote logical masks for arithmetic
  • Convert character arrays to Unicode code points
  • Preserve complex numbers while promoting precision
  • Convert single-precision gpuArray data to double
  • Preserve sparse structure while converting stored values
  • Handle double precision with 'like' prototypes
  • Promote matrices without changing shape
  • Using double 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