dot-class | R Documentation |
The dot object is defined so that .[x,y]
returns the commutator
of x
and y
, that is, xy-yx
or the Lie bracket
[x,y]
. It would have been nice to use [x,y]
(that is,
without the dot) but although this is syntactically consistent, it
cannot be done in R.
The “meat” of the dot functionality is:
setClass("dot", slots = c(ignore='numeric')) `.` <- new("dot") setMethod("[",signature(x="dot",i="ANY",j="ANY"),function(x,i,j,drop){i*j-j*i})
The package code includes other bits and pieces such as informative
error messages for idiom such as .[]
. The package defines a
matrix method for the dot object. This is because “*
”
returns (incorrectly, in my view) the elementwise product, not the
matrix product.
The Jacobi identity, satisfied by any associative algebra, is
\left[x,\left[y,z\right]\right]+
\left[y,\left[z,x\right]\right]+
\left[z,\left[x,y\right]\right]=0
and the left hand side is returned by jacobi()
, which should be
zero (for some definition of “zero”).
Function ad()
returns the adjoint operator. The adjoint
vignette provides details and examples of the adjoint operator.
The dot object is generated by running script inst/dot.Rmd
, which
includes some further discussion and technical documentation, and
creates file dot.rda
which resides in the data/
directory.
Always returns an object of the same class as xy
.
ignore
:Object of class "numeric"
, just a
formal placeholder
signature(x = "dot", i = "ANY", j = "ANY")
: ...
signature(x = "dot", i = "ANY", j = "missing")
: ...
signature(x = "dot", i = "function", j = "function")
: ...
signature(x = "dot", i = "matrix", j = "matrix")
: ...
signature(x = "dot", i = "missing", j = "ANY")
: ...
signature(x = "dot", i = "missing", j = "missing")
: ...
Robin K. S. Hankin
.[as.freealg("x"),as.freealg("y")]
.[as.freealg("x"),as.freealg("y+2z")]
.[as.freealg("x+y+2xYx"),as.freealg("x+y+2xYx")]
x <- rfalg()
y <- rfalg()
z <- rfalg()
jacobi(x,y,z) # Jacobi identity
.[x,.[y,z]] + .[y,.[z,x]] + .[z,.[x,y]] # Jacobi, expanded
f <- ad(x)
f(y)
rM <- function(...){matrix(sample(1:9,9),3,3)} # a random matrix
M <- rM()
N <- rM()
O <- rM()
.[M,N]
jacobi(M,N,O)
plot(.[sin,tan](seq(from=0,to=1,len=100)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.