4. Einsum operation by DelayedTensor

Authors: Koki Tsuyuzaki [aut, cre]
Last modified: 2025-03-29 06:17:14.108202
Compiled: Sat Mar 29 06:20:30 2025

What is einsum

einsum is an easy and intuitive way to write tensor operations.

It was originally introduced by Numpy1 package of Python but similar tools have been implemented in other languages (e.g. R, Julia) inspired by Numpy. In this vignette, we will use CRAN einsum package first.

einsum is named after Einstein summation2 introduced by Albert Einstein, which is a notational convention that implies summation over a set of indexed terms in a formula.

Here, we consider a simple example of einsum; matrix multiplication. If we naively implement the matrix multiplication, the calculation would look like the following in a for loop.

A <- matrix(runif(3*4), nrow=3, ncol=4)
B <- matrix(runif(4*5), nrow=4, ncol=5)
C <- matrix(0, nrow=3, ncol=5)

I <- nrow(A)
J <- ncol(A)
K <- ncol(B)

for(i in 1:I){
  for(j in 1:J){
    for(k in 1:K){
      C[i,k] = C[i,k] + A[i,j] * B[j,k]
    }
  }
}

Therefore, any programming language can implement this. However, when analyzing tensor data, such operations tend to be more complicated and increase the possibility of causing bugs because the order of tensors is larger or more tensors are handled simultaneously. In addition, several programming languages, especially R, are known to significantly slow down the speed of computation if the code is written in for loop.

Obviously, in the case of the R language, it should be executed using the built-in matrix multiplication function (%*%) prepared by the R, as shown below.

C <- A %*% B

However, more complex operations than matrix multiplication are not always provided by programming languages as standard.

einsum is a function that solves such a problem. To put it simply, einsum is a wrapper for the for loop above. Like the Einstein summation, it omits many notations such as for, array size (e.g. I, J, and K), brackets (e.g. {}, (), and []), and even addition operator (+) and extracts the array subscripts (e.g. i, j, and k) to concisely express the tensor operation as follows.

suppressPackageStartupMessages(library("einsum"))
C <- einsum('ij,jk->ik', A, B)

Einsum of DelayedTensor

CRAN einsum is easy to use because the syntax is almost the same as that of Numpy‘s einsum, except that it prohibits the implicit modes that do not use’->’. It is extremely fast because the internal calculation is actually performed by C++. When the input tensor is huge, however, it is not scalable because it assumes that the input is R’s standard array.

Using einsum of DelayedTensor, we can augment the CRAN einsum’s functionality; in DelayedTensor, the input DelayedArray objects are divided into multiple block tensors and the CRAN einsum is incremently applied in the block processing.

Typical operations of einsum

A surprisingly large number of tensor operations can be handled uniformly in einsum.

In more detail, einsum is capable of performing any tensor operation that can be described by a combination of the following three operations3.

  1. Multiplication: the element values of the tensors on the left side of -> are multiplied by each other
  2. Summation: when comparing the left and right sides of ->, if there is a missing subscript on the right, the summation is done in the direction of the subscript
  3. Permutation: the subscripts to the right of -> can be rearranged in any order

Some typical operations are introduced below. Here we use the arrays and DelayedArray objects below.

suppressPackageStartupMessages(library("DelayedTensor"))
suppressPackageStartupMessages(library("DelayedArray"))

arrA <- array(runif(3), dim=c(3))
arrB <- array(runif(3*3), dim=c(3,3))
arrC <- array(runif(3*4), dim=c(3,4))
arrD <- array(runif(3*3*3), dim=c(3,3,3))
arrE <- array(runif(3*4*5), dim=c(3,4,5))

darrA <- DelayedArray(arrA)
darrB <- DelayedArray(arrB)
darrC <- DelayedArray(arrC)
darrD <- DelayedArray(arrD)
darrE <- DelayedArray(arrE)

No Operation

diag

We can also extract the diagonal elements as follows.

einsum::einsum('ii->i', arrB)
## [1] 0.05189427 0.14958670 0.04032693
DelayedTensor::einsum('ii->i', darrB)
## <3> HDF5Array object of type "double":
##        [1]        [2]        [3] 
## 0.05189427 0.14958670 0.04032693
einsum::einsum('iii->i', arrD)
## [1] 0.2126933 0.9967052 0.2246769
DelayedTensor::einsum('iii->i', darrD)
## <3> HDF5Array object of type "double":
##       [1]       [2]       [3] 
## 0.2126933 0.9967052 0.2246769

Multiplication

By using multiple arrays or DelayedArray objects as input and writing “,” on the right side of ->, multiplication will be performed.

Hadamard Product

Hadamard Product can also be implemented in einsum, multiplying by the product of each element.

einsum::einsum('i,i->i', arrA, arrA)
## [1] 0.693253309 0.001922188 0.278016135
DelayedTensor::einsum('i,i->i', darrA, darrA)
## <3> HDF5Array object of type "double":
##         [1]         [2]         [3] 
## 0.693253309 0.001922188 0.278016135
einsum::einsum('ij,ij->ij', arrC, arrC)
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.92788111 0.02322562 0.05429748 0.06738677
## [2,] 0.15418160 0.57006275 0.05273439 0.06723816
## [3,] 0.03350386 0.38334214 0.05635275 0.90778209
DelayedTensor::einsum('ij,ij->ij', darrC, darrC)
## <3 x 4> HDF5Matrix object of type "double":
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.92788111 0.02322562 0.05429748 0.06738677
## [2,] 0.15418160 0.57006275 0.05273439 0.06723816
## [3,] 0.03350386 0.38334214 0.05635275 0.90778209
einsum::einsum('ijk,ijk->ijk', arrE, arrE)
## , , 1
## 
##            [,1]       [,2]      [,3]       [,4]
## [1,] 0.86651949 0.07614034 0.5991220 0.35294607
## [2,] 0.89061181 0.48876488 0.2913038 0.06887109
## [3,] 0.09230641 0.54259715 0.5560831 0.34979000
## 
## , , 2
## 
##           [,1]      [,2]      [,3]       [,4]
## [1,] 0.3646663 0.2728969 0.4097932 0.02173345
## [2,] 0.3816556 0.9130738 0.8413611 0.06366191
## [3,] 0.5965503 0.5654322 0.6213147 0.01419502
## 
## , , 3
## 
##            [,1]      [,2]         [,3]      [,4]
## [1,] 0.02710576 0.1336292 0.1053641669 0.6810540
## [2,] 0.60848739 0.4528653 0.0006882309 0.7996888
## [3,] 0.51753865 0.6427403 0.6563810987 0.4669783
## 
## , , 4
## 
##              [,1]        [,2]      [,3]       [,4]
## [1,] 0.0009956905 0.936783621 0.2319106 0.01242244
## [2,] 0.0001021853 0.254042284 0.3091181 0.08480305
## [3,] 0.5504698308 0.003245683 0.3616105 0.99518247
## 
## , , 5
## 
##            [,1]      [,2]      [,3]        [,4]
## [1,] 0.01694910 0.1804616 0.2681359 0.383470669
## [2,] 0.08352549 0.4000698 0.5792173 0.243036705
## [3,] 0.37858629 0.1558609 0.5563005 0.007381677
DelayedTensor::einsum('ijk,ijk->ijk', darrE, darrE)
## <3 x 4 x 5> HDF5Array object of type "double":
## ,,1
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.86651949 0.07614034 0.59912204 0.35294607
## [2,] 0.89061181 0.48876488 0.29130375 0.06887109
## [3,] 0.09230641 0.54259715 0.55608310 0.34979000
## 
## ,,2
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.36466631 0.27289685 0.40979324 0.02173345
## [2,] 0.38165562 0.91307379 0.84136108 0.06366191
## [3,] 0.59655032 0.56543216 0.62131472 0.01419502
## 
## ,,3
##              [,1]         [,2]         [,3]         [,4]
## [1,] 0.0271057650 0.1336292420 0.1053641669 0.6810539993
## [2,] 0.6084873856 0.4528652981 0.0006882309 0.7996888330
## [3,] 0.5175386491 0.6427402946 0.6563810987 0.4669783380
## 
## ,,4
##              [,1]         [,2]         [,3]         [,4]
## [1,] 0.0009956905 0.9367836212 0.2319105999 0.0124224366
## [2,] 0.0001021853 0.2540422839 0.3091181003 0.0848030456
## [3,] 0.5504698308 0.0032456831 0.3616104537 0.9951824709
## 
## ,,5
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.016949105 0.180461614 0.268135946 0.383470669
## [2,] 0.083525495 0.400069815 0.579217290 0.243036705
## [3,] 0.378586290 0.155860858 0.556300490 0.007381677

Outer Product

The outer product can also be implemented in einsum, in which the subscripts in the input array are all different, and all of them are kept.

einsum::einsum('i,j->ij', arrA, arrA)
##            [,1]        [,2]       [,3]
## [1,] 0.69325331 0.036504292 0.43901663
## [2,] 0.03650429 0.001922188 0.02311708
## [3,] 0.43901663 0.023117079 0.27801613
DelayedTensor::einsum('i,j->ij', darrA, darrA)
## <3 x 3> HDF5Matrix object of type "double":
##             [,1]        [,2]        [,3]
## [1,] 0.693253309 0.036504292 0.439016635
## [2,] 0.036504292 0.001922188 0.023117079
## [3,] 0.439016635 0.023117079 0.278016135
einsum::einsum('ij,klm->ijklm', arrC, arrE)
## , , 1, 1, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.8966756 0.1418642 0.2169097 0.2416443
## [2,] 0.3655152 0.7028303 0.2137648 0.2413777
## [3,] 0.1703871 0.5763449 0.2209768 0.8869109
## 
## , , 2, 1, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.9090555 0.1438228 0.2199045 0.2449805
## [2,] 0.3705617 0.7125339 0.2167161 0.2447102
## [3,] 0.1727395 0.5843022 0.2240277 0.8991560
## 
## , , 3, 1, 1
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.29265915 0.04630198 0.07079552 0.07886844
## [2,] 0.11929774 0.22939147 0.06976907 0.07878143
## [3,] 0.05561134 0.18810885 0.07212295 0.28947212
## 
## , , 1, 2, 1
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.26579915 0.04205243 0.06429797 0.07162996
## [2,] 0.10834870 0.20833812 0.06336572 0.07155093
## [3,] 0.05050738 0.17084438 0.06550357 0.26290462
## 
## , , 2, 2, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.6734357 0.1065451 0.1629070 0.1814836
## [2,] 0.2745151 0.5278510 0.1605451 0.1812833
## [3,] 0.1279668 0.4328558 0.1659616 0.6661021
## 
## , , 3, 2, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7095531 0.1122593 0.1716440 0.1912168
## [2,] 0.2892378 0.5561604 0.1691553 0.1910058
## [3,] 0.1348299 0.4560706 0.1748624 0.7018262
## 
## , , 1, 3, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7455964 0.1179618 0.1803630 0.2009301
## [2,] 0.3039302 0.5844118 0.1777480 0.2007084
## [3,] 0.1416789 0.4792376 0.1837449 0.7374770
## 
## , , 2, 3, 1
## 
##            [,1]       [,2]      [,3]      [,4]
## [1,] 0.51989927 0.08225394 0.1257659 0.1401072
## [2,] 0.21192848 0.40750634 0.1239424 0.1399526
## [3,] 0.09879171 0.33416912 0.1281240 0.5142376
## 
## , , 3, 3, 1
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7183168 0.1136458 0.1737640 0.1935785
## [2,] 0.2928101 0.5630295 0.1712446 0.1933649
## [3,] 0.1364952 0.4617035 0.1770221 0.7104944
## 
## , , 1, 4, 1
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5722692 0.09053945 0.1384344 0.1542203
## [2,] 0.2332762 0.44855480 0.1364273 0.1540501
## [3,] 0.1087431 0.36783026 0.1410301 0.5660372
## 
## , , 2, 4, 1
## 
##           [,1]       [,2]       [,3]       [,4]
## [1,] 0.2527928 0.03999467 0.06115167 0.06812489
## [2,] 0.1030469 0.19814350 0.06026504 0.06804973
## [3,] 0.0480359 0.16248444 0.06229828 0.25003989
## 
## , , 3, 4, 1
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5697048 0.09013373 0.1378141 0.1535292
## [2,] 0.2322309 0.44654479 0.1358159 0.1533598
## [3,] 0.1082558 0.36618198 0.1403981 0.5635008
## 
## , , 1, 1, 2
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5816932 0.09203044 0.1407141 0.1567600
## [2,] 0.2371178 0.45594153 0.1386739 0.1565870
## [3,] 0.1105338 0.37388764 0.1433525 0.5753586
## 
## , , 2, 1, 2
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5950891 0.09414982 0.1439546 0.1603700
## [2,] 0.2425784 0.46644148 0.1418675 0.1601931
## [3,] 0.1130793 0.38249795 0.1466538 0.5886086
## 
## , , 3, 1, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7439945 0.1177083 0.1799755 0.2004984
## [2,] 0.3032772 0.5831562 0.1773661 0.2002772
## [3,] 0.1413745 0.4782080 0.1833501 0.7358924
## 
## , , 1, 2, 2
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.50320556 0.0796128 0.1217276 0.1356084
## [2,] 0.20512356 0.3944215 0.1199627 0.1354588
## [3,] 0.09561955 0.3234391 0.1240100 0.4977257
## 
## , , 2, 2, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.9204477 0.1456252 0.2226603 0.2480506
## [2,] 0.3752055 0.7214633 0.2194320 0.2477769
## [3,] 0.1749043 0.5916246 0.2268352 0.9104241
## 
## , , 3, 2, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7243299 0.1145972 0.1752186 0.1951990
## [2,] 0.2952613 0.5677427 0.1726781 0.1949836
## [3,] 0.1376378 0.4655684 0.1785039 0.7164420
## 
## , , 1, 3, 2
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.6166356 0.09755871 0.1491668 0.1661765
## [2,] 0.2513614 0.48332997 0.1470041 0.1659932
## [3,] 0.1171736 0.39634709 0.1519637 0.6099205
## 
## , , 2, 3, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.8835627 0.1397896 0.2137377 0.2381105
## [2,] 0.3601700 0.6925522 0.2106387 0.2378478
## [3,] 0.1678953 0.5679165 0.2177453 0.8739408
## 
## , , 3, 3, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7592800 0.1201267 0.1836731 0.2046177
## [2,] 0.3095082 0.5951373 0.1810101 0.2043919
## [3,] 0.1442790 0.4880329 0.1871171 0.7510116
## 
## , , 1, 4, 2
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.14200725 0.02246715 0.03435217 0.03826940
## [2,] 0.05788695 0.11130782 0.03385411 0.03822718
## [3,] 0.02698434 0.09127622 0.03499628 0.14046081
## 
## , , 2, 4, 2
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.24304461 0.0384524 0.05879355 0.06549786
## [2,] 0.09907318 0.1905027 0.05794111 0.06542560
## [3,] 0.04618355 0.1562187 0.05989594 0.24039788
## 
## , , 3, 4, 2
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.11476624 0.01815732 0.02776245 0.03092825
## [2,] 0.04678259 0.08995583 0.02735993 0.03089412
## [3,] 0.02180798 0.07376685 0.02828301 0.11351645
## 
## , , 1, 1, 3
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.15859044 0.0250908 0.03836372 0.04273839
## [2,] 0.06464681 0.1243060 0.03780749 0.04269124
## [3,] 0.03013549 0.1019352 0.03908305 0.15686341
## 
## , , 2, 1, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7514013 0.1188802 0.1817672 0.2024944
## [2,] 0.3062965 0.5889618 0.1791318 0.2022710
## [3,] 0.1427819 0.4829688 0.1851754 0.7432186
## 
## , , 3, 1, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.6929750 0.1096365 0.1676337 0.1867492
## [2,] 0.2824800 0.5431662 0.1652032 0.1865431
## [3,] 0.1316797 0.4454148 0.1707768 0.6854286
## 
## , , 1, 2, 3
## 
##           [,1]       [,2]       [,3]       [,4]
## [1,] 0.3521250 0.05571016 0.08518058 0.09489385
## [2,] 0.1435380 0.27600191 0.08394556 0.09478915
## [3,] 0.0669111 0.22633100 0.08677774 0.34829044
## 
## , , 2, 2, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.6482323 0.1025577 0.1568102 0.1746915
## [2,] 0.2642414 0.5080961 0.1545367 0.1744988
## [3,] 0.1231777 0.4166562 0.1597504 0.6411731
## 
## , , 3, 2, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7722607 0.1221804 0.1868132 0.2081158
## [2,] 0.3147995 0.6053117 0.1841046 0.2078862
## [3,] 0.1467456 0.4963763 0.1903160 0.7638509
## 
## , , 1, 3, 3
## 
##           [,1]       [,2]       [,3]       [,4]
## [1,] 0.3126746 0.04946866 0.07563735 0.08426239
## [2,] 0.1274567 0.24507996 0.07454070 0.08416943
## [3,] 0.0594147 0.20097394 0.07705557 0.30926963
## 
## , , 2, 3, 3
## 
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.025270465 0.003998073 0.006113035 0.006810114
## [2,] 0.010301094 0.019807443 0.006024404 0.006802601
## [3,] 0.004801916 0.016242780 0.006227656 0.024995273
## 
## , , 3, 3, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7804125 0.1234701 0.1887852 0.2103126
## [2,] 0.3181224 0.6117012 0.1860480 0.2100806
## [3,] 0.1482946 0.5016159 0.1923249 0.7719139
## 
## , , 1, 4, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7949447 0.1257692 0.1923006 0.2142289
## [2,] 0.3240463 0.6230919 0.1895125 0.2139926
## [3,] 0.1510561 0.5109566 0.1959063 0.7862879
## 
## , , 2, 4, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.8614036 0.1362838 0.2083773 0.2321388
## [2,] 0.3511372 0.6751835 0.2053560 0.2318827
## [3,] 0.1636847 0.5536736 0.2122844 0.8520230
## 
## , , 3, 4, 3
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.6582556 0.1041435 0.1592349 0.1773927
## [2,] 0.2683272 0.5159525 0.1569262 0.1771970
## [3,] 0.1250823 0.4230987 0.1622206 0.6510872
## 
## , , 1, 1, 4
## 
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.030395434 0.004808901 0.007352788 0.008191237
## [2,] 0.012390204 0.023824485 0.007246181 0.008182200
## [3,] 0.005775766 0.019536891 0.007490654 0.030064431
## 
## , , 2, 1, 4
## 
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.009737340 0.001540557 0.002355505 0.002624107
## [2,] 0.003969268 0.007632301 0.002321353 0.002621211
## [3,] 0.001850298 0.006258748 0.002399671 0.009631301
## 
## , , 3, 1, 4
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7146821 0.1130708 0.1728847 0.1925990
## [2,] 0.2913285 0.5601806 0.1703781 0.1923865
## [3,] 0.1358045 0.4593673 0.1761263 0.7068993
## 
## , , 1, 2, 4
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.9323217 0.1475038 0.2255327 0.2512505
## [2,] 0.3800458 0.7307705 0.2222627 0.2509733
## [3,] 0.1771606 0.5992567 0.2297615 0.9221689
## 
## , , 2, 2, 4
## 
##            [,1]       [,2]      [,3]      [,4]
## [1,] 0.48551111 0.07681334 0.1174472 0.1308399
## [2,] 0.19791070 0.38055229 0.1157444 0.1306956
## [3,] 0.09225724 0.31206588 0.1196494 0.4802239
## 
## , , 3, 2, 4
## 
##            [,1]        [,2]       [,3]       [,4]
## [1,] 0.05487812 0.008682338 0.01327526 0.01478905
## [2,] 0.02237017 0.043014452 0.01308278 0.01477274
## [3,] 0.01042799 0.035273320 0.01352417 0.05428050
## 
## , , 1, 3, 4
## 
##            [,1]       [,2]      [,3]      [,4]
## [1,] 0.46388087 0.07339119 0.1122148 0.1250108
## [2,] 0.18909349 0.36359812 0.1105878 0.1248729
## [3,] 0.08814704 0.29816288 0.1143189 0.4588293
## 
## , , 2, 3, 4
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5355603 0.08473169 0.1295544 0.1443276
## [2,] 0.2183124 0.41978175 0.1276760 0.1441684
## [3,] 0.1017676 0.34423538 0.1319835 0.5297281
## 
## , , 3, 3, 4
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5792508 0.09164402 0.1401233 0.1561018
## [2,] 0.2361222 0.45402715 0.1380917 0.1559295
## [3,] 0.1100697 0.37231777 0.1427506 0.5729428
## 
## , , 1, 4, 4
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.10736174 0.01698584 0.02597127 0.02893282
## [2,] 0.04376427 0.08415206 0.02559472 0.02890089
## [3,] 0.02040097 0.06900756 0.02645824 0.10619259
## 
## , , 2, 4, 4
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.28051229 0.04438021 0.06785714 0.07559499
## [2,] 0.11434627 0.21987055 0.06687329 0.07551159
## [3,] 0.05330319 0.18030136 0.06912948 0.27745754
## 
## , , 3, 4, 4
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.9609428 0.1520320 0.2324562 0.2589636
## [2,] 0.3917127 0.7532041 0.2290859 0.2586779
## [3,] 0.1825992 0.6176531 0.2368148 0.9504782
## 
## , , 1, 1, 5
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.12540636 0.01984070 0.03033634 0.03379564
## [2,] 0.05111986 0.09829574 0.02989650 0.03375836
## [3,] 0.02382982 0.08060587 0.03090516 0.12404069
## 
## , , 2, 1, 5
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.27839132 0.04404465 0.06734407 0.07502342
## [2,] 0.11348169 0.21820810 0.06636766 0.07494064
## [3,] 0.05290016 0.17893810 0.06860679 0.27535967
## 
## , , 3, 1, 5
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5926914 0.09377047 0.1433746 0.1597238
## [2,] 0.2416010 0.46456210 0.1412959 0.1595476
## [3,] 0.1126237 0.38095679 0.1460629 0.5862370
## 
## , , 1, 2, 5
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.40920279 0.0647405 0.09898793 0.1102757
## [2,] 0.16680486 0.3207405 0.09755272 0.1101540
## [3,] 0.07775707 0.2630181 0.10084398 0.4047466
## 
## , , 2, 2, 5
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.6092760 0.09639434 0.1473865 0.1641932
## [2,] 0.2483614 0.47756141 0.1452496 0.1640121
## [3,] 0.1157751 0.39161667 0.1501500 0.6026410
## 
## , , 3, 2, 5
## 
##           [,1]       [,2]       [,3]      [,4]
## [1,] 0.3802898 0.06016614 0.09199376 0.1024839
## [2,] 0.1550190 0.29807796 0.09065996 0.1023709
## [3,] 0.0722630 0.24443411 0.09371867 0.3761485
## 
## , , 1, 3, 5
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.4987968 0.07891529 0.1206611 0.1344203
## [2,] 0.2033264 0.39096588 0.1189117 0.1342720
## [3,] 0.0947818 0.32060538 0.1229235 0.4933650
## 
## , , 2, 3, 5
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7331063 0.1159857 0.1773416 0.1975641
## [2,] 0.2988388 0.5746218 0.1747703 0.1973461
## [3,] 0.1393055 0.4712095 0.1806668 0.7251228
## 
## , , 3, 3, 5
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.7184572 0.1136680 0.1737979 0.1936163
## [2,] 0.2928674 0.5631396 0.1712780 0.1934027
## [3,] 0.1365219 0.4617937 0.1770567 0.7106333
## 
## , , 1, 4, 5
## 
##           [,1]       [,2]      [,3]      [,4]
## [1,] 0.5965025 0.09437343 0.1442965 0.1607509
## [2,] 0.2431545 0.46754930 0.1422044 0.1605735
## [3,] 0.1133479 0.38340640 0.1470021 0.5900066
## 
## , , 2, 4, 5
## 
##            [,1]       [,2]      [,3]      [,4]
## [1,] 0.47487806 0.07513107 0.1148751 0.1279744
## [2,] 0.19357631 0.37221791 0.1132095 0.1278332
## [3,] 0.09023674 0.30523140 0.1170290 0.4697067
## 
## , , 3, 4, 5
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.08276061 0.01309366 0.02002015 0.02230308
## [2,] 0.03373602 0.06486925 0.01972988 0.02227847
## [3,] 0.01572624 0.05319500 0.02039553 0.08185936
DelayedTensor::einsum('ij,klm->ijklm', darrC, darrE)
## <3 x 4 x 3 x 4 x 5> HDF5Array object of type "double":
## ,,1,1,1
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.8966756 0.1418642 0.2169097 0.2416443
## [2,] 0.3655152 0.7028303 0.2137648 0.2413777
## [3,] 0.1703871 0.5763449 0.2209768 0.8869109
## 
## ,,2,1,1
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.9090555 0.1438228 0.2199045 0.2449805
## [2,] 0.3705617 0.7125339 0.2167161 0.2447102
## [3,] 0.1727395 0.5843022 0.2240277 0.8991560
## 
## ,,3,1,1
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.29265915 0.04630198 0.07079552 0.07886844
## [2,] 0.11929774 0.22939147 0.06976907 0.07878143
## [3,] 0.05561134 0.18810885 0.07212295 0.28947212
## 
## ...
## 
## ,,1,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.59650246 0.09437343 0.14429654 0.16075089
## [2,] 0.24315452 0.46754930 0.14220441 0.16057354
## [3,] 0.11334791 0.38340640 0.14700213 0.59000662
## 
## ,,2,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.47487806 0.07513107 0.11487506 0.12797444
## [2,] 0.19357631 0.37221791 0.11320951 0.12783325
## [3,] 0.09023674 0.30523140 0.11702900 0.46970668
## 
## ,,3,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.08276061 0.01309366 0.02002015 0.02230308
## [2,] 0.03373602 0.06486925 0.01972988 0.02227847
## [3,] 0.01572624 0.05319500 0.02039553 0.08185936

Summation

If there is a vanishing subscript on the left or right side of ->, the summation is done for that subscript.

einsum::einsum('i->', arrA)
## [1] 1.403733
DelayedTensor::einsum('i->', darrA)
## <1> HDF5Array object of type "double":
##      [1] 
## 1.403733
einsum::einsum('ij->', arrC)
## [1] 5.237251
DelayedTensor::einsum('ij->', darrC)
## <1> HDF5Array object of type "double":
##      [1] 
## 5.237251
einsum::einsum('ijk->', arrE)
## [1] 32.61525
DelayedTensor::einsum('ijk->', darrE)
## <1> HDF5Array object of type "double":
##      [1] 
## 32.61525

Row-wise / Column-wise Summation

einsum::einsum('ij->i', arrC)
## [1] 1.608273 1.636628 1.992350
DelayedTensor::einsum('ij->i', darrC)
## <3> HDF5Array object of type "double":
##      [1]      [2]      [3] 
## 1.608273 1.636628 1.992350
einsum::einsum('ij->j', arrC)
## [1] 1.5389661 1.5265708 0.7000452 1.4716688
DelayedTensor::einsum('ij->j', darrC)
## <4> HDF5Array object of type "double":
##       [1]       [2]       [3]       [4] 
## 1.5389661 1.5265708 0.7000452 1.4716688

Mode-wise Vectorization

einsum::einsum('ijk->i', arrE)
## [1]  9.453345 11.098294 12.063607
DelayedTensor::einsum('ijk->i', darrE)
## <3> HDF5Array object of type "double":
##       [1]       [2]       [3] 
##  9.453345 11.098294 12.063607
einsum::einsum('ijk->j', arrE)
## [1] 7.654624 8.762761 9.229747 6.968114
DelayedTensor::einsum('ijk->j', darrE)
## <4> HDF5Array object of type "double":
##      [1]      [2]      [3]      [4] 
## 7.654624 8.762761 9.229747 6.968114
einsum::einsum('ijk->k', arrE)
## [1] 7.397498 7.088444 7.068190 5.351622 5.709492
DelayedTensor::einsum('ijk->k', darrE)
## <5> HDF5Array object of type "double":
##      [1]      [2]      [3]      [4]      [5] 
## 7.397498 7.088444 7.068190 5.351622 5.709492

Mode-wise Summation

These are the same as what the modeSum function does.

einsum::einsum('ijk->ij', arrE)
##          [,1]     [,2]     [,3]     [,4]
## [1,] 1.861128 2.556568 2.738169 2.297481
## [2,] 2.640678 3.464156 2.800264 2.193197
## [3,] 3.152818 2.742038 3.691315 2.477436
DelayedTensor::einsum('ijk->ij', darrE)
## <3 x 4> HDF5Matrix object of type "double":
##          [,1]     [,2]     [,3]     [,4]
## [1,] 1.861128 2.556568 2.738169 2.297481
## [2,] 2.640678 3.464156 2.800264 2.193197
## [3,] 3.152818 2.742038 3.691315 2.477436
einsum::einsum('ijk->jk', arrE)
##          [,1]      [,2]     [,3]      [,4]     [,5]
## [1,] 2.178412 1.9940256 1.664096 0.7835998 1.034490
## [2,] 1.711665 2.2298965 1.840217 1.5288728 1.452111
## [3,] 2.059465 2.3456435 1.161006 1.6388954 2.024737
## [4,] 1.447956 0.5188787 2.402871 1.4002539 1.198154
DelayedTensor::einsum('ijk->jk', darrE)
## <4 x 5> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 2.1784123 1.9940256 1.6640959 0.7835998 1.0344902
## [2,] 1.7116646 2.2298965 1.8402169 1.5288728 1.4521106
## [3,] 2.0594652 2.3456435 1.1610061 1.6388954 2.0247373
## [4,] 1.4479561 0.5188787 2.4028713 1.4002539 1.1981543
einsum::einsum('ijk->jk', arrE)
##          [,1]      [,2]     [,3]      [,4]     [,5]
## [1,] 2.178412 1.9940256 1.664096 0.7835998 1.034490
## [2,] 1.711665 2.2298965 1.840217 1.5288728 1.452111
## [3,] 2.059465 2.3456435 1.161006 1.6388954 2.024737
## [4,] 1.447956 0.5188787 2.402871 1.4002539 1.198154
DelayedTensor::einsum('ijk->jk', darrE)
## <4 x 5> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 2.1784123 1.9940256 1.6640959 0.7835998 1.0344902
## [2,] 1.7116646 2.2298965 1.8402169 1.5288728 1.4521106
## [3,] 2.0594652 2.3456435 1.1610061 1.6388954 2.0247373
## [4,] 1.4479561 0.5188787 2.4028713 1.4002539 1.1981543

Trace

If we take the diagonal elements of a matrix and add them together, we get trace.

einsum::einsum('ii->', arrB)
## [1] 0.2418079
DelayedTensor::einsum('ii->', darrB)
## <1> HDF5Array object of type "double":
##       [1] 
## 0.2418079

Permutation

By changing the order of the indices on the left and right side of ->, we can get a sorted array or DelayedArray.

einsum::einsum('ij->ji', arrB)
##            [,1]      [,2]       [,3]
## [1,] 0.05189427 0.5333371 0.32713827
## [2,] 0.15965106 0.1495867 0.56532566
## [3,] 0.41444442 0.9948574 0.04032693
DelayedTensor::einsum('ij->ji', darrB)
## <3 x 3> DelayedArray object of type "double":
##            [,1]       [,2]       [,3]
## [1,] 0.05189427 0.53333705 0.32713827
## [2,] 0.15965106 0.14958670 0.56532566
## [3,] 0.41444442 0.99485737 0.04032693
einsum::einsum('ijk->jki', arrD)
## , , 1
## 
##           [,1]      [,2]      [,3]
## [1,] 0.2126933 0.7808531 0.3927919
## [2,] 0.7725836 0.3832042 0.0156923
## [3,] 0.4120539 0.8265905 0.9371301
## 
## , , 2
## 
##           [,1]       [,2]       [,3]
## [1,] 0.2557103 0.47181315 0.08210511
## [2,] 0.6092896 0.99670521 0.88593970
## [3,] 0.1859749 0.05835422 0.28107832
## 
## , , 3
## 
##           [,1]      [,2]      [,3]
## [1,] 0.3387236 0.2518009 0.1545498
## [2,] 0.7366115 0.5530934 0.4070127
## [3,] 0.7865532 0.5580297 0.2246769
DelayedTensor::einsum('ijk->jki', darrD)
## <3 x 3 x 3> DelayedArray object of type "double":
## ,,1
##           [,1]      [,2]      [,3]
## [1,] 0.2126933 0.7808531 0.3927919
## [2,] 0.7725836 0.3832042 0.0156923
## [3,] 0.4120539 0.8265905 0.9371301
## 
## ,,2
##            [,1]       [,2]       [,3]
## [1,] 0.25571033 0.47181315 0.08210511
## [2,] 0.60928962 0.99670521 0.88593970
## [3,] 0.18597494 0.05835422 0.28107832
## 
## ,,3
##           [,1]      [,2]      [,3]
## [1,] 0.3387236 0.2518009 0.1545498
## [2,] 0.7366115 0.5530934 0.4070127
## [3,] 0.7865532 0.5580297 0.2246769

Multiplication + Summation

Some examples of combining Multiplication and Summation are shown below.

Inner Product (Squared Frobenius Norm)

Inner Product first calculate Hadamard Product and collapses it to 0D tensor (norm).

einsum::einsum('i,i->', arrA, arrA)
## [1] 0.9731916
DelayedTensor::einsum('i,i->', darrA, darrA)
## <1> HDF5Array object of type "double":
##       [1] 
## 0.9731916
einsum::einsum('ij,ij->', arrC, arrC)
## [1] 3.297989
DelayedTensor::einsum('ij,ij->', darrC, darrC)
## <1> HDF5Array object of type "double":
##      [1] 
## 3.297989
einsum::einsum('ijk,ijk->', arrE, arrE)
## [1] 22.32759
DelayedTensor::einsum('ijk,ijk->', darrE, darrE)
## <1> HDF5Array object of type "double":
##      [1] 
## 22.32759

Contracted Product

The inner product is an operation that eliminates all subscripts, while the outer product is an operation that leaves all subscripts intact. In the middle of the two, the operation that eliminates some subscripts while keeping others by summing them is called contracted product.

einsum::einsum('ijk,ijk->jk', arrE, arrE)
##           [,1]       [,2]      [,3]      [,4]      [,5]
## [1,] 1.8494377 1.34287226 1.1531318 0.5515677 0.4790609
## [2,] 1.1075024 1.75140280 1.2292348 1.1940716 0.7363923
## [3,] 1.4465089 1.87246904 0.7624335 0.9026392 1.4036537
## [4,] 0.7716072 0.09959038 1.9477212 1.0924080 0.6338891
DelayedTensor::einsum('ijk,ijk->jk', darrE, darrE)
## <4 x 5> HDF5Matrix object of type "double":
##            [,1]       [,2]       [,3]       [,4]       [,5]
## [1,] 1.84943772 1.34287226 1.15313180 0.55156771 0.47906089
## [2,] 1.10750238 1.75140280 1.22923483 1.19407159 0.73639229
## [3,] 1.44650889 1.87246904 0.76243350 0.90263915 1.40365373
## [4,] 0.77160716 0.09959038 1.94772117 1.09240795 0.63388905

Matrix Multiplication

Matrix Multiplication is considered a contracted product.

einsum::einsum('ij,jk->ik', arrC, t(arrC))
##           [,1]      [,2]      [,3]
## [1,] 1.0727910 0.6141237 0.5733207
## [2,] 0.6141237 0.8442169 0.8409150
## [3,] 0.5733207 0.8409150 1.3809808
DelayedTensor::einsum('ij,jk->ik', darrC, t(darrC))
## <3 x 3> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]
## [1,] 1.0727910 0.6141237 0.5733207
## [2,] 0.6141237 0.8442169 0.8409150
## [3,] 0.5733207 0.8409150 1.3809808

Multiplication + Permutation

Some examples of combining Multiplication and Permutation are shown below.

einsum::einsum('ij,ij->ji', arrC, arrC)
##            [,1]       [,2]       [,3]
## [1,] 0.92788111 0.15418160 0.03350386
## [2,] 0.02322562 0.57006275 0.38334214
## [3,] 0.05429748 0.05273439 0.05635275
## [4,] 0.06738677 0.06723816 0.90778209
DelayedTensor::einsum('ij,ij->ji', darrC, darrC)
## <4 x 3> HDF5Matrix object of type "double":
##            [,1]       [,2]       [,3]
## [1,] 0.92788111 0.15418160 0.03350386
## [2,] 0.02322562 0.57006275 0.38334214
## [3,] 0.05429748 0.05273439 0.05635275
## [4,] 0.06738677 0.06723816 0.90778209
einsum::einsum('ijk,ijk->jki', arrE, arrE)
## , , 1
## 
##            [,1]       [,2]       [,3]         [,4]      [,5]
## [1,] 0.86651949 0.36466631 0.02710576 0.0009956905 0.0169491
## [2,] 0.07614034 0.27289685 0.13362924 0.9367836212 0.1804616
## [3,] 0.59912204 0.40979324 0.10536417 0.2319105999 0.2681359
## [4,] 0.35294607 0.02173345 0.68105400 0.0124224366 0.3834707
## 
## , , 2
## 
##            [,1]       [,2]         [,3]         [,4]       [,5]
## [1,] 0.89061181 0.38165562 0.6084873856 0.0001021853 0.08352549
## [2,] 0.48876488 0.91307379 0.4528652981 0.2540422839 0.40006981
## [3,] 0.29130375 0.84136108 0.0006882309 0.3091181003 0.57921729
## [4,] 0.06887109 0.06366191 0.7996888330 0.0848030456 0.24303670
## 
## , , 3
## 
##            [,1]       [,2]      [,3]        [,4]        [,5]
## [1,] 0.09230641 0.59655032 0.5175386 0.550469831 0.378586290
## [2,] 0.54259715 0.56543216 0.6427403 0.003245683 0.155860858
## [3,] 0.55608310 0.62131472 0.6563811 0.361610454 0.556300490
## [4,] 0.34979000 0.01419502 0.4669783 0.995182471 0.007381677
DelayedTensor::einsum('ijk,ijk->jki', darrE, darrE)
## <4 x 5 x 3> HDF5Array object of type "double":
## ,,1
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 0.8665194940 0.3646663109 0.0271057650 0.0009956905 0.0169491048
## [2,] 0.0761403432 0.2728968521 0.1336292420 0.9367836212 0.1804616137
## [3,] 0.5991220386 0.4097932401 0.1053641669 0.2319105999 0.2681359460
## [4,] 0.3529460717 0.0217334525 0.6810539993 0.0124224366 0.3834706695
## 
## ,,2
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 0.8906118129 0.3816556245 0.6084873856 0.0001021853 0.0835254948
## [2,] 0.4887648841 0.9130737905 0.4528652981 0.2540422839 0.4000698145
## [3,] 0.2913037507 0.8413610772 0.0006882309 0.3091181003 0.5792172900
## [4,] 0.0688710941 0.0636619076 0.7996888330 0.0848030456 0.2430367046
## 
## ,,3
##             [,1]        [,2]        [,3]        [,4]        [,5]
## [1,] 0.092306413 0.596550320 0.517538649 0.550469831 0.378586290
## [2,] 0.542597151 0.565432162 0.642740295 0.003245683 0.155860858
## [3,] 0.556083104 0.621314721 0.656381099 0.361610454 0.556300490
## [4,] 0.349789997 0.014195019 0.466978338 0.995182471 0.007381677

Summation + Permutation

Some examples of combining Summation and Permutation are shown below.

einsum::einsum('ijk->ki', arrE)
##          [,1]     [,2]     [,3]
## [1,] 2.574928 2.444998 2.377572
## [2,] 1.913845 2.742902 2.431697
## [3,] 1.680050 2.373496 3.014644
## [4,] 1.592457 1.361328 2.397836
## [5,] 1.692065 2.175569 1.841858
DelayedTensor::einsum('ijk->ki', darrE)
## <5 x 3> HDF5Matrix object of type "double":
##          [,1]     [,2]     [,3]
## [1,] 2.574928 2.444998 2.377572
## [2,] 1.913845 2.742902 2.431697
## [3,] 1.680050 2.373496 3.014644
## [4,] 1.592457 1.361328 2.397836
## [5,] 1.692065 2.175569 1.841858

Multiplication + Summation + Permutation

Finally, we will show a more complex example, combining Multiplication, Summation, and Permutation.

einsum::einsum('i,ij,ijk,ijk,ji->jki',
    arrA, arrC, arrE, arrE, t(arrC))
## , , 1
## 
##             [,1]        [,2]        [,3]         [,4]        [,5]
## [1,] 0.669447688 0.281730556 0.020941123 0.0007692414 0.013094384
## [2,] 0.001472408 0.005277300 0.002584133 0.0181155937 0.003489781
## [3,] 0.027085755 0.018526374 0.004763417 0.0104844643 0.012122179
## [4,] 0.019802907 0.001219409 0.038212208 0.0006969913 0.021515564
## 
## , , 2
## 
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 0.0060203115 0.0025798959 4.113221e-03 6.907467e-07 0.0005646113
## [2,] 0.0122157637 0.0228205708 1.131852e-02 6.349312e-03 0.0099989964
## [3,] 0.0006735006 0.0019452451 1.591205e-06 7.146878e-04 0.0013391630
## [4,] 0.0002030256 0.0001876694 2.357408e-03 2.499915e-04 0.0007164496
## 
## , , 3
## 
##             [,1]        [,2]        [,3]        [,4]        [,5]
## [1,] 0.001630654 0.010538456 0.009142662 0.009724413 0.006687977
## [2,] 0.109672835 0.114288378 0.129914340 0.000656036 0.031503487
## [3,] 0.016523035 0.018461278 0.019503214 0.010744621 0.016529495
## [4,] 0.167426423 0.006794423 0.223518435 0.476342498 0.003533228
DelayedTensor::einsum('i,ij,ijk,ijk,ji->jki',
    darrA, darrC, darrE, darrE, t(darrC))
## <4 x 5 x 3> HDF5Array object of type "double":
## ,,1
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 0.6694476884 0.2817305560 0.0209411235 0.0007692414 0.0130943840
## [2,] 0.0014724078 0.0052773003 0.0025841326 0.0181155937 0.0034897806
## [3,] 0.0270857547 0.0185263743 0.0047634168 0.0104844643 0.0121221788
## [4,] 0.0198029067 0.0012194088 0.0382122084 0.0006969913 0.0215155643
## 
## ,,2
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 6.020311e-03 2.579896e-03 4.113221e-03 6.907467e-07 5.646113e-04
## [2,] 1.221576e-02 2.282057e-02 1.131852e-02 6.349312e-03 9.998996e-03
## [3,] 6.735006e-04 1.945245e-03 1.591205e-06 7.146878e-04 1.339163e-03
## [4,] 2.030256e-04 1.876694e-04 2.357408e-03 2.499915e-04 7.164496e-04
## 
## ,,3
##             [,1]        [,2]        [,3]        [,4]        [,5]
## [1,] 0.001630654 0.010538456 0.009142662 0.009724413 0.006687977
## [2,] 0.109672835 0.114288378 0.129914340 0.000656036 0.031503487
## [3,] 0.016523035 0.018461278 0.019503214 0.010744621 0.016529495
## [4,] 0.167426423 0.006794423 0.223518435 0.476342498 0.003533228

Create your original function by einsum

By using einsum and other DelayedTensor functions, it is possible to implement your original tensor calculation functions. It is intended to be applied to Delayed Arrays, which can scale to large-scale data since the calculation is performed internally by block processing.

For example, kronecker can be easily implmented by eimsum and other DelayedTensor functions4 (the kronecker function inside DelayedTensor has a more efficient implementation though).

darr1 <- DelayedArray(array(1:6, dim=c(2,3)))
darr2 <- DelayedArray(array(20:1, dim=c(4,5)))

mykronecker <- function(darr1, darr2){
    stopifnot((length(dim(darr1)) == 2) && (length(dim(darr2)) == 2))
    # Outer Product
    tmpdarr <- DelayedTensor::einsum('ij,kl->ikjl', darr1, darr2)
    # Reshape
    DelayedTensor::unfold(tmpdarr, row_idx=c(2,1), col_idx=c(4,3))
}

identical(as.array(DelayedTensor::kronecker(darr1, darr2)),
    as.array(mykronecker(darr1, darr2)))
## [1] TRUE

Session information

## R version 4.4.3 (2025-02-28)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Etc/UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] einsum_0.1.2              DelayedRandomArray_1.15.0
##  [3] HDF5Array_1.35.16         h5mread_0.99.4           
##  [5] rhdf5_2.51.2              DelayedArray_0.33.6      
##  [7] SparseArray_1.7.7         S4Arrays_1.7.3           
##  [9] abind_1.4-8               IRanges_2.41.3           
## [11] S4Vectors_0.45.4          MatrixGenerics_1.19.1    
## [13] matrixStats_1.5.0         BiocGenerics_0.53.6      
## [15] generics_0.1.3            Matrix_1.7-3             
## [17] DelayedTensor_1.13.0      BiocStyle_2.35.0         
## 
## loaded via a namespace (and not attached):
##  [1] dqrng_0.4.1         sass_0.4.9          lattice_0.22-6     
##  [4] digest_0.6.37       evaluate_1.0.3      grid_4.4.3         
##  [7] fastmap_1.2.0       jsonlite_2.0.0      BiocManager_1.30.25
## [10] codetools_0.2-20    jquerylib_0.1.4     cli_3.6.4          
## [13] rlang_1.1.5         crayon_1.5.3        XVector_0.47.2     
## [16] cachem_1.1.0        yaml_2.3.10         tools_4.4.3        
## [19] beachmat_2.23.7     parallel_4.4.3      BiocParallel_1.41.2
## [22] Rhdf5lib_1.29.2     rsvd_1.0.5          buildtools_1.0.0   
## [25] R6_2.6.1            lifecycle_1.0.4     BiocSingular_1.23.0
## [28] irlba_2.3.5.1       ScaledMatrix_1.15.0 rTensor_1.4.8      
## [31] bslib_0.9.0         Rcpp_1.0.14         xfun_0.51          
## [34] sys_3.4.3           knitr_1.50          rhdf5filters_1.19.2
## [37] htmltools_0.5.8.1   rmarkdown_2.29      maketools_1.3.2    
## [40] compiler_4.4.3