The level of a tensor is the number of dimensions or subscripts used.

level.tensor(X,...)

Arguments

X

the tensor to be used

...

not used

Value

the number of levels

Details

The level of the tensor is the length of its dim attribute. Objects without a dim attribute get level 1 if they are of length > 1 and are marked as scalars by 0 level otherwise.

See also

Author

K. Gerald van den Boogaart

Examples

A <- to.tensor(1:24,c(a=1,b=2,c=3,d=4))
level.tensor(A)
#> [1] 4
level.tensor(matrix(1))
#> [1] 2
level.tensor(1:10)
#> [1] 1
level.tensor(1)
#> [1] 0