sarcomp.zeros#

sarcomp.zeros(shape=(1,), dtype='float32', p2=False, axis=1)#

Create an array of zeros with the specified shape and data type, optionally padding to the next power of two.

Generates an array filled with zeros, with the given shape and data type. If the p2 flag is set to True, the function adjusts the size of the specified axis (or axes) to the next power of two. This can be useful for optimizing performance in certain algorithms that benefit from sizes being powers of two.

Parameters:
  • shape (int or tuple of ints, optional) – The shape of the array to create. Default is (1,), which creates a scalar or a single-element array. If an integer is provided, it specifies the size along the y-axis, assuming a size of 1 along the x-axis.

  • dtype (str or np.dtype, optional) – The desired data type for the array, specified either as a dtype object or a string (e.g., ‘float32’). Default is ‘float32’.

  • p2 (bool, optional) – A boolean flag that, when set to True, pads the array size along the specified axis or axes to the next power of two. Default is False.

  • axis (int or tuple of ints, optional) – The axis or axes along which to apply the padding if p2 is True. Default is 1, which applies padding along the y-axis. For multidimensional arrays, a tuple can specify multiple axes.

Returns:

An array of zeros with the specified shape and data type. If p2 is True, the shape may be adjusted to have sizes that are powers of two along the specified axis or axes.

Return type:

Array

Examples

>>> zeros()
Array of shape (1,), dtype='float32', filled with zeros.
>>> zeros(shape=(5, 10), dtype='complex64', p2=True, axis=0)
Array of shape (8, 10), dtype='complex64', filled with zeros. # Assuming 5 padded to 8 along x-axis
>>> zeros(shape=5, p2=True)
Array of shape (1, 8), dtype='float32', filled with zeros. # Assuming 5 padded to 8 along y-axis

Notes

This function is similar to numpy.zeros, but with the additional capability of padding array dimensions to the next power of two when p2 is True. This feature can be advantageous for algorithms that perform more efficiently with array sizes that are powers of two.