A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
clamp
ArrayFire Functions | ArrayFire Functions by Category » Mathematical functions » Numeric functions

## Functions
af_err | af_clamp (af_array *out, const af_array in, const af_array lo, const af_array hi, const bool batch)
| C Interface to clamp an array between an upper and a lower limit.
array | clamp (const array &in, const array &lo, const array &hi)
array | clamp (const array &in, const array &lo, const double hi)
array | clamp (const array &in, const double lo, const array &hi)
array | clamp (const array &in, const double lo, const double hi)

## Detailed Description

Clamp an array between an upper and a lower limit.

## Function Documentation

## ◆ af_clamp()

af_err af_clamp | ( | af_array * | out,
|  | const af_array | in,
|  | const af_array | lo,
|  | const af_array | hi,
|  | const bool | batch )

C Interface to clamp an array between an upper and a lower limit.

Parameters

  [out] | out | clamped array
  [in] | in | input array
  [in] | lo | lower limit array
  [in] | hi | upper limit array
  [in] | batch | batch mode

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ clamp() [1/4]

array clamp | ( | const array & | in,
|  | const array & | lo,
|  | const array & | hi )

C++ Interface to clamp an array between an upper and a lower limit.

Parameters

  [in] | in | input array
  [in] | lo | lower limit; can be an array or a scalar
  [in] | hi | upper limit; can be an array or a scalar

Returns
  clamped array

## ◆ clamp() [2/4]

array clamp | ( | const array & | in,
|  | const array & | lo,
|  | const double | hi )

C++ Interface to clamp an array between an upper and a lower limit.

Parameters

  [in] | in | input array
  [in] | lo | lower limit; can be an array or a scalar
  [in] | hi | upper limit; can be an array or a scalar

Returns
  clamped array

## ◆ clamp() [3/4]

array clamp | ( | const array & | in,
|  | const double | lo,
|  | const array & | hi )

C++ Interface to clamp an array between an upper and a lower limit.

Parameters

  [in] | in | input array
  [in] | lo | lower limit; can be an array or a scalar
  [in] | hi | upper limit; can be an array or a scalar

Returns
  clamped array

## ◆ clamp() [4/4]

array clamp | ( | const array & | in,
|  | const double | lo,
|  | const double | hi )

C++ Interface to clamp an array between an upper and a lower limit.

Parameters

  [in] | in | input array
  [in] | lo | lower limit; can be an array or a scalar
  [in] | hi | upper limit; can be an array or a scalar

Returns
  clamped array