---
title: "ClikaRT::ops::nonzero"
sidebar_label: "nonzero"
description: "Coordinates of the nonzero elements: an [n, ndim] Int64 matrix, one row per nonzero element of input."
---

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

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

## nonzero() {#nonzero}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`nonzero`**([`Tensor`](../Tensor.md) `input`)

</div>

Coordinates of the nonzero elements: an `[n, `[`ndim`](./ndim.md#ndim)`]` Int64 matrix, one row per nonzero element of `input`. An element is nonzero exactly when its Bool cast is true: +0 and -0 are zero; a subnormal, an infinity and a NaN are nonzero.

The row count is data-dependent (see [`masked_select`](./masked_select.md#masked_select)); a 1-arg [`where()`](./where.md#where) call is sugar for this op.

**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 2620

</div>
