Calculates the Euclidean norm of a tensor or its subtensors.

norm(X,...)
# S3 method for class 'tensor'
norm(X,i=NULL,...,by=NULL)
opnorm(X,...)
# S3 method for class 'tensor'
opnorm(X,i=NULL,...,by=NULL)

Arguments

X

The tensor

i

For norm the dimensions to of the subtensors to be used. If missing the norm of the whole tensor is computed. For opnorm the dimensions of the image.

...

unused

by

the list dimension, if i is not specified the norm is calculated for each of these in parallel.

Value

norm

either a single number giving the norm of the tensor or a tensors with the dimensions i removed containing the individual norms in each entry.

opnorm

a tensor of dimension dim(X)[by] giving the Euclidean operator norm of the tensor (i.e. its largest singular value)

Details

norm

The function computes the Euclidean norm, which is the square root over the sum of all entries and not the operator norm.

opnorm

The function computes the Euclidean operator norm, which is largest factor in changing the Euclidean norm, when mapped with the linear mapping corresponding to the tensor.

See also

Author

K. Gerald van den Boogaart

Examples

C <- to.tensor(1:20,c(A=4,B=5))
norm(C,"A")
#> [1]  5.477226 13.190906 21.118712 29.086079 37.067506
#> attr(,"class")
#> [1] "tensor"
norm(C,2)
#> [1] 23.76973 25.69047 27.65863 29.66479
#> attr(,"class")
#> [1] "tensor"
norm(C,c("A","B"))
#> [1] 53.57238
opnorm(C,"A")
#> NULL