abs_diff: Absolute difference

View source: R/abs_diff.R

abs_diffR Documentation

Absolute difference

Description

Equivalent to abs(x - y) but aims to be faster by avoiding allocations.

Usage

abs_diff(x, y, nThread = getOption("hutilscpp.nThread", 1L), option = 1L)

max_abs_diff(x, y, nThread = getOption("hutilscpp.nThread", 1L))

Arguments

x, y

Atomic, numeric, equilength vectors.

nThread

Number of threads to use.

option

An integer, provides backwards-compatible method to change results.

0

Return max(abs(x - y)) (without allocation).

1

Return abs(x - y) with the expectation that every element will be integer, returning a double only if required.

2

Return abs(x - y) but always a double vector, regardless of necessity.

3

Return which.max(abs(x - y))

Examples

x <- sample(10)
y <- sample(10)
abs_diff(x, y)
max_abs_diff(x, y)


hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.