Simple functionality for quaternionic and octonionic matrices,
intended for use in the jordan
package. Use idiom like
matrix(Him,4,5)
or matrix(roct(6),2,3)
to create an
onionmat
object, a matrix of onions.
The package is intended to match base R's matrix functionality in the sense that standard R idiom just goes through for onionic matrices. Determinants are not well-defined for quaternionic or octonionic matrices, and matrix inverses are not implemented.
newonionmat(d, M)
onionmat(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
as.onionmat(x)
is.onionmat(x)
onionmat_negative(e1)
onionmat_inverse(e1)
onionmat_prod_onionmat(e1,e2)
onionmat_power_onionmat(...)
onionmat_prod_single(x,y)
onionmat_power_single(e1,e2)
onionmat_plus_onionmat(e1,e2)
matrix_arith_onion(e1,e2)
onion_arith_matrix(e1,e2)
matrix_plus_onion(e1,e2)
matrix_prod_onion(e1,e2)
# S4 method for onionmat,onionmat
cprod(x,y)
# S4 method for onionmat,missing
cprod(x,y)
# S4 method for onionmat,ANY
cprod(x,y)
# S4 method for ANY,ANY
cprod(x,y)
# S4 method for onion,missing
cprod(x,y)
# S4 method for onion,onion
cprod(x,y)
# S4 method for onion,onionmat
cprod(x,y)
# S4 method for onionmat,onion
cprod(x,y)
# S4 method for onionmat,onionmat
tcprod(x,y)
# S4 method for onionmat,missing
tcprod(x,y)
# S4 method for onionmat,ANY
tcprod(x,y)
# S4 method for ANY,ANY
tcprod(x,y)
# S4 method for onion,missing
cprod(x,y)
# S4 method for onion,onion
cprod(x,y)
# S4 method for onion,onionmat
cprod(x,y)
# S4 method for onionmat,onion
cprod(x,y)
# S4 method for onionmat
t(x)
# S4 method for onion
t(x)
# S4 method for onionmat
ht(x)
# S4 method for onion
ht(x)
nrow(x)
ncol(x)
herm_onion_mat(real_diagonal, onions)
onionmat_complex(z)
onionmat_conjugate(z)
onionmat_imag(z)
onionmat_re(z)
onionmat_mod(z)
onionmat_matrixprod_onionmat(x,y)
onion_matrixprod_onionmat(x,y)
onionmat_matrixprod_numeric(x,y)
onionmat_matrixprod_onion(x,y)
data and matrix index
Objects of class onionmat
In function
onionmat()
, as for matrix()
Further arguments (currently ignored)
In function herm_onion_mat()
, on-
and off- diagonal elements of an Hermitian matrix
Robin K. S. Hankin
An object of class onionmat
is a two-element list, the first of
which is an onion, and the second an index matrix of integers used for
tracking attributes such as dimensions and dimnames. This device
makes the extraction and replacement methods easy. Use getM()
to access the index matrix and getd()
to access the onionic
vector.
The S4 method for matrix()
simply dispatches to
onionmat()
, which is a drop-in replacement for matrix()
.
Function drop()
has a method for onionmat
objects.
Function newonionmat()
is lower-level: it also creates onionmat
objects, but takes two arguments: an onion and a matrix; the matrix
argument can be used to specify additional attributes via
attr()
, but this ability is not currently used in the package.
Functions such as onionmat_plus_onionmat()
are low-level helper
functions, not really designed for the end-user.
Vignette onionmat
shows some use-cases.
The print method for onionmat
objects is sensitive to option
show_onionmats_in_place
. If TRUE
, it prints the matrix
elements in-place, using onion_to_string()
. It works best when
option show_onions_compactly
is effective.
matrix(rquat(28),4,7)
M <- onionmat(rquat(10),2,5)
cprod(M)
Re(M)
Re(M) <- 0.3
romat() %*% rquat(6)
a <- rsomat()
a # default
options("show_onionmats_in_place" = TRUE)
a
options("show_onionmats_in_place" = FALSE) # restore default
Run the code above in your browser using DataLab