constant

arrayfire.constant(scalar: int | float | complex, shape: tuple[int, ...] = (1, ), dtype: ~arrayfire_wrapper.dtypes.Dtype = arrayfire.float32(typecode<f>)) Array

Create a multi-dimensional array filled with a constant value.

Parameters

scalarint | float | complex

The value to fill each element of the constant array with.

shapetuple[int, …], optional, default: (1,)

The shape of the constant array.

dtypeDtype, optional, default: float32

Data type of the array.

Returns

Array

A multi-dimensional ArrayFire array filled with the specified value.

Notes

The shape parameter determines the dimensions of the resulting array: - If shape is (x1,), the output is a 1D array of size (x1,). - If shape is (x1, x2), the output is a 2D array of size (x1, x2). - If shape is (x1, x2, x3), the output is a 3D array of size (x1, x2, x3). - If shape is (x1, x2, x3, x4), the output is a 4D array of size (x1, x2, x3, x4).