RunMat
GitHub

sinc — Normalized sinc, sin(pi*x)/(pi*x), evaluated element-wise.

y = sinc(x) evaluates the normalized sinc function element-wise using MATLAB's definition sin(pi*x)/(pi*x), with sinc(0) defined as 1.

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.

How RunMat runs 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]

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 · 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

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 works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Write code or describe what you want to compute. The sandbox is free, no account required.