RunMat
GitHub

inf — Create arrays filled with IEEE positive infinity values using MATLAB-compatible size, class, and like forms.

inf(...) creates positive-infinity-filled arrays across scalar, vector, matrix, and N-D size signatures, with MATLAB-compatible class and 'like' option behavior.

Syntax

A = inf(2, 3)

How inf works

  • inf() returns the scalar Inf.
  • inf(n) returns an n x n double array filled with Inf.
  • inf(m, n, ...) returns a dense double array with the requested dimensions.
  • inf(sz) accepts a size vector and returns an array with prod(sz) Inf elements.
  • inf(A) returns an Inf array with the same size as A.
  • inf(___, 'single') returns a single-precision numeric array.
  • inf(___, 'like', prototype) matches numeric precision and device residency for supported prototype arrays.

Does RunMat run inf on the GPU?

Provider-backed inf construction uses constant-fill hooks, so fully resident GPU pipelines can create Inf arrays without first materializing a host tensor when provider support is available.

GPU memory and residency

When a GPU prototype is supplied, RunMat preserves residency by allocating the output through the active acceleration provider. If the provider cannot fill on device, RunMat falls back to a host Inf tensor and uploads it.

Examples

Creating a 2x3 matrix of Inf values

A = inf(2, 3)

Expected output:

A = [Inf Inf Inf; Inf Inf Inf]

Creating a single-precision Inf array

A = inf(4, 1, 'single')

Expected output:

A = [Inf; Inf; Inf; Inf]

Creating a GPU-resident Inf array like a prototype

G = gpuArray(rand(2,2));
A = inf(2, 2, 'like', G)

Expected output:

A = [Inf Inf; Inf Inf]

Using inf with coding agents

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

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

FAQ

How is inf different from Inf?

Both bare identifiers resolve to the scalar IEEE positive-infinity constant. The callable form inf(...) constructs Inf-filled arrays.

Does inf(n) create a row vector?

No. MATLAB compatibility requires inf(n) to create an n x n matrix. Use inf(1, n) or inf(n, 1) for vectors.

Can inf create GPU arrays?

Yes. With a GPU prototype, inf(..., 'like', G) asks the active acceleration provider to allocate an Inf-filled GPU tensor.

Creation

colon · eye · false · fill · linspace · logspace · magic · meshgrid · nan · ones · peaks · rand · randi · randn · randperm · range · true · zeros

Sorting Sets

argsort · intersect · ismember · issorted · setdiff · sort · sortrows · union · unique

Shape

cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · squeeze · tril · triu · vertcat

Indexing

find · ind2sub · sub2ind

Introspection

isempty · ismatrix · isscalar · isvector · length · ndims · numel · size

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how inf 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.