The diagonal tensor is the tensor equivalent of the diagonal matrix.
diag.tensor(X,mark="'",dn=NULL,by=NULL)
a tensor with dimension c(dim(X),mark(dim(X),mark))
c(dim(X),mark(dim(X),mark))
a tensor containing the diagonal entries.
a character to be concatenated to the names of the row dimensions to get the column dimension names
dimnames which are used twice
The diagonal tensor is created for each level of the indices in by.
by
K. Gerald van den Boogaart
$$E_{i_1\ldots i_n j_1\ldots j_n}=\delta_{i_1j_1}\ldots\delta_{i_nj_n}$$
to.tensor
A <- to.tensor(1:4,c(a=2,b=2)) diag.tensor(A) diag.tensor(A,by="b")
Run the code above in your browser using DataLab