# Creates a "diagonal" tensor

### Description

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

### Usage

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

### 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 |

### Details

*
E_{i_1...i_n j_1...j_n}=δ_{i_1j_1}...δ_{i_n j_n}
*

### Value

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

### Author(s)

K. Gerald van den Boogaart

### See Also

`to.tensor`

### Examples

1 2 3 | ```
A <- to.tensor(1:4,c(a=2,b=2))
diag.tensor(A)
diag.tensor(A,by="b")
``` |