zeros#

Generate an operator of zeros

zeros() has both a shapeless and a shaped version. The shapeless version is preferred in contexts where the shape can be deduced by the expression, thus simplifying the code. If the shape cannot be deducded, the explicit shape version is used to specify the shape directly.

template<typename T = int>
inline auto matx::zeros()#

Return zeros for all elements

zeros is used as an operator that always returns a 0 type for all elements. It can be used in place of memset to set all values to 0. This version of zeros() is shapeless and can be used in contexts where the shape can be deduced.

Template Parameters:

T – Data type

template<typename T = int, typename ShapeType, std::enable_if_t<!std::is_array_v<typename remove_cvref<ShapeType>::type>, bool> = true>
inline auto matx::zeros(ShapeType &&s)#

Return zero for all elements

Zeros is used as an operator that always returns a 0 type for all elements. It can be used in place of memset to zero a block of memory.

Template Parameters:

T – Data type

Parameters:

s – Shape of tensor

template<typename T = int, int RANK>
inline auto matx::zeros(const index_t (&s)[RANK])#

Return zero for all elements

Zeros is used as an operator that always returns a 0 type for all elements. It can be used in place of memset to zero a block of memory.

Template Parameters:

T – Data type

Parameters:

s – Shape of tensor

Examples#

index_t count = 100;

std::array<index_t, 1> s({count});
auto t1 = make_tensor<TestType>(s);

(t1 = zeros()).run(exec);