1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
###
### $Id: find.R 22 2022-05-30 18:03:47Z proebuck $
###
##-----------------------------------------------------------------------------
test.find <- function(input, expected) {
output <- do.call(getFromNamespace("find", "matlab"), input)
identical(output, expected)
}
X <- c(3, 2, 1, 1, 2, 3)
find.expected.eq.one <- c(3, 4)
test.find(list(X == 1), find.expected.eq.one)
X <- c(1, 0, 4, -3, 0, 0, 0, 8, 6)
find.expected.nonzero <- c(1, 3, 4, 8, 9)
find.expected.gt.two <- c(3, 8, 9)
test.find(list(X), find.expected.nonzero)
test.find(list(X > 2), find.expected.gt.two)
|