---
title: "ClikaRT::ops::linspace"
sidebar_label: "linspace"
description: "steps evenly spaced values from start to end, ENDPOINTS INCLUDED. out[i] = start + i * (end - start) / (steps - 1); the last element is exactly end; steps = 1 yields just start."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## linspace() {#linspace}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`linspace`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `start`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `end`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `steps`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype` `=` [`DataType::Float32`](../../index.md#DataType),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`<br />
)

</div>

`steps` evenly spaced values from `start` to `end`, ENDPOINTS INCLUDED.

`out[i] = start + i * (end - start) / (steps - 1)`; the last element is exactly `end`; `steps = 1` yields just `start`. Contrast [`arange`](./arange.md#arange), whose upper bound is exclusive. Bounds and count are literals or 0-D Tensors (trace symbolically).

**Parameters**

- `start`: first value.
- `end`: last value (inclusive).
- `steps`: number of samples.
- `dtype`: element type. Default [`DataType::Float32`](../../index.md#DataType).
- `device`: stream or device. Default: the default device.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `steps` is negative or not a scalar count (`code_name()` carries the reason).

**Returns:** a new 1-D tensor of `steps` elements.

```cpp
auto grid = ClikaRT::ops::linspace(0.0, 1.0, 33);  // 0, 1/32, .., 1
```

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 2433

</div>
