File: pow2.R

package info (click to toggle)
r-cran-matlab 1.0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 700 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
###
### $Id: pow2.R 22 2022-05-30 18:03:47Z proebuck $
###


##-----------------------------------------------------------------------------
test.pow2 <- function(input, expected) {
    output <- do.call(getFromNamespace("pow2", "matlab"), input)
    identical(output, expected)
}

pow2.expected.00 <- 0
pow2.expected.m1 <- -0.5
pow2.expected.f  <- c(1, 2, 4, 8)
pow2.expected.fe <- c(0, 0.5, -8, 24)
pow2.expected.complex <- c(2^(1i), 2^(-1i))

test.pow2(list(f=0, e=0), pow2.expected.00)
test.pow2(list(f=-1, e=-1), pow2.expected.m1)
test.pow2(list(f=0:3), pow2.expected.f)
test.pow2(list(f=c(0, 1, -2, 3), e=c(0, -1, 2, 3)), pow2.expected.fe)
test.pow2(list(f=c(1i, -1i)), pow2.expected.complex)