---
title: "ClikaRT::Scalar"
sidebar_label: "Scalar"
description: "A scalar operand that keeps its KIND across the boundary: a bool, an integer (any width, stays integral), or a double."
---

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

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

**Header:** `ClikaRT/compute/ops.h`

A scalar operand that keeps its KIND across the boundary: a bool, an integer (any width, stays integral), or a double. What it buys over a bare double parameter: an integer scalar against an integer tensor stays in the integer domain (`ops::sub(2, int64_tensor)` is Int64, exact at any magnitude), where a double would force weak-float promotion. Every ctor is implicit on purpose. Pass the bare literal. Distinct from [`ScalarOrTensor`](./ScalarOrTensor.md): a [`Scalar`](./Scalar.md) never carries a tensor, which is what keeps a two-tensor call (`ops::add(a, b)`) unambiguous against the tensor-first overloads.

## Member functions

### Scalar(bool) {#Scalar}

<div class="api-signature">

**`Scalar`**(`bool` `v`)

</div>

A boolean scalar; it keeps Bool kind (never widened to int or double).

<div class="api-declared">

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

</div>

### Scalar(T) {#Scalar-2}

<div class="api-signature">

`template <``typename T`, `typename std::enable_if<std::is_integral<T>::value &&!std::is_same<T, bool>::value, int>::type` `=` `0``>`<br />**`Scalar`**(`T` `v`)

</div>

Integral values keep their integer-ness across the boundary. Templated over the integral types so every width lands here exactly, never on the double ctor, and never ambiguously against it.

<div class="api-declared">

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

</div>

### Scalar(double) {#Scalar-3}

<div class="api-signature">

**`Scalar`**(`double` `v`)

</div>

A double scalar, the weak-float kind (against an integer tensor the result promotes to float).

<div class="api-declared">

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

</div>

### is\_bool() {#is_bool}

<div class="api-signature">

`bool` **`is_bool`**() `const`

</div>

True for the Bool kind.

<div class="api-declared">

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

</div>

### is\_int() {#is_int}

<div class="api-signature">

`bool` **`is_int`**() `const`

</div>

True for the Int kind.

<div class="api-declared">

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

</div>

### is\_float() {#is_float}

<div class="api-signature">

`bool` **`is_float`**() `const`

</div>

True for the Float kind.

<div class="api-declared">

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

</div>

### bool\_value() {#bool_value}

<div class="api-signature">

`bool` **`bool_value`**() `const`

</div>

The boolean payload; meaningful when [`is_bool()`](./Scalar.md#is_bool).

<div class="api-declared">

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

</div>

### int\_value() {#int_value}

<div class="api-signature">

`std::int64_t` **`int_value`**() `const`

</div>

The integer payload; meaningful when [`is_int()`](./Scalar.md#is_int).

<div class="api-declared">

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

</div>

### float\_value() {#float_value}

<div class="api-signature">

`double` **`float_value`**() `const`

</div>

The double payload; meaningful when [`is_float()`](./Scalar.md#is_float).

<div class="api-declared">

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

</div>
