grapes-.-grapes: Define a tensor product

Description Usage Arguments Value Examples

Description

Define a tensor product

Usage

1
A %.% B

Arguments

A

An (eventually named) array of dimension \mathrm{dim}(A)=(a_i)_{i\in I_A}

B

An (eventually named) array of dimension \mathrm{dim}(B)=(b_j)_{j\in I_B}

I_A

a named list of subvectors from names(dimnames(A)) or from 1:length(dim(A)). I_A=(I_A^{(c)},I_A^{(n)},I_A^{(p)}).

I_B

a named list of subvectors from names(dimnames(B)) or from 1:length(dim(B)). I_B=(I_B^{(c)},I_B^{(p)},I_B^{(q)}). Necessarily, (\mathrm{dim}(A))_{I_A^{(p)}}=(\mathrm{dim}(B))_{I_B^{(p)}} (e.g dim(A)[I_A$p]==dim(B)[I_B$p]) and (\mathrm{dim}(A))_{i\in I_A^{(c)}}=(\mathrm{dim}(B))_{i\in I_B^{(c)}} e.g dim(A)[I_A$c]==dim(B)[I_B$c])

Value

C=AB the array of dimension ≤ft((a_\ell)_{\ell\in I_A^{(c)}},(a_i)_{i\in I_A^{(n)}}(b_j)_{j\in I_B^{(q)}}\right) defined by

\forall (\ell_1,…,\ell_C)\in∏_{i\in I_A^{(c)}}\{1,…, a_i\},

\forall (i_1,…,i_N)\in∏_{i\in I_A^{(n)}}\{1,… ,a_i\},

\forall (j_1,…,j_Q)\in∏_{j\in I_B^{(q)}}\{1,… ,b_j\},

C[\ell_1,…,\ell_C,i_1,…,i_N,j_1,…,j_Q]=∑_{k_1=1}^{K_1}\!\!…\!\!∑_{k_P=1}^{K_P}A^\star[\ell_1,…,\ell_C,i_1,...,i_q,k_1,...,k_p]\times B^\star[\ell_1,…,\ell_C,k_1,...,k_p,j_1,...,j_n])

where A^\star and B^\star are multidimensional transposition of A and B and K_1,…,K_P=\mathrm{dim}(A)_{I_A^{(p)}}.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
A=array(1:(prod(2:6)),2:6);
dimnames(A)<-sapply(dim(A),seq_len)
names(dimnames(A))<-paste0("x",2:6)
B=array(1:(prod(3:7)),3:7);
dimnames(B)<-sapply(dim(B),seq_len)
names(dimnames(B))<-paste0("y",3:7)
I_A=list(c=c("x3","x5"),n=c("x2","x4"),p="x6")
I_B=list(c=c("y3","y5"),q=c("y4","y7"),p="y6")
"%.%"(A,B)
"%.%"(A,B,I_A,I_B)
W%.%.%.%t(X);

DanielBonnery/TensorDB documentation built on April 26, 2020, 3:45 p.m.