svdtensor.RdA tensor can be seen as a linear mapping of a tensor to a tensor. This function computes the singular value decomposition of this mapping
svd.tensor(X,i,j=NULL,...,name="lambda",by=NULL)The tensor to be decomposed
The image dimensions of the linear mapping
The coimage dimensions of the linear mapping
The name of the eigenspace dimension. This is the dimension created by the decompositions, in which the eigenvectors are \(e_i\)
further arguments for generic use
the operation is done in parallel for these dimensions
a tensor or in case of svd a list u,d,v, of tensors like in svd.
A tensor can be seen as a linear mapping of a tensor to a tensor. Let denote \(R_i\) the space of real tensors with dimensions \(i_1...i_d\).
Computes a singular value decomposition \(u_{i_1...i_d\lambda{}}\),\(d_\lambda{}\), \(v_{j_1...j_l}\lambda{}\) such that u and v correspond to orthogonal mappings from \(R_\lambda{}\) to \(R_i\) or \(R_j\) respectively.
# SVD
A <- to.tensor(rnorm(120),c(a=2,b=2,c=5,d=3,e=2))
SVD <- svd.tensor(A,c("a","d"),c("b","c"),by="e")
dim(SVD$v)
#> b c lambda e
#> 2 5 6 2
# Property of decomposition
einstein.tensor(SVD$v,diag=SVD$d,SVD$u,by="e") # A
#> , , 1, 1, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.9232620 -0.5541038 -0.005333142 0.02741056 0.5607759
#> [2,] -0.6875862 -0.1618330 0.989809359 2.40181018 0.2565309
#>
#> , , 2, 1, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.2631799 0.5518464 -2.405133 -0.3910052 -1.430789
#> [2,] 0.2208612 1.3514035 -1.233032 0.5541960 0.447513
#>
#> , , 1, 2, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.9091546 -1.151658 -1.160385 0.5219834 0.5840035
#> [2,] 0.2547813 -0.526109 -1.227036 0.0054809 0.3172920
#>
#> , , 2, 2, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] -0.6576118 0.09235619 1.463217 0.03864691 -0.7196404
#> [2,] -1.3629594 -0.94128250 1.289122 2.05096271 0.1667157
#>
#> , , 1, 3, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 2.502679 -0.06136386 -1.354977 -1.5895300 -0.1887926
#> [2,] 1.072112 0.50430429 -2.529419 0.2058044 0.0747170
#>
#> , , 2, 3, 1
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.40040871 -1.0764436 0.2275063 -1.082493 0.3127565
#> [2,] 0.05500096 0.5362245 -0.8185311 -1.081182 -0.6043449
#>
#> , , 1, 1, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.04524665 -0.7301505 1.200353 0.8723428 0.4442791
#> [2,] -0.75568298 -0.5917005 -1.548818 0.2061176 -0.1194045
#>
#> , , 2, 1, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.6485396 0.5241485 -0.9080713 -1.860478 0.3900637
#> [2,] -0.2881794 -1.1839120 0.4080450 -1.065526 1.4749626
#>
#> , , 1, 2, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] -1.2946583 1.4333404 -0.447372 -0.8699108 0.4218055
#> [2,] -0.2113007 -0.1250153 1.092853 -1.3594073 -0.9635751
#>
#> , , 2, 2, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] -1.4676127 -0.7374681 0.04795768 -0.7026765 0.3267117
#> [2,] 0.4196187 0.2798241 0.50800968 0.3456470 0.4786580
#>
#> , , 1, 3, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.7805649 -1.049773 0.2117230 -0.02289612 0.2409237
#> [2,] -0.3714158 -1.041934 -0.5145817 -0.04291589 0.9873379
#>
#> , , 2, 3, 2
#>
#> c
#> b [,1] [,2] [,3] [,4] [,5]
#> [1,] -0.1854255 0.1355099 -0.4199903 -0.2358174 0.275788
#> [2,] -0.3759064 1.3715435 -0.4811891 -0.5334722 -0.607175
#>
#> attr(,"class")
#> [1] "tensor"
# Property of orthogonality
SVD$v %e% SVD$v[[lambda=~"lambda'"]] # 2*delta.tensor(c(lambda=6))
#> lambda'
#> lambda [,1] [,2] [,3] [,4] [,5]
#> [1,] 2.000000e+00 1.595946e-16 -3.261280e-16 -3.378374e-16 1.266348e-16
#> [2,] 1.595946e-16 2.000000e+00 -9.992007e-16 3.434752e-16 -1.665335e-16
#> [3,] -3.261280e-16 -9.992007e-16 2.000000e+00 -9.714451e-17 -1.942890e-16
#> [4,] -3.378374e-16 3.434752e-16 -9.714451e-17 2.000000e+00 -4.510281e-17
#> [5,] 1.266348e-16 -1.665335e-16 -1.942890e-16 -4.510281e-17 2.000000e+00
#> [6,] 1.838807e-16 0.000000e+00 -4.163336e-17 2.012279e-16 1.838807e-16
#> lambda'
#> lambda [,6]
#> [1,] 1.838807e-16
#> [2,] 0.000000e+00
#> [3,] -4.163336e-17
#> [4,] 2.012279e-16
#> [5,] 1.838807e-16
#> [6,] 2.000000e+00
#> attr(,"class")
#> [1] "tensor" "matrix"
SVD$u %e% SVD$u[[lambda=~"lambda'"]] # 2*delta.tensor(c(lambda=6)))
#> lambda'
#> lambda [,1] [,2] [,3] [,4] [,5]
#> [1,] 2.000000e+00 1.595946e-16 -5.551115e-17 2.567391e-16 3.747003e-16
#> [2,] 1.595946e-16 2.000000e+00 -4.163336e-17 4.163336e-17 -8.326673e-17
#> [3,] -5.551115e-17 -4.163336e-17 2.000000e+00 1.734723e-16 -5.551115e-17
#> [4,] 2.567391e-16 4.163336e-17 1.734723e-16 2.000000e+00 3.330669e-16
#> [5,] 3.747003e-16 -8.326673e-17 -5.551115e-17 3.330669e-16 2.000000e+00
#> [6,] -3.157197e-16 -9.020562e-17 3.747003e-16 -1.665335e-16 4.440892e-16
#> lambda'
#> lambda [,6]
#> [1,] -3.157197e-16
#> [2,] -9.020562e-17
#> [3,] 3.747003e-16
#> [4,] -1.665335e-16
#> [5,] 4.440892e-16
#> [6,] 2.000000e+00
#> attr(,"class")
#> [1] "tensor" "matrix"
SVD$u %e% mark(SVD$u,"'",c("a","d")) # 2*delta.tensor(c(a=2,d=3)))
#> , , 1, 1
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] 2.00000e+00 -8.326673e-17 -5.551115e-17
#> [2,] -1.94289e-16 8.326673e-17 1.249001e-16
#>
#> , , 2, 1
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] -1.94289e-16 5.412337e-16 2.220446e-16
#> [2,] 2.00000e+00 -5.273559e-16 2.498002e-16
#>
#> , , 1, 2
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] -8.326673e-17 2.000000e+00 1.110223e-16
#> [2,] 5.412337e-16 2.012279e-16 -1.040834e-16
#>
#> , , 2, 2
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] 8.326673e-17 2.012279e-16 -3.330669e-16
#> [2,] -5.273559e-16 2.000000e+00 -1.110223e-16
#>
#> , , 1, 3
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] -5.551115e-17 1.110223e-16 2.000000e+00
#> [2,] 2.220446e-16 -3.330669e-16 1.387779e-17
#>
#> , , 2, 3
#>
#> d
#> a [,1] [,2] [,3]
#> [1,] 1.249001e-16 -1.040834e-16 1.387779e-17
#> [2,] 2.498002e-16 -1.110223e-16 2.000000e+00
#>
#> attr(,"class")
#> [1] "tensor"