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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X | NumericArray | Yes | — | Input values. |
Returns
| Name | Type | Description |
|---|---|---|
Y | NumericArray | Element-wise normalized sinc output. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:sinc:InvalidInput | Input cannot be interpreted as numeric/complex data. | sinc: expected numeric input |
RunMat:sinc:ProviderFailed | Provider unary_sinc dispatch fails with a non-unsupported error. | sinc: GPU provider unary_sinc failed |
RunMat:gather:DownloadFailed | GPU host fallback cannot download source data. | gather: download failed |
RunMat:sinc:MalformedComplexBuffer | Complex-interleaved fallback buffer has odd element count. | sinc: malformed complex buffer, odd length |
RunMat:sinc:InternalError | Internal tensor conversion/materialization fails. | sinc: internal error |
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
1for exactly zero real inputs. - Returns exact
0for finite nonzero integer-valued real inputs, matching MATLAB'ssinpi-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 return1 + 0iforz == 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 = 1Evaluate 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 0Evaluate 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.
Related Math functions
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
Structure
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how sinc is executed, line by line, in Rust.
- View the source for sinc 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.