tensorA (version 0.36.2.1)

diag.tensor: Creates a "diagonal" tensor

Description

The diagonal tensor is the tensor equivalent of the diagonal matrix.

Usage

diag.tensor(X,mark="'",dn=NULL,by=NULL)

Value

a tensor with dimension c(dim(X),mark(dim(X),mark))

Arguments

X

a tensor containing the diagonal entries.

mark

a character to be concatenated to the names of the row dimensions to get the column dimension names

dn

dimnames which are used twice

by

The diagonal tensor is created for each level of the indices in by.

Author

K. Gerald van den Boogaart

Details

$$E_{i_1\ldots i_n j_1\ldots j_n}=\delta_{i_1j_1}\ldots\delta_{i_nj_n}$$

See Also

to.tensor

Examples

Run this code
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