---
title: "ClikaRT::ops::bincount"
sidebar_label: "bincount"
description: "Occurrence count (or weight sum) of each non-negative integer value."
---

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

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

## bincount() {#bincount}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`bincount`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `weights` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `minlength` `=` `0`<br />
)

</div>

Occurrence count (or weight sum) of each non-negative integer value.

The output is 1-D with length `max(x) + 1`, floored at `minlength`; entry `i` counts how often `i` occurs (with `weights` bound, it sums the weights at those positions instead).

**Parameters**

- `input`: non-negative integers; 1-D.
- `weights`: optional per-position weights, same shape as `input`.
- `minlength`: minimum output length; default 0.

**Returns:** the 1-D counts (integer) or weight sums (weights' dtype).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `input` carries a negative value or is not integer-typed.

<div class="api-declared">

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

</div>
