linspace#

Return a range of linearly-spaced numbers using first and last value. The step size is determined by the shape.

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

Create a linearly-spaced range of values.

Creates a set of values using a start and end that are linearly- spaced apart over the set of values. Distance is determined by the shape and selected dimension.

Template Parameters:
  • T – Operator type

  • Dim – Dimension to operate over

  • ShapeType – Shape type

Parameters:
  • s – Shape object

  • first – First value

  • last – Last value

Returns:

Operator with linearly-spaced values

template<int Dim, int RANK, typename T>
inline auto matx::linspace(const index_t (&s)[RANK], T first, T last)#

Create a linearly-spaced range of values.

Creates a set of values using a start and end that are linearly- spaced apart over the set of values. Distance is determined by the shape and selected dimension.

Template Parameters:
  • Dim – Dimension to operate over

  • RANK – Rank of shape

  • T – Operator type

Parameters:
  • s – Array of sizes

  • first – First value

  • last – Last value

Returns:

Operator with linearly-spaced values

Examples#

index_t count = 100;
auto t1 = make_tensor<TestType>({count});

// Create a set of linearly-spaced numbers starting at 1, ending at 100, and 
// with `count` points in between
(t1 = linspace<0>(t1.Shape(), (TestType)1, (TestType)100)).run(exec);