RunMat
GitHub

sinc — Compute the normalized sinc function sin(pi*x)/(pi*x) element-wise.

y = sinc(x) evaluates the normalized sinc function using MATLAB's definition sin(pi*x)/(pi*x), with the removable singularity handled as sinc(0) = 1.

Syntax

Y = sinc(X)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYesInput values.

Returns

NameTypeDescription
YNumericArrayElement-wise normalized sinc output.

Errors

IdentifierWhenMessage
RunMat:sinc:InvalidInputInput cannot be interpreted as numeric/complex data.sinc: expected numeric input
RunMat:sinc:ProviderFailedProvider unary_sinc dispatch fails with a non-unsupported error.sinc: GPU provider unary_sinc failed
RunMat:gather:DownloadFailedGPU host fallback cannot download source data.gather: download failed

How sinc works

  • Accepts real or complex scalars, vectors, matrices, and N-D tensors.
  • Preserves the input shape for vector, matrix, and N-D tensor inputs.
  • Returns 1 for exactly zero real inputs.
  • Returns exact 0 for finite nonzero integer-valued real inputs, matching MATLAB's sinpi-style integer accuracy where practical.
  • Logical and integer inputs are promoted to double precision before evaluation.
  • Complex inputs use the analytic extension sin(pi*z)/(pi*z) and return 1 + 0i for z == 0.
  • GPU inputs stay resident when the active provider supports unary_sinc; otherwise RunMat gathers automatically and evaluates with the host implementation.

Does RunMat run sinc on the GPU?

Provider-backed execution uses the same normalized sinc semantics, including sinc(0) == 1 and exact zeros for finite nonzero integer-valued real inputs.

If the provider declines the operation, RunMat gathers through the active provider and evaluates with the host implementation.

Fusion emits a guarded normalized sinc expression with explicit zero and integer branches for real elementwise graphs.

GPU memory and residency

sinc keeps real GPU tensors resident when the active provider exposes unary_sinc. The runtime preserves a host fallback for providers that do not support the hook.

Examples

Evaluate sinc at zero

y = sinc(0)

Expected output:

y = 1

Evaluate sinc at integer inputs

x = 1:5;
y = sinc(x)

Expected output:

y = [0 0 0 0 0]

Evaluate normalized sinc values

x = [-1 0 1 0.5];
y = sinc(x)

Expected output:

y = [0 1 0 0.6366]

Preserve matrix shape

A = [0 0.5; 1.5 2];
Y = sinc(A)

Expected output:

Y =
    1.0000    0.6366
   -0.2122         0

Evaluate sinc for a complex value

z = sinc(0.5 + 0.25i)

Use gpuArray input

g = gpuArray([0 0.5 1]);
y = sinc(g);
result = gather(y)

Expected output:

result = [1 0.6366 0]

Using sinc with coding agents

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

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

FAQ

Which sinc definition does RunMat use?

RunMat uses MATLAB's normalized definition, sin(pi*x)/(pi*x), with the removable singularity at zero defined as 1.

Why does sinc(1:5) return exact zeros?

The implementation detects finite nonzero integer-valued real inputs before evaluating the trigonometric expression. This avoids floating-point residuals from sin(pi*x) and matches MATLAB's practical sinpi behaviour.

Does sinc support complex values?

Yes. Complex scalars and complex tensors use the analytic extension sin(pi*z)/(pi*z) and preserve tensor shape.

Will sinc(gpuArray(...)) stay on the GPU?

Yes when the active provider implements unary_sinc. Providers without that hook fall back to host evaluation so zero and integer cases still use the exact MATLAB-compatible path.

Signal

blackman · butter · conv · conv2 · deconv · filter · hamming · hann · sawtooth · square

Elementwise

abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times

Trigonometry

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

Reduction

all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

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

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Interpolation

interp1 · interp2 · pchip · ppval · spline

Ode

ode15s · ode23 · ode45

Open-source implementation

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

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.