Zeros

Shipping
array_zeros

numpy-style zero-filled array source; shape rank picks Vector / Matrix / Tensor

Signature

Outputs

  • arrayArrayA zero-filled array. The requested shape's rank picks the variant: rank 1 → Vector, rank 2 → Matrix, rank ≥ 3 → Tensor.

Parameters

KeyTypeDefaultNotes
shapetext3, 3Target shape as comma-separated dimensions (numpy-style): '5' → a 1-D Vector, '3, 4' → a 2-D Matrix, '2, 3, 4' → an n-D Tensor. The rank picks the output type.
unittextOptional physical unit. Applied only when the result is 1-D (a Vector); Matrix/Tensor results are dimensionless in the data model, so it is dropped there — re-attach downstream with Set Unit if needed.

Description

Zeros is a pure source (no inputs) that births an array every element of which is , mirroring numpy.zeros. It is the identity element for addition and the canonical way to pre-allocate a grid you will fill downstream.

The Shape string is parsed numpy-style ('5', '3, 4', '2, 3, 4') and the rank of that shape selects the output variant through Captyse's shared array SSOT: rank 1 → Vector, rank 2 → Matrix, rank ≥ 3 → Tensor. One node therefore covers 1-D, 2-D and n-D. Only a 1-D (Vector) result can carry the optional Unit; Matrix/Tensor results are dimensionless in the data model and the unit is silently dropped.

Creation is a total operation: an empty or negative shape, an element count that overflows, or one exceeding the -element cap (~800 MB of f64) returns a clean error rather than crashing or cropping. Fully stateless — output depends only on the parameters.

Mathematics

Examples

A 2×3 zero matrix

Set Shape = 2, 3. The array output is a rank-2 Matrix of six zeros, ready as an accumulator for a downstream write/scatter.

A unitful zero vector

Set Shape = 8 and Unit = V. Because the result is 1-D, the unit survives: an 8-element Vector of .

Applications

  • Pre-allocating an accumulator or output buffer that a downstream node fills or scatters into.
  • Building a masked/sparse pattern by starting from zeros and setting a few entries.
  • Supplying a zero baseline to subtract, pad, or initialize an iterative computation.

Neat

There is no dedicated 1-D vs 2-D vs n-D node: the same executor calls `array_factory::filled(shape, 0.0)`, and the rank of the parsed shape alone decides Vector/Matrix/Tensor via the shared `array_to_value` SSOT — identical to how `reshape` picks its variant.

The element count is validated *before* any allocation (`checked_numel`), so a doomed `100000, 100000` request fails fast with a message instead of OOM-aborting the whole native library.

Known issues

A unit is only kept on rank-1 (Vector) results; for a Matrix or Tensor the unit is dropped and must be re-attached downstream with Set Unit.

The total element count is capped at 100,000,000; larger shapes return an error rather than allocating.

See also

arraytensorsourcenumpyconstructorzerosstateless