sorted_union: Sorted Union

Description Usage Arguments Value Examples

View source: R/C_interfaces.R

Description

For two sorted numeric vectors a and b, determine the sorted union of unique elements.

Usage

1
sorted_union(a, b, tolerance = 0)

Arguments

a

a sorted vector of numbers.

b

a sorted vector of numbers.

tolerance

a non-negative number, indicating the tolerance for numerical noise. Specifically, numbers in a and b are appended one by one and in the appropriate order to the output vector. However, a number is only added if it is more than tolerance larger than the most recently added number.

Value

A numeric vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sorted_union(1:3, 2:4)

# Numerical noise < tolerance has no effect
sorted_union(0, 1e-14)
sorted_union(0, 1e-14, tolerance=1e-12)
sorted_union(c(0, 1e-14), 2, tolerance=1e-12)

# Trivial cases
sorted_union(1:10, c())
sorted_union(c(), 1:10)
sorted_union(c(), c())

andreas50/uts documentation built on April 8, 2021, 10:03 a.m.