ADcomplex {RTMB} | R Documentation |
AD complex numbers
Description
A limited set of complex number operations can be used when constructing AD tapes. The available methods are listed in this help page.
Usage
adcomplex(real, imag = rep(advector(0), length(real)))
## S3 method for class 'adcomplex'
Re(z)
## S3 method for class 'adcomplex'
Im(z)
## S4 method for signature 'adcomplex'
show(object)
## S3 method for class 'adcomplex'
dim(x)
## S3 replacement method for class 'adcomplex'
dim(x) <- value
## S3 method for class 'adcomplex'
x[...]
## S3 replacement method for class 'adcomplex'
x[...] <- value
## S3 method for class 'adcomplex'
t(x)
## S3 method for class 'adcomplex'
length(x)
## S3 method for class 'adcomplex'
Conj(z)
## S3 method for class 'adcomplex'
Mod(z)
## S3 method for class 'adcomplex'
Arg(z)
## S3 method for class 'adcomplex'
x + y
## S3 method for class 'adcomplex'
x - y
## S3 method for class 'adcomplex'
x * y
## S3 method for class 'adcomplex'
x / y
## S3 method for class 'adcomplex'
exp(x)
## S3 method for class 'adcomplex'
log(x, base)
## S3 method for class 'adcomplex'
sqrt(x)
## S4 method for signature 'adcomplex'
fft(z, inverse = FALSE)
## S4 method for signature 'advector'
fft(z, inverse = FALSE)
## S3 method for class 'adcomplex'
rep(x, ...)
## S3 method for class 'adcomplex'
as.vector(x, mode = "any")
## S3 method for class 'adcomplex'
is.matrix(x)
## S3 method for class 'adcomplex'
as.matrix(x, ...)
## S4 method for signature 'adcomplex,ANY'
x %*% y
## S4 method for signature 'adcomplex,ANY'
solve(a, b)
## S4 method for signature 'adcomplex'
colSums(x)
## S4 method for signature 'adcomplex'
rowSums(x)
## S4 method for signature 'adcomplex,ANY,ANY'
diag(x)
## S4 method for signature 'advector,adcomplex'
Ops(e1, e2)
## S4 method for signature 'adcomplex,advector'
Ops(e1, e2)
Arguments
real |
Real part |
imag |
Imaginary part |
z |
An object of class |
object |
An object of class |
x |
An object of class |
value |
Replacement value |
... |
As [ |
y |
An object of class |
base |
Not implemented |
inverse |
As fft |
mode |
As as.vector |
a |
matrix |
b |
matrix, vector or missing |
e1 |
Left operand |
e2 |
Right operand |
Value
Object of class "adcomplex"
.
Functions
-
adcomplex()
: Constructadcomplex
vector -
Re(adcomplex)
: As complex -
Im(adcomplex)
: As complex -
show(adcomplex)
: Print method -
dim(adcomplex)
: As dim -
dim(adcomplex) <- value
: As dim -
[
: As [ -
`[`(adcomplex) <- value
: As [<- -
t(adcomplex)
: As t -
length(adcomplex)
: As length -
Conj(adcomplex)
: As complex -
Mod(adcomplex)
: As complex -
Arg(adcomplex)
: As complex -
+
: As complex -
-
: As complex -
*
: As complex -
/
: As complex -
exp(adcomplex)
: As complex -
log(adcomplex)
: As complex -
sqrt(adcomplex)
: As complex -
fft(adcomplex)
: Fast Fourier Transform equivalent to fft. Notably this is the multivariate transform whenx
is an array. -
fft(advector)
: If real input is supplied it is first converted to complex. -
rep(adcomplex)
: As rep -
as.vector(adcomplex)
: Apply for each of real/imag -
is.matrix(adcomplex)
: Apply for real -
as.matrix(adcomplex)
: Apply for each of real/imag -
x %*% y
: Complex matrix multiply -
solve(a = adcomplex, b = ANY)
: Complex matrix inversion and solve -
colSums(adcomplex)
: Apply for each of real/imag -
rowSums(adcomplex)
: Apply for each of real/imag -
diag(x = adcomplex, nrow = ANY, ncol = ANY)
: Apply for each of real/imag -
Ops(e1 = advector, e2 = adcomplex)
: Mixed real/complex arithmetic -
Ops(e1 = adcomplex, e2 = advector)
: Mixed real/complex arithmetic
Examples
## Tape using complex operations
F <- MakeTape(function(x) {
x <- as.complex(x)
y <- exp( x * ( 1 + 2i ) )
c(Re(y), Im(y))
}, numeric(1))
F
F(1)
## Complex FFT on the tape
G <- MakeTape(function(x) sum(Re(fft(x))), numeric(3))
G$simplify()
G$print()