archimedes.zeros¶

archimedes.zeros(shape: ShapeLike, dtype: DTypeLike = <class 'numpy.float64'>, sparse: bool = True, kind: str = 'MX') SymbolicArray¶

Construct a symbolic array of zeros with the given shape and dtype.

This function creates an array filled with zeros, either as “structural” (sparse) zeros that are symbolic placeholders, or as actual numerical zero values.

Parameters:
  • shape (int or tuple of ints) – Shape of the array. A single integer n creates a vector of length n. A tuple (m, n) creates an mĂ—n matrix.

  • dtype (numpy.dtype, optional) – Data type of the array. Default is np.float64.

  • sparse (bool, optional) – If True (default), the array will contain “structural” zeros, which are symbolic placeholders rather than actual numeric values. These are more efficient in memory and computation. If False, the array will contain actual numeric zero values.

  • kind ({"SX", "MX"}, optional) –

    Kind of symbolic variable to create. Default is “MX”.

    • SX: Scalar-based symbolic type. Each element has its own symbolic representation. Generally more efficient for element-wise operations.

    • MX: Matrix-based symbolic type. The entire array is represented by a single symbolic object. Supports a broader range of operations.

Returns:

Symbolic array of zeros with the given shape, dtype, and symbolic kind.

Return type:

SymbolicArray

Notes

The distinction between sparse (structural) and dense (numerical) zeros is important:

  • Sparse/structural zeros (sparse=True) are efficient for building computational graphs where many elements are zero, especially in matrix operations.

  • Dense/numerical zeros (sparse=False) actually contain the value 0 and behave more like traditional NumPy arrays filled with zeros.

When working within a function that will be executed with both symbolic and numeric arrays, prefer using np.zeros_like or np.zeros(..., like=x) where x is either a SymbolicArray or NumPy array. This provides better compatibility across both numeric and symbolic execution paths.

The exception is when you specifically need sparse/structural zeros, which are only available through this direct function call with sparse=True.

Examples

>>> import archimedes as arc
>>> import numpy as np
>>>
>>> # Create a vector of structural zeros (sparse representation)
>>> z1 = arc.zeros(5)
>>> print(z1)
[00, 00, 00, 00, 00]
>>>
>>> # Create a matrix of numerical zeros (dense representation)
>>> z2 = arc.zeros(5, sparse=False)
>>> print(z2)
@1=0, [@1, @1, @1, @1, @1]
>>>
>>> # Create MX-type zeros
>>> z3 = arc.zeros(4, kind="MX")

See also

numpy.zeros

NumPy’s array of zeros function

zeros_like

Create an array of zeros with shape/dtype of an input array

ones

Create an array of ones

array

Create an array from data