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

power — Compute element-wise exponentiation in MATLAB and RunMat.

power(A, B) (or A .^ B) raises each element of A to the corresponding element of B. Implicit expansion, complex results, and domain behavior follow MATLAB semantics.

Syntax

C = power(A, B)
C = power(A, B, "like", prototype)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Base operand.
BAnyYes—Exponent operand.
likeStringScalarYes—Literal string "like".
prototypeLikePrototypeYes—Output class/device prototype.

Returns

NameTypeDescription
CNumericArrayElementwise power result.

Errors

IdentifierWhenMessage
RunMat:power:InvalidArgumentOptional arguments are malformed or unsupported.power: invalid argument
RunMat:power:InvalidInputOperands or prototypes cannot be converted into supported numeric/logical/complex forms.power: invalid input
RunMat:power:SizeMismatchOperands are not broadcast-compatible.power: array sizes are not compatible for broadcasting
RunMat:power:InternalProvider interaction, gather/upload, or internal tensor construction failed.power: internal error

How power works

  • Supports scalars, vectors, matrices, and N-D tensors with the same shape or compatible singleton dimensions. Size mismatches raise the standard MATLAB error.
  • When either operand is a scalar symbolic expression, power and scalar ^ construct a symbolic power expression that can participate in symbolic functions such as limit.
  • Logical and character inputs are promoted to double precision before powering ('A'.^2 uses the Unicode code points of the characters).
  • Complex bases and/or exponents follow the analytic identity z.^w = exp(w * log(z)), so negative bases with fractional exponents return complex results instead of NaN.
  • Empty tensors propagate emptiness; the result uses the broadcasted size.
  • Integer bases preserve their class, require nonnegative integer-valued exponents, and use saturating exponentiation; scalar-double compatibility follows the exact 64-bit rule.
  • In RunMat compatibility mode, the RunMat-only optional 'like', prototype arguments mirror the prototype's numeric flavour and residency. MATLAB-compatible mode rejects this extension before dispatch.

Does RunMat run power on the GPU?

When both operands are gpuArrays with identical shapes, RunMat calls the provider's elem_pow hook. The WGPU backend uses a fused WGSL kernel, and the in-process provider executes on host data without leaving the GPU abstraction.

If only one operand lives on the GPU and the other is a scalar, RunMat materialises a device buffer for the scalar and still uses elem_pow.

Implicit expansion, complex operands, and providers that lack elem_pow automatically fall back to the host implementation. Results respect 'like' residency hints, re-uploading to the GPU when requested.

GPU memory and residency

Most workflows do not require manual gpuArray calls. RunMat's auto-offload and fusion planner keep chains of element-wise operations on the GPU whenever the provider can satisfy them. When an operation needs a fallback (implicit expansion, complex inputs, or unsupported kernels), RunMat transparently gathers to the host, computes the MATLAB-accurate result, and honours any 'like' residency hints you supplied.

Examples

Raise a scalar to a power

y = power(2, 5)

Expected output:

y = 32

Compute element-wise powers of a matrix

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

Expected output:

B =
     1     4     9
    16    25    36

Broadcast exponents across rows

base = (1:3)';
exponent = [1 2 3];
result = power(base, exponent)

Expected output:

result =
     1     1     1
     2     4     8
     3     9    27

Generate complex powers from negative bases

values = power([-2 -1 0 1 2], 0.5)

Expected output:

values = [0.0000 + 1.4142i, 0.0000 + 1.0000i, 0, 1, 1.4142]

Keep GPU results with a 'like' prototype

proto = gpuArray.zeros(1, 1, 'single');
x = [1 2 3];
y = [2 3 4];
devicePowers = power(x, y, 'like', proto);
result = gather(devicePowers)

Expected output:

devicePowers =
  1x3 gpuArray  single
     1     8    81
result =
     1     8    81

Convert character codes before powering

codes = power('ABC', 2)

Expected output:

codes = [4225 4356 4489]

Using power with coding agents

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

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

FAQ

Does power support MATLAB implicit expansion?⌄

Yes. Singleton dimensions expand automatically, and size mismatches raise a dimension error with the usual MATLAB wording.

What numeric type does power return?⌄

Ordinary real inputs produce double, and results promote to complex double when exponentiation leaves the real line. Integer bases preserve their class, accept only nonnegative integer-valued exponents, and saturate overflow.

Can I mix scalars and arrays?⌄

Absolutely. Scalars broadcast to match the other operand. This includes scalar gpuArrays.

What happens if only one operand is on the GPU?⌄

If the other operand is a scalar, RunMat keeps everything on the GPU. Otherwise, it gathers the device operand, performs the computation on the host, and returns a host tensor (unless 'like' instructs the runtime to re-upload the result).

Does power modify the inputs in-place?⌄

No. The builtin always allocates a fresh tensor (or complex tensor). Fusion can eliminate temporary allocations when the expression continues with other element-wise operations.

Can I force the result to stay on the GPU?⌄

Yes—pass 'like', gpuArrayPrototype. The runtime mirrors the residency of the prototype and uploads the result when necessary.

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

  • View the source for power 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 power works
  • Does RunMat run power on the GPU?
  • GPU memory and residency
  • Examples
  • Raise a scalar to a power
  • Compute element-wise powers of a matrix
  • Broadcast exponents across rows
  • Generate complex powers from negative bases
  • Keep GPU results with a 'like' prototype
  • Convert character codes before powering
  • Using power 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