4. Einsum operation by DelayedTensor

Authors: Koki Tsuyuzaki [aut, cre]
Last modified: 2026-11-01 13:28:51.79401
Compiled: Sun Nov 1 13:31:29 2026

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.3746165 0.1394404 0.1190596
DelayedTensor::einsum('ii->i', darrB)
## <3> HDF5Array object of type "double":
##       [1]       [2]       [3] 
## 0.3746165 0.1394404 0.1190596
einsum::einsum('iii->i', arrD)
## [1] 0.2523185 0.8944236 0.6480896
DelayedTensor::einsum('iii->i', darrD)
## <3> HDF5Array object of type "double":
##       [1]       [2]       [3] 
## 0.2523185 0.8944236 0.6480896

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.79810117 0.01637126 0.20062847
DelayedTensor::einsum('i,i->i', darrA, darrA)
## <3> HDF5Array object of type "double":
##        [1]        [2]        [3] 
## 0.79810117 0.01637126 0.20062847
einsum::einsum('ij,ij->ij', arrC, arrC)
##             [,1]      [,2]       [,3]       [,4]
## [1,] 0.378039680 0.8406767 0.52642242 0.17798129
## [2,] 0.041400176 0.3759125 0.61229702 0.06373679
## [3,] 0.003958779 0.2384336 0.01968263 0.03946995
DelayedTensor::einsum('ij,ij->ij', darrC, darrC)
## <3 x 4> HDF5Matrix object of type "double":
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.378039680 0.840676677 0.526422419 0.177981290
## [2,] 0.041400176 0.375912480 0.612297024 0.063736795
## [3,] 0.003958779 0.238433551 0.019682633 0.039469945
einsum::einsum('ijk,ijk->ijk', arrE, arrE)
## , , 1
## 
##            [,1]       [,2]       [,3]      [,4]
## [1,] 0.85780699 0.04949809 0.13681695 0.5126100
## [2,] 0.62473904 0.98280217 0.09019006 0.6168342
## [3,] 0.01978785 0.08733516 0.29459740 0.1567408
## 
## , , 2
## 
##             [,1]        [,2]       [,3]      [,4]
## [1,] 0.007851121 0.961764375 0.04378452 0.1646552
## [2,] 0.803115643 0.003532964 0.65498952 0.1767910
## [3,] 0.130957597 0.414920378 0.52695962 0.4867821
## 
## , , 3
## 
##           [,1]        [,2]      [,3]      [,4]
## [1,] 0.1947527 0.007423033 0.1871045 0.1908039
## [2,] 0.1273842 0.335033210 0.6977343 0.2621435
## [3,] 0.6382511 0.661916933 0.7028327 0.3387622
## 
## , , 4
## 
##           [,1]       [,2]       [,3]       [,4]
## [1,] 0.5704766 0.09715478 0.11142782 0.07362350
## [2,] 0.2413872 0.04850522 0.02408952 0.11541341
## [3,] 0.6086772 0.26625726 0.95678142 0.09397323
## 
## , , 5
## 
##           [,1]      [,2]       [,3]       [,4]
## [1,] 0.1831780 0.2663996 0.65944666 0.06025528
## [2,] 0.6376869 0.7453401 0.09882863 0.08079029
## [3,] 0.4323383 0.9037981 0.86127776 0.07219297
DelayedTensor::einsum('ijk,ijk->ijk', darrE, darrE)
## <3 x 4 x 5> HDF5Array object of type "double":
## ,,1
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.85780699 0.04949809 0.13681695 0.51261005
## [2,] 0.62473904 0.98280217 0.09019006 0.61683422
## [3,] 0.01978785 0.08733516 0.29459740 0.15674076
## 
## ,,2
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.007851121 0.961764375 0.043784521 0.164655249
## [2,] 0.803115643 0.003532964 0.654989522 0.176791022
## [3,] 0.130957597 0.414920378 0.526959616 0.486782077
## 
## ,,3
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.194752744 0.007423033 0.187104550 0.190803943
## [2,] 0.127384166 0.335033210 0.697734292 0.262143527
## [3,] 0.638251109 0.661916933 0.702832748 0.338762155
## 
## ,,4
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.57047663 0.09715478 0.11142782 0.07362350
## [2,] 0.24138716 0.04850522 0.02408952 0.11541341
## [3,] 0.60867718 0.26625726 0.95678142 0.09397323
## 
## ,,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.18317797 0.26639958 0.65944666 0.06025528
## [2,] 0.63768687 0.74534008 0.09882863 0.08079029
## [3,] 0.43233832 0.90379813 0.86127776 0.07219297

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.7981012 0.11430627 0.40015224
## [2,] 0.1143063 0.01637126 0.05731092
## [3,] 0.4001522 0.05731092 0.20062847
DelayedTensor::einsum('i,j->ij', darrA, darrA)
## <3 x 3> HDF5Matrix object of type "double":
##            [,1]       [,2]       [,3]
## [1,] 0.79810117 0.11430627 0.40015224
## [2,] 0.11430627 0.01637126 0.05731092
## [3,] 0.40015224 0.05731092 0.20062847
einsum::einsum('ij,klm->ijklm', arrC, arrE)
## , , 1, 1, 1
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.56946034 0.8491986 0.6719887 0.3907347
## [2,] 0.18844989 0.5678559 0.7247294 0.2338244
## [3,] 0.05827408 0.4522499 0.1299381 0.1840043
## 
## , , 2, 1, 1
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.48597958 0.7247093 0.5734777 0.3334544
## [2,] 0.16082384 0.4846104 0.6184867 0.1995466
## [3,] 0.04973132 0.3859517 0.1108896 0.1570300
## 
## , , 3, 1, 1
## 
##             [,1]       [,2]       [,3]       [,4]
## [1,] 0.086490408 0.12897744 0.10206256 0.05934531
## [2,] 0.028622024 0.08624673 0.11007288 0.03551357
## [3,] 0.008850746 0.06868833 0.01973517 0.02794683
## 
## , , 1, 2, 1
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.13679269 0.2039899 0.16142150 0.09386018
## [2,] 0.04526842 0.1364073 0.17409058 0.05616805
## [3,] 0.01399829 0.1086370 0.03121302 0.04420053
## 
## , , 2, 2, 1
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.60953935 0.9089658 0.7192837 0.4182349
## [2,] 0.20171312 0.6078220 0.7757363 0.2502812
## [3,] 0.06237545 0.4840795 0.1390832 0.1969547
## 
## , , 3, 2, 1
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.18170349 0.2709624 0.21441825 0.12467568
## [2,] 0.06013062 0.1811915 0.23124675 0.07460874
## [3,] 0.01859410 0.1443040 0.04146066 0.05871213
## 
## , , 1, 3, 1
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.22742523 0.3391442 0.26837196 0.15604761
## [2,] 0.07526118 0.2267845 0.28943499 0.09338241
## [3,] 0.02327290 0.1806149 0.05189333 0.07348576
## 
## , , 2, 3, 1
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.18464945 0.2753555 0.21789463 0.12669705
## [2,] 0.06110552 0.1841292 0.23499597 0.07581837
## [3,] 0.01889557 0.1466436 0.04213286 0.05966403
## 
## , , 3, 3, 1
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.33372070 0.4976557 0.39380538 0.2289821
## [2,] 0.11043724 0.3327805 0.42471297 0.1370281
## [3,] 0.03415034 0.2650319 0.07614757 0.1078320
## 
## , , 1, 4, 1
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.44021238 0.6564597 0.5194703 0.3020513
## [2,] 0.14567823 0.4389721 0.5602407 0.1807543
## [3,] 0.04504786 0.3496047 0.1004466 0.1422417
## 
## , , 2, 4, 1
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.48289524 0.7201098 0.5698380 0.3313381
## [2,] 0.15980315 0.4815347 0.6145614 0.1982802
## [3,] 0.04941569 0.3835022 0.1101858 0.1560334
## 
## , , 3, 4, 1
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.24342191 0.3629990 0.28724876 0.16702372
## [2,] 0.08055492 0.2427361 0.30979332 0.09995076
## [3,] 0.02490988 0.1933191 0.05554341 0.07865462
## 
## , , 1, 1, 2
## 
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.05447968 0.08124195 0.06428846 0.03738118
## [2,] 0.01802880 0.05432618 0.06933410 0.02236974
## [3,] 0.00557502 0.04326627 0.01243104 0.01760350
## 
## , , 2, 1, 2
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.55100779 0.8216816 0.6502139 0.3780735
## [2,] 0.18234344 0.5494554 0.7012455 0.2262477
## [3,] 0.05638579 0.4375954 0.1257276 0.1780419
## 
## , , 3, 1, 2
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.22250206 0.3318026 0.26256240 0.15266958
## [2,] 0.07363197 0.2218752 0.28316947 0.09136092
## [3,] 0.02276911 0.1767051 0.05076997 0.07189499
## 
## , , 1, 2, 2
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.60298018 0.8991846 0.7115436 0.4137343
## [2,] 0.19954251 0.6012813 0.7673887 0.2475879
## [3,] 0.06170424 0.4788704 0.1375865 0.1948353
## 
## , , 2, 2, 2
## 
##             [,1]       [,2]        [,3]       [,4]
## [1,] 0.036545867 0.05449844 0.043125760 0.02507591
## [2,] 0.012094020 0.03644290 0.046510462 0.01500599
## [3,] 0.003739816 0.02902373 0.008338946 0.01180872
## 
## , , 3, 2, 2
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.39605097 0.5906047 0.46735788 0.2717500
## [2,] 0.13106402 0.3949351 0.50403821 0.1626213
## [3,] 0.04052873 0.3145329 0.09036994 0.1279722
## 
## , , 1, 3, 2
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.12865569 0.1918557 0.15181948 0.08827698
## [2,] 0.04257566 0.1282932 0.16373494 0.05282693
## [3,] 0.01316561 0.1021748 0.02935634 0.04157130
## 
## , , 2, 3, 2
## 
##           [,1]      [,2]      [,3]      [,4]
## [1,] 0.4976063 0.7420474 0.5871977 0.3414321
## [2,] 0.1646714 0.4962043 0.6332836 0.2043207
## [3,] 0.0509211 0.3951854 0.1135426 0.1607868
## 
## , , 3, 3, 2
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.44633132 0.6655844 0.5266909 0.3062498
## [2,] 0.14770315 0.4450738 0.5680280 0.1832668
## [3,] 0.04567403 0.3544642 0.1018428 0.1442188
## 
## , , 1, 4, 2
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.24949192 0.3720508 0.29441164 0.17118865
## [2,] 0.08256365 0.2487890 0.31751838 0.10244314
## [3,] 0.02553104 0.1981397 0.05692845 0.08061596
## 
## , , 2, 4, 2
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.25852277 0.3855179 0.30506845 0.17738516
## [2,] 0.08555220 0.2577944 0.32901158 0.10615127
## [3,] 0.02645518 0.2053117 0.05898909 0.08353402
## 
## , , 3, 4, 2
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.42897895 0.6397080 0.50621438 0.2943435
## [2,] 0.14196078 0.4277703 0.54594434 0.1761418
## [3,] 0.04389832 0.3406834 0.09788336 0.1386119
## 
## , , 1, 1, 3
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.27133792 0.4046283 0.32019090 0.18617826
## [2,] 0.08979308 0.2705734 0.34532090 0.11141327
## [3,] 0.02776658 0.2154892 0.06191322 0.08767485
## 
## , , 2, 1, 3
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.21944537 0.3272444 0.25895536 0.15057224
## [2,] 0.07262043 0.2188271 0.27927933 0.09010582
## [3,] 0.02245631 0.1742775 0.05007251 0.07090731
## 
## , , 3, 1, 3
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.49120693 0.7325045 0.5796462 0.3370412
## [2,] 0.16255371 0.4898230 0.6251394 0.2016930
## [3,] 0.05026624 0.3901032 0.1120824 0.1587190
## 
## , , 1, 2, 3
## 
##             [,1]       [,2]       [,3]       [,4]
## [1,] 0.052973588 0.07899602 0.06251121 0.03634778
## [2,] 0.017530399 0.05282434 0.06741736 0.02175133
## [3,] 0.005420899 0.04207018 0.01208738 0.01711685
## 
## , , 2, 2, 3
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.35588741 0.5307114 0.41996309 0.2441918
## [2,] 0.11777281 0.3548847 0.45292366 0.1461299
## [3,] 0.03641871 0.2826361 0.08120552 0.1149945
## 
## , , 3, 2, 3
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.50023081 0.7459612 0.5902948 0.3432329
## [2,] 0.16553996 0.4988214 0.6366237 0.2053983
## [3,] 0.05118968 0.3972697 0.1141414 0.1616349
## 
## , , 1, 3, 3
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.26595666 0.3966036 0.31384077 0.18248591
## [2,] 0.08801228 0.2652073 0.33847239 0.10920368
## [3,] 0.02721591 0.2112155 0.06068534 0.08593606
## 
## , , 2, 3, 3
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.51358665 0.7658779 0.6060553 0.3523970
## [2,] 0.16995977 0.5121397 0.6536212 0.2108823
## [3,] 0.05255641 0.4078765 0.1171889 0.1659504
## 
## , , 3, 3, 3
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.51545967 0.7686710 0.6082655 0.3536822
## [2,] 0.17057960 0.5140074 0.6560049 0.2116514
## [3,] 0.05274808 0.4093640 0.1176163 0.1665556
## 
## , , 1, 4, 3
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.26857301 0.4005052 0.31692818 0.18428112
## [2,] 0.08887810 0.2678163 0.34180212 0.11027798
## [3,] 0.02748364 0.2132934 0.06128233 0.08678146
## 
## , , 2, 4, 3
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.31480257 0.4694443 0.37148113 0.2160015
## [2,] 0.10417672 0.3139156 0.40063662 0.1292602
## [3,] 0.03221441 0.2500076 0.07183088 0.1017192
## 
## , , 3, 4, 3
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.35786246 0.5336567 0.42229373 0.2455470
## [2,] 0.11842640 0.3568542 0.45543722 0.1469409
## [3,] 0.03662082 0.2842046 0.08165618 0.1156327
## 
## , , 1, 1, 4
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.46439509 0.6925218 0.5480070 0.3186443
## [2,] 0.15368095 0.4630867 0.5910170 0.1906839
## [3,] 0.04752253 0.3688099 0.1059645 0.1500556
## 
## , , 2, 1, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.30208265 0.4504759 0.35647105 0.20727373
## [2,] 0.09996735 0.3012315 0.38444849 0.12403727
## [3,] 0.03091276 0.2399058 0.06892848 0.09760911
## 
## , , 3, 1, 4
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.47969170 0.7153326 0.5660577 0.3291400
## [2,] 0.15874301 0.4783402 0.6104844 0.1969648
## [3,] 0.04908787 0.3809581 0.1094549 0.1549982
## 
## , , 1, 2, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.19164646 0.2857897 0.22615140 0.13149804
## [2,] 0.06342102 0.1911065 0.24390077 0.07869139
## [3,] 0.01961159 0.1522004 0.04372942 0.06192491
## 
## , , 2, 2, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.13541380 0.2019337 0.15979435 0.09291405
## [2,] 0.04481210 0.1350323 0.17233572 0.05560186
## [3,] 0.01385718 0.1075420 0.03089839 0.04375498
## 
## , , 3, 2, 4
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.31726300 0.4731134 0.37438455 0.2176897
## [2,] 0.10499094 0.3163691 0.40376791 0.1302704
## [3,] 0.03246619 0.2519616 0.07239229 0.1025142
## 
## , , 1, 3, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.20524165 0.3060633 0.24219435 0.14082637
## [2,] 0.06792004 0.2046634 0.26120283 0.08427367
## [3,] 0.02100281 0.1629973 0.04683154 0.06631779
## 
## , , 2, 3, 4
## 
##             [,1]       [,2]       [,3]       [,4]
## [1,] 0.095429517 0.14230774 0.11261110 0.06547887
## [2,] 0.031580218 0.09516065 0.12144932 0.03918403
## [3,] 0.009765504 0.07578752 0.02177487 0.03083524
## 
## , , 3, 3, 4
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.60141611 0.8968522 0.7096980 0.4126611
## [2,] 0.19902492 0.5997217 0.7653982 0.2469457
## [3,] 0.06154418 0.4776283 0.1372297 0.1943299
## 
## , , 1, 4, 4
## 
##            [,1]      [,2]      [,3]       [,4]
## [1,] 0.16683107 0.2487842 0.1968681 0.11447098
## [2,] 0.05520893 0.1663610 0.2123192 0.06850202
## [3,] 0.01707218 0.1324927 0.0380671 0.05390655
## 
## , , 2, 4, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.20887998 0.3114889 0.24648774 0.14332281
## [2,] 0.06912406 0.2082915 0.26583319 0.08576760
## [3,] 0.02137513 0.1658868 0.04766172 0.06749341
## 
## , , 3, 4, 4
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.18848238 0.2810713 0.22241766 0.12932701
## [2,] 0.06237394 0.1879513 0.23987398 0.07739220
## [3,] 0.01928780 0.1496876 0.04300745 0.06090253
## 
## , , 1, 1, 5
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.26315117 0.3924200 0.31053017 0.18056093
## [2,] 0.08708387 0.2624098 0.33490196 0.10805173
## [3,] 0.02692882 0.2089875 0.06004519 0.08502955
## 
## , , 2, 1, 5
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.49098975 0.7321806 0.5793899 0.3368922
## [2,] 0.16248184 0.4896064 0.6248630 0.2016039
## [3,] 0.05024402 0.3899307 0.1120328 0.1586489
## 
## , , 3, 1, 5
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.40427842 0.6028737 0.47706664 0.2773953
## [2,] 0.13378671 0.4031394 0.51450896 0.1659996
## [3,] 0.04137066 0.3210669 0.09224726 0.1306307
## 
## , , 1, 2, 5
## 
##            [,1]      [,2]       [,3]      [,4]
## [1,] 0.31734778 0.4732398 0.37448460 0.2177479
## [2,] 0.10501900 0.3164537 0.40387581 0.1303052
## [3,] 0.03247487 0.2520290 0.07241164 0.1025416
## 
## , , 2, 2, 5
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.53081835 0.7915744 0.6263894 0.3642205
## [2,] 0.17566221 0.5293228 0.6755513 0.2179578
## [3,] 0.05431976 0.4215615 0.1211208 0.1715183
## 
## , , 3, 2, 5
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.58452678 0.8716662 0.6897678 0.4010725
## [2,] 0.19343578 0.5828799 0.7439038 0.2400108
## [3,] 0.05981586 0.4642152 0.1333759 0.1888726
## 
## , , 1, 3, 5
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.49929651 0.7445679 0.5891922 0.3425918
## [2,] 0.16523077 0.4978898 0.6354347 0.2050147
## [3,] 0.05109407 0.3965277 0.1139283 0.1613330
## 
## , , 2, 3, 5
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.19329031 0.2882411 0.22809122 0.13262597
## [2,] 0.06396501 0.1927457 0.24599284 0.07936637
## [3,] 0.01977981 0.1535059 0.04410451 0.06245607
## 
## , , 3, 3, 5
## 
##            [,1]      [,2]      [,3]      [,4]
## [1,] 0.57061122 0.8509149 0.6733468 0.3915244
## [2,] 0.18883075 0.5690036 0.7261941 0.2342970
## [3,] 0.05839185 0.4531639 0.1302007 0.1843762
## 
## , , 1, 4, 5
## 
##            [,1]      [,2]      [,3]       [,4]
## [1,] 0.15092676 0.2250671 0.1781003 0.10355826
## [2,] 0.04994576 0.1505015 0.1920784 0.06197160
## [3,] 0.01544465 0.1198619 0.0344381 0.04876754
## 
## , , 2, 4, 5
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.17476252 0.2606118 0.20622760 0.11991314
## [2,] 0.05783366 0.1742701 0.22241326 0.07175872
## [3,] 0.01788382 0.1387916 0.03987688 0.05646936
## 
## , , 3, 4, 5
## 
##            [,1]      [,2]       [,3]       [,4]
## [1,] 0.16520232 0.2463553 0.19494614 0.11335342
## [2,] 0.05466993 0.1647369 0.21024638 0.06783324
## [3,] 0.01690550 0.1311992 0.03769546 0.05338026
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.56946034 0.84919864 0.67198871 0.39073469
## [2,] 0.18844989 0.56785593 0.72472937 0.23382444
## [3,] 0.05827408 0.45224989 0.12993806 0.18400433
## 
## ,,2,1,1
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.48597958 0.72470928 0.57347767 0.33345444
## [2,] 0.16082384 0.48461036 0.61848675 0.19954665
## [3,] 0.04973132 0.38595174 0.11088963 0.15702998
## 
## ,,3,1,1
##             [,1]        [,2]        [,3]        [,4]
## [1,] 0.086490408 0.128977440 0.102062556 0.059345313
## [2,] 0.028622024 0.086246727 0.110072879 0.035513572
## [3,] 0.008850746 0.068688326 0.019735169 0.027946828
## 
## ...
## 
## ,,1,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.15092676 0.22506713 0.17810034 0.10355826
## [2,] 0.04994576 0.15050154 0.19207845 0.06197160
## [3,] 0.01544465 0.11986193 0.03443810 0.04876754
## 
## ,,2,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.17476252 0.26061181 0.20622760 0.11991314
## [2,] 0.05783366 0.17427014 0.22241326 0.07175872
## [3,] 0.01788382 0.13879163 0.03987688 0.05646936
## 
## ,,3,4,5
##            [,1]       [,2]       [,3]       [,4]
## [1,] 0.16520232 0.24635532 0.19494614 0.11335342
## [2,] 0.05466993 0.16473687 0.21024638 0.06783324
## [3,] 0.01690550 0.13119918 0.03769546 0.05338026

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.469231
DelayedTensor::einsum('i->', darrA)
## <1> HDF5Array object of type "double":
##      [1] 
## 1.469231
einsum::einsum('ij->', arrC)
## [1] 5.420885
DelayedTensor::einsum('ij->', darrC)
## <1> HDF5Array object of type "double":
##      [1] 
## 5.420885
einsum::einsum('ijk->', arrE)
## [1] 32.01556
DelayedTensor::einsum('ijk->', darrE)
## <1> HDF5Array object of type "double":
##      [1] 
## 32.01556

Row-wise / Column-wise Summation

einsum::einsum('ij->i', arrC)
## [1] 2.6791616 1.8515429 0.8901807
DelayedTensor::einsum('ij->i', darrC)
## <3> HDF5Array object of type "double":
##       [1]       [2]       [3] 
## 2.6791616 1.8515429 0.8901807
einsum::einsum('ij->j', arrC)
## [1] 0.8812385 2.0182978 1.6483386 0.8730102
DelayedTensor::einsum('ij->j', darrC)
## <4> HDF5Array object of type "double":
##       [1]       [2]       [3]       [4] 
## 0.8812385 2.0182978 1.6483386 0.8730102

Mode-wise Vectorization

einsum::einsum('ijk->i', arrE)
## [1]  8.98948 10.80287 12.22321
DelayedTensor::einsum('ijk->i', darrE)
## <3> HDF5Array object of type "double":
##      [1]      [2]      [3] 
##  8.98948 10.80287 12.22321
einsum::einsum('ijk->j', arrE)
## [1] 8.711889 8.050298 8.585318 6.668050
DelayedTensor::einsum('ijk->j', darrE)
## <4> HDF5Array object of type "double":
##      [1]      [2]      [3]      [4] 
## 8.711889 8.050298 8.585318 6.668050
einsum::einsum('ijk->k', arrE)
## [1] 6.476856 6.299354 6.712739 5.459506 7.067100
DelayedTensor::einsum('ijk->k', darrE)
## <5> HDF5Array object of type "double":
##      [1]      [2]      [3]      [4]      [5] 
## 6.476856 6.299354 6.712739 5.459506 7.067100

Mode-wise Summation

These are the same as what the modeSum function does.

einsum::einsum('ijk->ij', arrE)
##          [,1]     [,2]     [,3]     [,4]
## [1,] 2.639385 2.117170 2.157562 2.075362
## [2,] 3.333345 2.713193 2.414514 2.341815
## [3,] 2.739158 3.219935 4.013242 2.250873
DelayedTensor::einsum('ijk->ij', darrE)
## <3 x 4> HDF5Matrix object of type "double":
##          [,1]     [,2]     [,3]     [,4]
## [1,] 2.639385 2.117170 2.157562 2.075362
## [2,] 3.333345 2.713193 2.414514 2.341815
## [3,] 2.739158 3.219935 4.013242 2.250873
einsum::einsum('ijk->jk', arrE)
##          [,1]     [,2]     [,3]      [,4]      [,5]
## [1,] 1.857252 1.346654 1.597123 2.0267884 1.8840703
## [2,] 1.509371 1.684278 1.478560 1.0479368 2.3301529
## [3,] 1.212973 1.744482 2.106212 1.4671681 2.0544839
## [4,] 1.897261 1.523940 1.530843 0.9176125 0.7983933
DelayedTensor::einsum('ijk->jk', darrE)
## <4 x 5> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 1.8572523 1.3466544 1.5971234 2.0267884 1.8840703
## [2,] 1.5093707 1.6842777 1.4785603 1.0479368 2.3301529
## [3,] 1.2129726 1.7444816 2.1062120 1.4671681 2.0544839
## [4,] 1.8972608 1.5239403 1.5308434 0.9176125 0.7983933
einsum::einsum('ijk->jk', arrE)
##          [,1]     [,2]     [,3]      [,4]      [,5]
## [1,] 1.857252 1.346654 1.597123 2.0267884 1.8840703
## [2,] 1.509371 1.684278 1.478560 1.0479368 2.3301529
## [3,] 1.212973 1.744482 2.106212 1.4671681 2.0544839
## [4,] 1.897261 1.523940 1.530843 0.9176125 0.7983933
DelayedTensor::einsum('ijk->jk', darrE)
## <4 x 5> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 1.8572523 1.3466544 1.5971234 2.0267884 1.8840703
## [2,] 1.5093707 1.6842777 1.4785603 1.0479368 2.3301529
## [3,] 1.2129726 1.7444816 2.1062120 1.4671681 2.0544839
## [4,] 1.8972608 1.5239403 1.5308434 0.9176125 0.7983933

Trace

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

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

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.3746165 0.6230150 0.2327503
## [2,] 0.4232139 0.1394404 0.4231329
## [3,] 0.5321146 0.6328551 0.1190596
DelayedTensor::einsum('ij->ji', darrB)
## <3 x 3> DelayedArray object of type "double":
##           [,1]      [,2]      [,3]
## [1,] 0.3746165 0.6230150 0.2327503
## [2,] 0.4232139 0.1394404 0.4231329
## [3,] 0.5321146 0.6328551 0.1190596
einsum::einsum('ijk->jki', arrD)
## , , 1
## 
##           [,1]      [,2]      [,3]
## [1,] 0.2523185 0.4968733 0.8549141
## [2,] 0.2471870 0.8804747 0.8799568
## [3,] 0.6559243 0.9029095 0.1370134
## 
## , , 2
## 
##           [,1]       [,2]       [,3]
## [1,] 0.2765141 0.20857575 0.58602582
## [2,] 0.7248029 0.89442363 0.06776581
## [3,] 0.4785199 0.05611782 0.69619877
## 
## , , 3
## 
##           [,1]       [,2]      [,3]
## [1,] 0.5913634 0.08046751 0.2625424
## [2,] 0.3764730 0.25905577 0.2660438
## [3,] 0.2013190 0.03637305 0.6480896
DelayedTensor::einsum('ijk->jki', darrD)
## <3 x 3 x 3> DelayedArray object of type "double":
## ,,1
##           [,1]      [,2]      [,3]
## [1,] 0.2523185 0.4968733 0.8549141
## [2,] 0.2471870 0.8804747 0.8799568
## [3,] 0.6559243 0.9029095 0.1370134
## 
## ,,2
##            [,1]       [,2]       [,3]
## [1,] 0.27651411 0.20857575 0.58602582
## [2,] 0.72480289 0.89442363 0.06776581
## [3,] 0.47851994 0.05611782 0.69619877
## 
## ,,3
##            [,1]       [,2]       [,3]
## [1,] 0.59136344 0.08046751 0.26254240
## [2,] 0.37647304 0.25905577 0.26604380
## [3,] 0.20131898 0.03637305 0.64808957

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] 1.015101
DelayedTensor::einsum('i,i->', darrA, darrA)
## <1> HDF5Array object of type "double":
##      [1] 
## 1.015101
einsum::einsum('ij,ij->', arrC, arrC)
## [1] 3.318011
DelayedTensor::einsum('ij,ij->', darrC, darrC)
## <1> HDF5Array object of type "double":
##      [1] 
## 3.318011
einsum::einsum('ijk,ijk->', arrE, arrE)
## [1] 21.3593
DelayedTensor::einsum('ijk,ijk->', darrE, darrE)
## <1> HDF5Array object of type "double":
##     [1] 
## 21.3593

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.5023339 0.9419244 0.9603880 1.4205410 1.2532032
## [2,] 1.1196354 1.3802177 1.0043732 0.4119173 1.9155378
## [3,] 0.5216044 1.2257337 1.5876716 1.0922988 1.6195530
## [4,] 1.2861850 0.8282283 0.7917096 0.2830101 0.2132385
DelayedTensor::einsum('ijk,ijk->jk', darrE, darrE)
## <4 x 5> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 1.5023339 0.9419244 0.9603880 1.4205410 1.2532032
## [2,] 1.1196354 1.3802177 1.0043732 0.4119173 1.9155378
## [3,] 0.5216044 1.2257337 1.5876716 1.0922988 1.6195530
## [4,] 1.2861850 0.8282283 0.7917096 0.2830101 0.2132385

Matrix Multiplication

Matrix Multiplication is considered a contracted product.

einsum::einsum('ij,jk->ik', arrC, t(arrC))
##           [,1]      [,2]      [,3]
## [1,] 1.9231201 1.3615073 0.6720026
## [2,] 1.3615073 1.0933465 0.4721216
## [3,] 0.6720026 0.4721216 0.3015449
DelayedTensor::einsum('ij,jk->ik', darrC, t(darrC))
## <3 x 3> HDF5Matrix object of type "double":
##           [,1]      [,2]      [,3]
## [1,] 1.9231201 1.3615073 0.6720026
## [2,] 1.3615073 1.0933465 0.4721216
## [3,] 0.6720026 0.4721216 0.3015449

Multiplication + Permutation

Some examples of combining Multiplication and Permutation are shown below.

einsum::einsum('ij,ij->ji', arrC, arrC)
##           [,1]       [,2]        [,3]
## [1,] 0.3780397 0.04140018 0.003958779
## [2,] 0.8406767 0.37591248 0.238433551
## [3,] 0.5264224 0.61229702 0.019682633
## [4,] 0.1779813 0.06373679 0.039469945
DelayedTensor::einsum('ij,ij->ji', darrC, darrC)
## <4 x 3> HDF5Matrix object of type "double":
##             [,1]        [,2]        [,3]
## [1,] 0.378039680 0.041400176 0.003958779
## [2,] 0.840676677 0.375912480 0.238433551
## [3,] 0.526422419 0.612297024 0.019682633
## [4,] 0.177981290 0.063736795 0.039469945
einsum::einsum('ijk,ijk->jki', arrE, arrE)
## , , 1
## 
##            [,1]        [,2]        [,3]       [,4]       [,5]
## [1,] 0.85780699 0.007851121 0.194752744 0.57047663 0.18317797
## [2,] 0.04949809 0.961764375 0.007423033 0.09715478 0.26639958
## [3,] 0.13681695 0.043784521 0.187104550 0.11142782 0.65944666
## [4,] 0.51261005 0.164655249 0.190803943 0.07362350 0.06025528
## 
## , , 2
## 
##            [,1]        [,2]      [,3]       [,4]       [,5]
## [1,] 0.62473904 0.803115643 0.1273842 0.24138716 0.63768687
## [2,] 0.98280217 0.003532964 0.3350332 0.04850522 0.74534008
## [3,] 0.09019006 0.654989522 0.6977343 0.02408952 0.09882863
## [4,] 0.61683422 0.176791022 0.2621435 0.11541341 0.08079029
## 
## , , 3
## 
##            [,1]      [,2]      [,3]       [,4]       [,5]
## [1,] 0.01978785 0.1309576 0.6382511 0.60867718 0.43233832
## [2,] 0.08733516 0.4149204 0.6619169 0.26625726 0.90379813
## [3,] 0.29459740 0.5269596 0.7028327 0.95678142 0.86127776
## [4,] 0.15674076 0.4867821 0.3387622 0.09397323 0.07219297
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.857806989 0.007851121 0.194752744 0.570476632 0.183177966
## [2,] 0.049498086 0.961764375 0.007423033 0.097154785 0.266399584
## [3,] 0.136816951 0.043784521 0.187104550 0.111427817 0.659446657
## [4,] 0.512610049 0.164655249 0.190803943 0.073623503 0.060255284
## 
## ,,2
##             [,1]        [,2]        [,3]        [,4]        [,5]
## [1,] 0.624739045 0.803115643 0.127384166 0.241387159 0.637686866
## [2,] 0.982802165 0.003532964 0.335033210 0.048505217 0.745340078
## [3,] 0.090190058 0.654989522 0.697734292 0.024089515 0.098828630
## [4,] 0.616834220 0.176791022 0.262143527 0.115413408 0.080790295
## 
## ,,3
##            [,1]       [,2]       [,3]       [,4]       [,5]
## [1,] 0.01978785 0.13095760 0.63825111 0.60867718 0.43233832
## [2,] 0.08733516 0.41492038 0.66191693 0.26625726 0.90379813
## [3,] 0.29459740 0.52695962 0.70283275 0.95678142 0.86127776
## [4,] 0.15674076 0.48678208 0.33876216 0.09397323 0.07219297

Summation + Permutation

Some examples of combining Summation and Permutation are shown below.

einsum::einsum('ijk->ki', arrE)
##          [,1]     [,2]     [,3]
## [1,] 2.234516 2.867473 1.374868
## [2,] 1.684327 2.185385 2.429641
## [3,] 1.396832 2.283034 3.032873
## [4,] 1.672140 1.206484 2.580881
## [5,] 2.001665 2.260490 2.804945
DelayedTensor::einsum('ijk->ki', darrE)
## <5 x 3> HDF5Matrix object of type "double":
##          [,1]     [,2]     [,3]
## [1,] 2.234516 2.867473 1.374868
## [2,] 1.684327 2.185385 2.429641
## [3,] 1.396832 2.283034 3.032873
## [4,] 1.672140 1.206484 2.580881
## [5,] 2.001665 2.260490 2.804945

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.28970497 0.002651539 0.065773348 0.19266562 0.061864227
## [2,] 0.03717461 0.722315040 0.005574929 0.07296627 0.200074395
## [3,] 0.06434329 0.020591309 0.087992913 0.05240310 0.310129458
## [4,] 0.08150616 0.026180558 0.030338260 0.01170630 0.009580727
## 
## , , 2
## 
##             [,1]         [,2]         [,3]         [,4]        [,5]
## [1,] 0.003309344 0.0042542339 0.0006747746 0.0012786670 0.003377931
## [2,] 0.047270907 0.0001699288 0.0161144575 0.0023330083 0.035849434
## [3,] 0.007065809 0.0513142029 0.0546629798 0.0018872581 0.007742586
## [4,] 0.005030368 0.0014417552 0.0021378166 0.0009412122 0.000658856
## 
## , , 3
## 
##              [,1]         [,2]        [,3]        [,4]        [,5]
## [1,] 3.508779e-05 0.0002322139 0.001131746 0.001079306 0.000766622
## [2,] 9.327232e-03 0.0443127198 0.070691490 0.028435777 0.096523948
## [3,] 2.597218e-03 0.0046457603 0.006196286 0.008435138 0.007593163
## [4,] 2.771052e-03 0.0086059215 0.005989047 0.001661372 0.001276314
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.289704966 0.002651539 0.065773348 0.192665618 0.061864227
## [2,] 0.037174606 0.722315040 0.005574929 0.072966273 0.200074395
## [3,] 0.064343289 0.020591309 0.087992913 0.052403099 0.310129458
## [4,] 0.081506161 0.026180558 0.030338260 0.011706304 0.009580727
## 
## ,,2
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 0.0033093441 0.0042542339 0.0006747746 0.0012786670 0.0033779308
## [2,] 0.0472709069 0.0001699288 0.0161144575 0.0023330083 0.0358494341
## [3,] 0.0070658091 0.0513142029 0.0546629798 0.0018872581 0.0077425855
## [4,] 0.0050303681 0.0014417552 0.0021378166 0.0009412122 0.0006588560
## 
## ,,3
##              [,1]         [,2]         [,3]         [,4]         [,5]
## [1,] 3.508779e-05 2.322139e-04 1.131746e-03 1.079306e-03 7.666220e-04
## [2,] 9.327232e-03 4.431272e-02 7.069149e-02 2.843578e-02 9.652395e-02
## [3,] 2.597218e-03 4.645760e-03 6.196286e-03 8.435138e-03 7.593163e-03
## [4,] 2.771052e-03 8.605921e-03 5.989047e-03 1.661372e-03 1.276314e-03

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.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 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.32.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=en_US.UTF-8    
##  [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.2.0              DelayedRandomArray_1.21.0
##  [3] HDF5Array_1.41.3          h5mread_1.5.3            
##  [5] rhdf5_2.57.20             DelayedArray_0.39.8      
##  [7] SparseArray_1.13.4        S4Arrays_1.13.2          
##  [9] abind_1.4-8               IRanges_2.47.5           
## [11] S4Vectors_0.51.10         MatrixGenerics_1.25.0    
## [13] matrixStats_1.5.0         BiocGenerics_0.59.12     
## [15] generics_0.1.4            Matrix_1.7-6             
## [17] DelayedTensor_1.19.0      BiocStyle_2.41.0         
## 
## loaded via a namespace (and not attached):
##  [1] dqrng_0.4.1         sass_0.4.10         lattice_0.23-1     
##  [4] digest_0.6.39       evaluate_1.0.5      grid_4.6.2         
##  [7] fastmap_1.2.0       jsonlite_2.0.0      BiocManager_1.30.27
## [10] codetools_0.2-20    jquerylib_0.1.4     cli_3.6.6          
## [13] rlang_1.3.0         XVector_0.53.0      cachem_1.1.0       
## [16] yaml_2.3.12         otel_0.2.0          tools_4.6.2        
## [19] beachmat_2.29.3     parallel_4.6.2      BiocParallel_1.47.0
## [22] Rhdf5lib_2.1.0      rsvd_1.0.6          buildtools_1.0.0   
## [25] R6_2.6.1            lifecycle_1.0.5     BiocSingular_1.29.2
## [28] irlba_2.4.1         ScaledMatrix_1.21.0 rTensor_1.5.0      
## [31] bslib_0.12.0        Rcpp_1.1.2          xfun_0.62          
## [34] sys_3.4.3           knitr_1.52          rhdf5filters_1.25.5
## [37] htmltools_0.5.9     rmarkdown_2.32      maketools_1.3.2    
## [40] compiler_4.6.2