eye#
Generate an identity tensor
-
template<typename T = int, typename ShapeType, std::enable_if_t<!std::is_array_v<typename remove_cvref<ShapeType>::type>, bool> = true>
inline auto matx::eye(ShapeType &&s)# Creates an identity patterns on the tensor
eye returns 1 on all elements on the diagonals of a tensor, and 0 otherwise. In other words, if the index of every dimension is the same, a 1 is returned, otherwise a zero is returned.
- Template Parameters:
T – Data type
-
template<typename T = int, int RANK>
inline auto matx::eye(const index_t (&s)[RANK])# Creates an identity patterns on the tensor
eye returns 1 on all elements on the diagonals of a tensor, and 0 otherwise. In other words, if the index of every dimension is the same, a 1 is returned, otherwise a zero is returned.
- Template Parameters:
T – Data type
Examples#
index_t count = 10;
auto t2 = make_tensor<TestType>({count, count});
auto t3 = make_tensor<TestType>({count, count, count});
auto t4 = make_tensor<TestType>({count, count, count, count});
auto eye_op = eye<TestType>();
// For each of t2, t3, and t4 the values on the diagonal where each index is the same
// is 1, and 0 everywhere else
(t2 = eye_op).run(exec);
(t3 = eye_op).run(exec);
(t4 = eye_op).run(exec);