---
title: "ClikaRT::ops::meshgrid"
sidebar_label: "meshgrid"
description: "Coordinate grids from 1-D axes: N inputs produce N N-D tensors, each input broadcast over every other axis, the NumPy meshgrid."
---

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

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

## meshgrid() {#meshgrid}

<div class="api-signature">

`std::vector<`[`Tensor`](../Tensor.md)`>` **`meshgrid`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const` [`Tensor`](../Tensor.md)`>` `tensors`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`MeshgridIndexing`](./index.md#MeshgridIndexing) `indexing` `=` [`MeshgridIndexing::IJ`](./index.md#MeshgridIndexing)<br />
)

</div>

Coordinate grids from 1-D axes: N inputs produce N N-D tensors, each input broadcast over every other axis, the NumPy [`meshgrid`](./meshgrid.md#meshgrid).

With [`MeshgridIndexing::IJ`](./index.md#MeshgridIndexing) (matrix indexing, the default) the output shapes follow the input order `[len0, len1, ..]`; `XY` (Cartesian) swaps the first two axes.

**Parameters**

- `tensors`: the 1-D axis tensors.
- `indexing`: output orientation; default [`MeshgridIndexing::IJ`](./index.md#MeshgridIndexing).

**Returns:** one grid per input, all of the common output shape.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when an input is not 1-D (`code_name()` carries the reason).

```cpp
auto g = ClikaRT::ops::meshgrid({ys, xs});  // g[0], g[1]: [len_y, len_x]
```

<div class="api-declared">

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

</div>
