---
title: "ClikaRT::ops::where"
sidebar_label: "where"
description: "Elementwise select: condition ? x : y, with numpy-style broadcasting across all three operands."
---

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

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

2 overloads.

## where(Tensor, Tensor, Tensor) {#where}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`where`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `condition`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `other`<br />
)

</div>

Elementwise select: `condition ? x : y`, with numpy-style broadcasting across all three operands.

`condition` is Bool; the output takes the broadcast shape and the promoted common dtype of `input` and `other`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `condition` is not Bool or the shapes do not broadcast (`code_name()` carries the reason).

**Returns:** a new tensor of the broadcast shape.

```cpp
auto safe = ClikaRT::ops::where(denom_ok, quotient, fallback);
```

<div class="api-declared">

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

</div>

## where(Tensor) {#where-2}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`where`**([`Tensor`](../Tensor.md) `condition`)

</div>

The coordinates where `condition` is nonzero, sugar for [`nonzero`](./nonzero.md#nonzero).

Returns the same `[n, `[`ndim`](./ndim.md#ndim)`]` Int64 coordinate matrix as ONE tensor (not a per-dim tuple); the row count is data-dependent.

**Throws**

- `ClikaRT::Error`: when the input's dtype is not served for this operation (the machine-readable reason rides `code_name()`).

**Returns:** a new `[n, `[`ndim`](./ndim.md#ndim)`]` Int64 coordinate matrix.

<div class="api-declared">

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

</div>
