$
\newcommand{\BAhat}{\hat{\boldsymbol{A}}}
\newcommand{\Buhat}{\hat{\boldsymbol{u}}}
\newcommand{\Bbhat}{\hat{\boldsymbol{b}}}
$
In vectorial problems, we end up with linear systems of higher order, such as
∑ k = 1 N ∑ l = 1 M A i j k l u k l = b i j \begin{equation}
\suml{k=1}{N}
\suml{l=1}{M} A_{ijkl} \, u_{kl}
= b_{ij}
\htmlId{eq:1}{}
\tag{1}\end{equation} k = 1 ∑ N l = 1 ∑ M A ij k l u k l = b ij ( 1 )
for i = 1 , … , N i=1,\dots,N i = 1 , … , N and j = 1 , … , M j=1,\dots,M j = 1 , … , M .
These systems cannot be solved readily with existing software. In order to be
able to solve them with existing software, we need to reshape them by
defining a matrix of matrices
A ^ \BAhat A ^ and vector of vectors u ^ \Buhat u ^ and b ^ \Bbhat b ^ :
[ A 1111 ⋯ A 111 M A 11 N 1 ⋯ A 11 N M ⋮ ⋱ ⋮ ⋯ ⋮ ⋱ ⋮ A 1 M 11 ⋯ A 1 M 1 M A 1 M N 1 ⋯ A 1 M N M ⋮ ⋱ ⋮ A N 111 ⋯ A N 11 M A N 1 N 1 ⋯ A N 1 N M ⋮ ⋱ ⋮ ⋯ ⋮ ⋱ ⋮ A N M 11 ⋯ A N M 1 M A N M N 1 ⋯ A N M N M ] ⏟ A ^ [ u 11 ⋮ u 1 M ⋮ u N 1 ⋮ u N M ] ⏟ u ^ = [ b 11 ⋮ b 1 M ⋮ b N 1 ⋮ b N M ] ⏟ b ^ \begin{equation}
\underbrace{
\left[
\begin{array}{ccc|c|ccc}
A_{1111}
& \cdots
& A_{111M}
&
& A_{11N1}
& \cdots
& A_{11NM}
\\
\vdots
& \ddots
& \vdots
& \cdots
& \vdots
& \ddots
& \vdots
\\
A_{1M11}
& \cdots
& A_{1M1M}
&
& A_{1MN1}
& \cdots
& A_{1MNM}
\\[1ex]
\hline
& \vdots
&
&\ddots
&
& \vdots
&
\\
\hline
&&&&&&
\\[-1.5ex]
A_{N111}
& \cdots
& A_{N11M}
&
& A_{N1N1}
& \cdots
& A_{N1NM}
\\
\vdots
& \ddots
& \vdots
& \cdots
& \vdots
& \ddots
& \vdots
\\
A_{NM11}
& \cdots
& A_{NM1M}
&
& A_{NMN1}
& \cdots
& A_{NMNM}
\end{array}
\right]
}_{\BAhat}
\underbrace{
\left[
\begin{array}{c}
u_{11}\\
\vdots \\
u_{1M} \\[1ex]
\hline \vdots\\
\hline \\[-1.5ex]
u_{N1} \\
\vdots \\
u_{NM}
\end{array}
\right]
}_{\Buhat}
=
\underbrace{
\left[
\begin{array}{c}
b_{11}\\
\vdots \\
b_{1M} \\[1ex]
\hline \vdots\\
\hline \\[-1.5ex]
b_{N1} \\
\vdots \\
b_{NM}
\end{array}
\right]}_{\Bbhat}
\tag{2}\end{equation} A ^ A 1111 ⋮ A 1 M 11 A N 111 ⋮ A N M 11 ⋯ ⋱ ⋯ ⋮ ⋯ ⋱ ⋯ A 111 M ⋮ A 1 M 1 M A N 11 M ⋮ A N M 1 M ⋯ ⋱ ⋯ A 11 N 1 ⋮ A 1 M N 1 A N 1 N 1 ⋮ A N M N 1 ⋯ ⋱ ⋯ ⋮ ⋯ ⋱ ⋯ A 11 N M ⋮ A 1 M N M A N 1 N M ⋮ A N M N M u ^ u 11 ⋮ u 1 M ⋮ u N 1 ⋮ u N M = b ^ b 11 ⋮ b 1 M ⋮ b N 1 ⋮ b N M ( 2 )
This allows us to express the linear system as
A ^ u ^ = b ^ \begin{equation}
\BAhat \Buhat = \Bbhat
\htmlId{eq:3}{}
\tag{3}\end{equation} A ^ u ^ = b ^ ( 3 )
Here, we reshape the system by defining a map i d i_d i d that maps original
indices to the reshaped indices
i d : = { [ 1 , N ] × [ 1 , M ] → [ 1 , N M ] ( i , j ) ↦ M ( i − 1 ) + j \begin{equation}
i_d :=
\left\{
\begin{array}{rl}
[1,N]\times[1,M] & \to [1,NM]\\[1ex]
(i,j) & \mapsto M(i-1)+j\\
\end{array}
\right.
\tag{4}\end{equation} i d := { [ 1 , N ] × [ 1 , M ] ( i , j ) → [ 1 , N M ] ↦ M ( i − 1 ) + j ( 4 )
where we used 1-based indexing of the arrays.
We set
α : = i d ( i , j ) = M ( i − 1 ) + j β : = i d ( k , l ) = M ( k − 1 ) + l \begin{equation}
\boxed{
\begin{alignedat}{3}
\alpha &:= i_d(i,j) &&= M(i-1) + j \\
\beta &:= i_d(k,l) &&= M(k-1) + l \\
\end{alignedat}
}
\tag{5}\end{equation} α β := i d ( i , j ) := i d ( k , l ) = M ( i − 1 ) + j = M ( k − 1 ) + l ( 5 )
and write
A ^ α β = A i j k l , u ^ β = u k l and b ^ α = b i j \begin{equation}
\hat{A}_{\alpha\beta} = A_{ijkl}
\quad,\quad
\hat{u}_{\beta} = u_{kl}
\eqand
\hat{b}_{\alpha} = b_{ij}
\tag{6}\end{equation} A ^ α β = A ij k l , u ^ β = u k l and b ^ α = b ij ( 6 )
For reference, the inverse of the index mapping reads
i d − 1 : = { [ 1 , N M ] → [ 1 , N ] × [ 1 , M ] α ↦ ( 1 + ( α − m o d ( α , M ) ) / M , m o d ( α , M ) ) \begin{equation}
i_d^{-1} :=
\left\{
\begin{array}{rl}
[1,NM] & \to [1,N]\times[1,M] \\[1ex]
\alpha & \mapsto (1+(\alpha-\modop(\alpha,M))/M\;,\; \modop(\alpha,M))
\end{array}
\right.
\tag{7}\end{equation} i d − 1 := { [ 1 , N M ] α → [ 1 , N ] × [ 1 , M ] ↦ ( 1 + ( α − mod ( α , M )) / M , mod ( α , M )) ( 7 )
Thus, we have for our reshaped indices,
j = m o d ( α , M ) i = 1 + ( α − j ) / M and l = m o d ( β , M ) k = 1 + ( β − l ) / M \begin{equation}
\begin{aligned}
j &= \modop(\alpha,M) \\
i &= 1+(\alpha-j)/M
\end{aligned}
\quad\eqand\quad
\begin{aligned}
l &= \modop(\beta,M) \\
k &= 1+(\beta-l)/M
\end{aligned}
\tag{8}\end{equation} j i = mod ( α , M ) = 1 + ( α − j ) / M and l k = mod ( β , M ) = 1 + ( β − l ) / M ( 8 )
Expressed as a regular linear system (3) , the higher-order system
(1) can be solved with a linear solver such as
LAPACK .