trim: Truncates small numbers to 0.

View source: R/basic_tensor.R

trimR Documentation

Truncates small numbers to 0.

Description

Given an array, matrix, or vector, trim will truncate all elements smaller than epsilon (in absolute value) to zero.

Usage

trim(X, epsilon = 10^-6)

Arguments

X

An array, a matrix, or a vector.

epsilon

A numeric.

Details

All elements in X that are smaller than epsilon (in absolute value) will be set to zero then returned.

Author(s)

David Gerard.

Examples

X <- c(0, 1, 10^-7, -1, -10^-7)
X
trim(X)

dcgerard/tensr documentation built on Oct. 4, 2022, 5:58 p.m.