\documentclass[a4paper,11pt]{report}
%\usepackage[utf8]{inputenc}

\usepackage[cal=boondox,scr=boondoxo]{mathalfa} %%% endrikan'ny mathcal sy mathscr 

\usepackage[a4paper,bindingoffset=0cm,%
            left=2cm,right=2cm,top=2cm,bottom=2cm,%
            footskip=0.8cm]{geometry}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\frenchbsetup{StandardLists=true} % ÃƒÂ  inclure si on utilise \usepackage[french]{babel}
\usepackage{cite}     % pour les citations multiples
\usepackage{enumitem}

%\bibliographystyle{fr-plain}


\usepackage{amsmath, amsthm} % tr`es bon mode mathÃ‚?ematailletique
\usepackage{amsfonts,amssymb}% permet la definition des ensembles
\usepackage{mathtools}

\usepackage{centernot}

%\usepackage{tikz3d-fr}

\usepackage{tikz,tkz-tab}
\usetikzlibrary{3d}

%\usepackage{pgfplots}
%\usetikzlibrary{decorations.pathreplacing}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}{Definition}[section]

\begin{document}
\section{Write any tensor of any order as vector or tensor of order one !!}
Let  
$\mathbb{K}$ a field( for e.g $\mathbb{R}$ ), we will construct $\mathbb{K}^{d_1\times\cdots\times d_k}\simeq \mathbb{K}^{d_1\cdots d_k}$ such that $d_1,\ldots,d_k\in\mathbb{N}^*$.
\begin{definition}
A tensor is a collection of elements
 its dimensions define the size of the collection
 its order is the number of different dimensions
\end{definition}
In linear algebra, we have the unfolding
\begin{definition}
A dimension of a tensor $T$ is a vector $d\in \left(\mathbb{N}^*\right)^k$ $(k<\infty)$. We have $$T=(a)_d=(a)_{d_1,\ldots,d_k} =({\alpha}_{i_1,\ldots,i_k}^{\{k\}})_{0\le i_1<d_1, \ldots , 0\le i_k< d_k} $$
$$ {\alpha}_{i_1,\ldots,i_k}^{\{k\}}\in \mathbb{K} \ \ / \ \ 0\le i_j<d_j $$
\end{definition}

$k>0$ is the order.\\
The size of the Tensor is $d_1 \times \cdots \times d_k=\prod_{i=1}^kd_i$

% Here $\mathbb{K} = \mathbb{R}$ to simplify but it works for all filds.


We can write $$T\in \mathbb{K}^{d_1 \times  d_2 \times \cdots \times d_k}$$


\section{Bijection}

For a given $d_1,\ldots,d_k\in \mathbb{N}^*$, there exists a bijective application  between a set of tensor order 1 of size $n=d_1\cdot d_2 \cdots d_k$ $\mathbb{K}^{n}$ and the set of tensor of order $k$ of the size $n= d_1\cdot d_2 \cdots d_k$ $\mathbb{K}^{d_1\times  d_2 \times \cdots \times d_k}$.

Little endian
$$
\begin{array}{ccc}
\mathbb{K}^{d_1\times  d_2 \times \cdots \times d_k} & \longrightarrow &  \mathbb{K}^{d_1\cdot d_2\cdots d_k}  \\
\left({\alpha}_{(i_1,\ldots,i_k)_k}\right) & \longmapsto & \left({\alpha}_{\left(i_1+i_2\cdot d_1+\ldots+i_k \prod_{j=1}^{k-1}d_j\right)_1}\right)
\end{array}
$$

Big endian

$$
\begin{array}{ccc}
\mathbb{K}^{d_1\times  d_2 \times \cdots \times d_k} & \longrightarrow &  \mathbb{K}^{d_1\cdot d_2\cdots d_k}  \\
\left({\alpha}_{(i_1,\ldots,i_k)_k}\right) & \longmapsto & \left({\alpha}_{\left(i_1 \prod_{j=2}^kd_j+i_2\prod_{j=3}^k d_j+\ldots +i_{k-1} d_k +i_k \right)_1}\right)
\end{array}
$$
For $a,b\in \mathbb{N}$, we note $ [\![ a,b ]\!] = [a.. b]=[a,b]\cap \mathbb{N}$

and  $ [\![ a,b [\![ = [\![ a,b ) = [a.. b) = [a.. b[=[a,b[\cap \mathbb{N}$

If $a=0$ we note $[b]=[\![0,b]\!]$ and $[b)=[\![0,b[\![$ so here we defined a bijection of indexe, i.e,

\begin{align*}
 f:[d_1)\times[d_2)\times\cdots\times [d_k) & \longrightarrow [d_1\cdot d_2\cdots d_k)\\
 (i_1,i_2,\ldots,i_k)_k & \longrightarrow  f(i_1,i_2,\ldots,i_k)=(i)_1
\end{align*}
If little endian
\begin{align*}
 i & =i_1 +i_2d_1+\cdots+i_k\prod_{j=1}^{k-1} d_j \\
 &=\sum_{j=1}^ki_j\prod_{l=1}^{j-1}d_l
\end{align*}
If big endian
\begin{align*}
 i & =i_1 \prod_{j=2}^kd_j+i_2\prod_{j=3}^k d_j+\ldots +i_{k-1} d_k +i_k \\
 &=\sum_{j=1}^ki_j\prod_{l=i+1}^kd_l
\end{align*}

$ $


\section{Inverse indexes}
The inverse of Little endian :

For any $i\in \mathbb{N} , i<n=\prod_{j=1}^kd_j \exists! (i_1, \ldots, i_k) / \forall 1 \le j \le k,  0\le i_j<d_j$ and $$ i=\sum_{j=1}^{k} i_j\left( \prod_{l=1}^{j-1} d_l \right) $$


The inverse of big endian :

For any $i\in \mathbb{N} , i<n=\prod_{j=1}^kd_j \exists! (i_1, \ldots, i_k) / \forall 1 \le j \le k,  0\le i_j<d_j$ and $$ i=\sum_{s=j}^k i_s\left( \prod_{l=s+1}^k d_l \right) $$

Proof of the inverse of big endian, the Little endian is almost the same:

By reccurence:
by Euclide division $\exists ! (r_1,i_1)\in \mathbb{N}^2 / r_1 < \prod_{l=2}^k d_l $ and $i=i_1*\prod_{l=2}^k d_l + r_1$.

And so on, there exists $(r_2, i_2)\in\mathbb{N}^2$ such that $r_2<\prod_{l=3}^k d_l$ and $r_1 = i_2*\prod_{l=3}^k d_l + r_2$.
Suppose, for all $2<j< k$ there exists $(r_j,i_j)\in\mathbb{N}^2$ such that $r_j<\prod_{l=j+1}^kd_l$ and $r_{j-1}=i_j\prod_{l=j+1}^k d_l + r_j $

By Euclide disvision on $r_j$ and $\prod_{l=j+2}^kd_l$ there exists $(r_{j+1}, i_{j+1})\in\mathbb{N}^2$ such that $r_j<\prod_{l=j+2}^k d_l$ and $r_j=i_{j+1}\prod_{l=j+2}^k d_l + r_{j+1}$



One of the advantages using order 1 tensor than larger order only one loop to browse all elements of the tensor.

\section{Operations on tensors}

We prove below that all operations like tensor contraction  and tensor multiplication work with these bijections.


Let $T_{\alpha}^{\{k\}}\in\mathbb{R}^{d_{1}\times\cdots\times d_{k}}$ and $T_{\beta}^{\{q\}}\in\mathbb{R}^{b_{1}\times\cdots\times b_{q}}$ and $T_{\alpha}^{\{1\}}\in\mathbb{R}^{d_{1}\cdots d_{k}}$ and $T_{\beta}^{\{1\}}\in\mathbb{R}^{b_{1}\cdots b_{q}}$ such that

$T_{\alpha}^{\{k\}}=\left({\alpha}_{\left(i_{1},\ldots,i_{k}\right)_k}\right)_{0\le i_{j}<d_{j} / 1\le j\le k} $
and $T_{\beta}^{\{q\}}=\left({\beta}_{\left(i_{1},\ldots,i_{q}\right)_q}\right)_{0\le i_{j}<b_{j} / 1\le j\le q} $

and $T_{\alpha}^{\{1\}}=\left({\alpha}_{\left(i_1\right)_1}\right)_{0\le i_1 < \prod_{j=1}^k d_{j}}$

and $T_{\beta}^{\{1\}}=\left({\beta}_{\left(i_1\right)_1}\right)_{0\le i_1 < \prod_{j=1}^{q} b_{j}}$

Here we use little endian so

${\alpha}_{\left(\sum_{j=1}^k i_j\left(\prod_{l=1}^{j-1}d_{l}\right)\right)_1}={\alpha}_{\left(i_1,\ldots,i_k\right)_k}$ $\,\, /\,\, i_j\in[d_{j})  \,\,/\,\, 1\le j\le k$

and

${\beta}_{\left(\sum_{j=1}^{q} i_j\left(\prod_{l=1}^{j-1}b_{l}\right)\right)_1}={\beta}_{\left(i_1,\ldots,i_{q}\right)_q}$ $\,\, /\,\, i_j\in [b_{j}) \,\,/\,\, 1\le j\le q$

\subsection{Tensor multiplication}

tensor multiplication of $T_{\alpha}^{\{k\}} \times T_{\beta}^{\{q\}} = T_{\gamma}^{\{k+q\}}=\left({\gamma}_{\left(i_{1},\ldots,i_{k+q}\right)_{k+q}}\right)\in \mathbb{R}^{d_{1}\times\cdots\times d_{k}\times b_{1}\times\cdots\times b_{q}}$ such that
$${\gamma}_{\left(i_{1},\ldots, i_{k},i_{k+1},\ldots,i_{k+q}\right)_{k+q}}={\alpha}_{\left(i_{1},\ldots,i_{k}\right)_k} \cdot {\beta}_{\left(i_{k+1},\ldots,i_{k+q}\right)_q} $$


So the correspondant one order tensor of $T_{\gamma}^{\{k+q\}}$ is $T_{\gamma}^{\{1\}}={\gamma}_{\left(i\right)_{1}}\in\mathbb{R}^{d_{1}\cdots d_{k}\cdot b_{1}\cdots b_{q}}$ such that

\begin{align*}
{\gamma}_{\left(i_{1},\ldots, i_{k},i_{k+1}\right)_{k+q}}&={\gamma}_{\left(\sum_{j=1}^{k+q} i_{j}\prod_{l=1}^{j-1}d_{i_{l}}\right)_{1} }\\
&={\gamma}_{\left( \sum_{j=1}^{k} i_{j}\prod_{l=1}^{j-1}d_{i_{l}} + \sum_{j=k+1}^{k+q} i_{j}\prod_{l=1}^{j-1}d_{i_{l}}\right)_{1} }\\
&={\alpha}_{\left( \sum_{j=1}^{k} i_{j}\prod_{l=1}^{j-1}d_{i_{l}} \right)_{1}} \cdot b_{\left( \sum_{j=k+1}^{k+q} i_{j}\prod_{l=1}^{j-1}d_{i_{l}} \right)_{1} }\\
&={\alpha}_{\left(i_{1},\ldots,i_{k}\right)_{k}} \cdot b_{\left( i_{k+1},\ldots,{k+q} \right)_{q} }\\
\end{align*}
Then,
${\gamma}_{\left(\sum_{j=1}^{k+q} i_{j}\prod_{l=1}^{j-1}d_{i_{l}}\right)_{1} }=
{\alpha}_{\left( \sum_{j=1}^{k} i_{j}\prod_{l=1}^{j-1}d_{i_{l}} \right)_{1}} \cdot b_{\left( \sum_{j=k+1}^{k+q} i_{j}\prod_{l=1}^{j-1}d_{i_{l}} \right)_{1} }$


\subsection{tensor contraction}
Let $T_{\alpha}^{\{k\}}\in\mathbb{R}^{d_{1}\times\cdots\times d_{k}}$ and $T_{\beta}^{\{q\}}\in\mathbb{R}^{b_{1}\times\cdots\times b_{q}}$ and $T_{\alpha}^{\{1\}}\in\mathbb{R}^{d_{1}\cdots d_{k}}$ and $T_{\beta}^{\{1\}}\in\mathbb{R}^{b_{1}\cdots b_{q}}$ such that there exists $0<k_0 \le \min(k,q)$.

tensor $k_0$ contraction of  $T_{\alpha}^{\{k\}}$ and $T_{\beta}^{\{q\}}$ is $T_{\gamma}^{\{k+q-2\cdot k_0\}}\in\mathbb{R}^{p_{1}\times\cdots\times p_{k+q-2k_0} }$ such that:
\begin{align*}
 d_{i}&=b_{i-k + k_0 + 1} &\forall i\in [\![k- k_0 , k ]\!] \\
 p_{i}&=d_{i} &\forall  i\in [\![ 1 , k- k_0]\!]\\
 p_{i}&=b_{i-k+2k_0} &\forall i\in [\![k-k_0+1, k+q-2k_0]\!] \\
\end{align*}
and
\begin{align*}
{\gamma}_{\left(i_{n_1},\ldots,i_{n_{k+q-2\cdot k_0}}\right)_{k+q-2\cdot k_0}}&={\gamma}_{\left(i_{1},\ldots,i_{k-k_0-1},j_{k_0+1},\ldots,j_{q}\right)_{k+q-2\cdot k_0}} \\
&i_{n_1}=i_1,\ldots,i_{n_{k-k_0-1}}=i_{k-k_0-1},i_{n_{k-k_0}}=j_{k_0+1},\ldots,i_{n_{k+q-2k_0}}=j_{q}\\
&=\sum_{l_{1}=0}^{b_{1}-1}\sum_{l_{2}=0}^{b_{1}-1}\cdots \sum_{l_{k_0}=0}^{d_{k_0}-1} {\alpha}_{\left(i_{1},\ldots,i_{k-k_0-1},l_{1},l_{2},\ldots,l_{k_0}\right)_{k} } {\beta}_{\left(l_{1},l_{2},\ldots,l_{k_0},j_{k_0+1},j_{k_0+2},\ldots,j_{q}\right)_{q}} \\
\end{align*}
For example in little endian transformation:
\begin{align*}
 {\alpha}_{\left(i_{1},\ldots,i_{k-k_0},l_{1},l_{2},\ldots,l_{k_0}\right)} &= {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{j=k-k_0+1}^{k}l_{(j-k+k_0)}\prod_{s=1}^{j-1}d_{s}\right)_{1}}\\
 {\beta}_{\left(l_{1},l_{2},\ldots,l_{k_0},j_{k_0+1},j_{k_0+2},\ldots,j_{q}\right)_{q}} &= {\beta}_{\left(\sum_{t=1}^{k_0}l_t\prod_{s=1}^{t-1}b_{s}+\sum_{t=k_0+1}^{k}j_{t}\prod_{s=1}^{t-1}b_{s}\right)_{1}}\\
\end{align*}
We have to sum these terms $
\forall l_{1}\in [\![0,b_{1}[\![, \forall l_{2}\in [\![0,b_{1}[\![\cdots \forall l_{k_0}\in[\![0,b_{k_0}[\![
$

So
\begin{align*}
 0  \le l_{j} &\le b_{j}-1  \, \, ,  \forall 1 \le j \le k_0\\
 0 \prod_{s=1}^{j-1}b_{s} \le l_{j} \prod_{s=1}^{j-1}b_{s} & \le (b_{j}-1) \prod_{s=1}^{j-1}b_{s}\, \, ,  \forall 1 \le j \le k_0\\
 0 \le l_{j} \prod_{s=1}^{j-1}b_{s} & \le (b_{j}-1) \prod_{s=1}^{j-1}b_{s}\, \, ,  \forall 1 \le j \le k_0\\
\sum_{j=1}^{k_0}  0 \le \sum_{j=1}^{k_0} l_{j} \prod_{s=1}^{j-1}b_{s} & \le \sum_{j=1}^{k_0} (b_{j}-1) \prod_{s=1}^{j-1}b_{s}\\
  0 \le \sum_{j=1}^{k_0} l_{j} \prod_{s=1}^{j-1}b_{s} & \le \sum_{j=1}^{k_0} (b_{j}-1) \prod_{s=1}^{j-1}b_{s} = M_{k_0}\\
%  \sum_{l_j=0}^{b_{j}-1} 0 \le \sum_{l_j=0}^{b_{j}-1} l_{j} \prod_{s=1}^{j-1}b_{s} &< \sum_{l_j=0}^{b_{j}-1}  \prod_{s=1}^{j}b_{s} \\
%   0 \le \sum_{l_j=0}^{b_{j}-1} l_{j} \prod_{s=1}^{j-1}b_{s} &<  b_{j} \prod_{s=1}^{j-1}b_{s}=\prod_{s=1}^{j}b_{s} \\
%   0 \le \sum_{l_j=0}^{b_{j}-1} l_{j} \prod_{s=1}^{j-1}b_{s} &<  \prod_{s=1}^{j}b_{s} \\
\end{align*}

if $k_0=1$
$M_1+1 = (b_{1}-1) +1 = b_{1} $

Suppose $M_{k_0-1}+1=\prod_{j=1}^{k_0-1}b_{j}$

 %$M_{k_0}+1 = \sum_{j=1}^{k_0} (b_{j}-1) \prod_{s=1}^{j-1}b_{s} +1$

\begin{align*}
 M_{k_0}+1  &= \sum_{j=1}^{k_0} (b_{j}-1) \prod_{s=1}^{j-1}b_{s} +1 \\
 &= \left(\sum_{j=1}^{k_0-1} (b_{j}-1) \prod_{s=1}^{j-1}b_{s} \right) + (b_{k_0}-1) \prod_{s=1}^{k_0-1}b_{s} +1 \\
 &= \left(\sum_{j=1}^{k_0-1} (b_{j}-1) \prod_{s=1}^{j-1}b_{s} \right) +1 + (b_{k_0}-1) \prod_{s=1}^{k_0-1}b_{s}  \\
 &=M_{k_0-1} + 1 + (b_{k_0}-1) \prod_{s=1}^{k_0-1}b_{s} \\
 &=\prod_{j=1}^{k_0-1}b_{j} + (b_{k_0}-1) \prod_{s=1}^{k_0-1}b_{s}\\
 &=  \prod_{s=1}^{k_0-1}b_{s} \left( (b_{k_0}-1) + 1\right) = b_{k_0} \prod_{s=1}^{k_0-1}b_{s}\\
&=  \prod_{s=1}^{k_0}b_{s} \\
 \end{align*}

So when $l_j$ browses $[\![0,b_{j}[\![ $ for all $1\le j\le k_0$ the indexe  $\sum_{j=1}^{k_0} l_{j} \prod_{s=1}^{j-1}b_{s}$ browses $\left[\!\!\left[0,\prod_{j=1}^{k_0}b_{j}\right[\!\!\right[$
\begin{align*}
 &{\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{j=k-k_0+1}^{k}l_{(j-k+k_0)}\prod_{s=1}^{j-1}d_{s}\right)_{1}} \\
 &={\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{j=k-k_0+1}^{k}l_{(j-k+k_0)}\prod_{s=1}^{k-k_0}d_{s}\prod_{s=k-k_0+1}^{j-1}d_{s}\right)_{1}}\\
 & ( t=j-k+k_0 \Rightarrow j=t+k-k_0 )\\
 &(j=k-k_0+1\Rightarrow t=1; j=k\Rightarrow t=k_0)\\
 &= {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{t=1}^{k_0}l_{t}\prod_{s=k-k_0+1}^{k-k_0+t-1}d_{s} \left(\prod_{s=1}^{k-k_0}d_{s}\right)\right)_1} \\
 \end{align*}
But $d_{s} = b_{s-k+k_0} \, \, \forall s\in[\![k-k_0+1,k]\!]$

\begin{align*}
   &{\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{t=1}^{k_0}l_{t}\prod_{s=k-k_0+1}^{k-k_0+t-1}d_{s} \left(\prod_{s=1}^{k-k_0}d_{s}\right)\right)_{1}}\\
    &= {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{t=1}^{k_0}l_{t}\prod_{s=k-k_0+1}^{k-k_0+t-1}b_{s-k+k_0} \left(\prod_{s=1}^{k-k_0}d_{s}\right)\right)_{1}} \\
    & (u=s-k+k_0 \Leftrightarrow s=u+k-k_0)\\
    & (s=k-k_0+1 \Rightarrow u=1)\\
    & (s=k-k_0+t-1 \Rightarrow u=t-1)\\
    &= {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\sum_{t=1}^{k_0}l_{t}\prod_{u=1}^{t-1}b_{u} \left(\prod_{s=1}^{k-k_0}d_{s}\right)\right)_{1}} \\
    &= {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{s=1}^{j-1}d_{s}+\left(\prod_{s=1}^{k-k_0}d_{s}\right)\sum_{t=1}^{k_0}l_{t}\prod_{u=1}^{t-1}b_{u}\right)_{1} } \\
\end{align*}


as below
$ \sum_{t=1}^{k_0}l_{t}\prod_{u=1}^{t-1}b_{u}$ browse $ \left[\!\!\left[0,\prod_{j=1}^{k_0}b_{j}\right[\!\!\right[$ when $l_j$  browses $[\![0,b_{j}[\![$ for all $1\le j\le k_0$

As $l_j\in [\![0,b_{j}[\![  \forall 1\le j\le k_0$ and
$$card([\![0,b_{j}[\![)=b_{j}$$
also
$$card\left(\prod_{j=1}^{k_0}[\![0,b_{j}[\![ \right)=\prod_{j=1}^{k_0}b_{j}$$

then

\begin{align*}
 &\sum_{l_{1}=0}^{b_{1}-1}\sum_{l_{2}=0}^{b_{1}-1}\cdots \sum_{l_{k_0}=0}^{d_{k_0}-1} {\alpha}_{\left(i_{1},\ldots,i_{k-k_0},l_{1},l_{2},\ldots,l_{k_0}\right)_{k}} b_{\left(l_{1},l_{2},\ldots,l_{k_0},i_{k_0+1},i_{k_0},\ldots,i_{q}\right)_{q}}\\
&= \sum_{l=0}^{\prod_{t=1}^{k_0}b_{t}} {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{u=1}^{j-1}d_{u}+l\cdot\prod_{s=1}^{k-k_0}d_{s}\right)_{1}} b_{\left(l+\sum_{j=k_0+1}^k i_{j}\prod_{u=1}^{j-1}b_{u}\right)_{1}} \\
&= {\gamma}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{u=1}^{j-1}d_{u}+\sum_{j=k_0+1}^k i_{j}\prod_{u=1}^{j-1}b_{u}\right)_{1}} \\
&={\gamma}_{\left(i_{1},i_{2},\ldots,i_{k-k_0},i_{k_0+1},i_{k_0+2},\ldots,i_{q}\right)_{k+q-2\cdot k_0}}
\end{align*}
Then 
$$ 
{\gamma}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{u=1}^{j-1}d_{u}+\sum_{j=k_0+1}^k i_{j}\prod_{u=1}^{j-1}b_{u}\right)_{1}} 
= \sum_{l=0}^{\prod_{t=1}^{k_0}b_{t}} {\alpha}_{\left(\sum_{j=1}^{k-k_0}i_{j}\prod_{u=1}^{j-1}d_{u}+l\cdot\prod_{s=1}^{k-k_0}d_{s}\right)_{1}} b_{\left(l+\sum_{j=k_0+1}^k i_{j}\prod_{u=1}^{j-1}b_{u}\right)_{1}}  
$$


\section{Advantages using tensor order one}
The most advantage is computation, only one loop to browse all tensor elements! If we can compute in parallele, as we know the size and it is on a line, each threads or compute units available can have the same number of elements to compute!


\section{Transposition}
By definition, the transposition of a tensor $T_{\alpha}^{\{k\}}\in\mathbb{R}^{d_{1}\times\cdots\times d_{k}}$ is $T_{\beta}^{\{k\}}\in\mathbb{R}^{b_{1}\times \cdots\times b_{k}}$ and $T_{\alpha}^{\{1\}}\in\mathbb{R}^{d_{1}\cdots d_{k}}$ and $T_{\beta}^{\{1\}}\in\mathbb{R}^{b_{k}\cdots b_{1}}$ such that : $b_j=d_{k-j+1}$

$\alpha_{\left(i_1, i_2,\ldots, i_{k}\right)_k} = \beta_{\left(i_{k},\ldots,i_2,i_1\right)_k}  $

in one dim representation (little endian) we have

\begin{align*}
 \alpha_{\left(i_1, i_2,\ldots, i_{k}\right)_k} &= \alpha_{\left(\sum_{j=1}^k i_j \prod_{l=1}^{j-1}d_l \right)_1} \\
 \beta_{\left(t_{1},\ldots,t_{k}\right)_k} &= \beta_{\left( \sum_{j=1}^k t_j \prod_{l=1}^{j-1}b_l\right)_1}
\end{align*}
here $t_j=i_{k-j+1}$ and $b_j=d_{k-j+1}$ so we have

\begin{align*}
 \alpha_{\left(i_1, i_2,\ldots, i_{k}\right)_k} &= \alpha_{\left(\sum_{j=1}^k i_j \prod_{l=1}^{j-1}d_l \right)_1} \\
 &=\beta_{\left(t_{1},\ldots,t_{k}\right)_k} \\
 &= \beta_{\left( \sum_{j=1}^k t_j \prod_{l=1}^{j-1}b_l\right)_1}\\
 & t_j=i_{k-j+1}\text{ and }b_j=d_{k-j+1}\\
 &= \beta_{\left( \sum_{j=1}^k i_{k-j+1} \prod_{l=1}^{j-1}d_{k-l+1}\right)_1}\\
 &\text{we pose  }t=k-j+1 \text{ so  } j=k-t+1   \\
 &\text{if }j=1 \Rightarrow t=k \text{ and } j=k \Rightarrow t=1 \\
 &= \beta_{\left( \sum_{t=k}^{1} i_{t} \prod_{l=1}^{k-t+1-1}d_{k-l+1}\right)_1}\\
 &= \beta_{\left( \sum_{t=1}^{k} i_{t} \prod_{l=1}^{k-t}d_{k-l+1}\right)_1}\\
 & \text{ we pose }s=k-l+1 \text{ and }l=k-s+1  \\
 &\text{if }l=1 \Rightarrow s=k  \text{ and } l=k-t \Rightarrow s=k-(k-t)+1=t+1 \\
 &= \beta_{\left( \sum_{t=1}^{k} i_{t} \prod_{s=k}^{t+1}d_{s}\right)_1}\\
\end{align*}



\section{Transposition}
By definition, the transposition of a tensor $T_{\alpha}^{\{k\}}\in\mathbb{R}^{d_{1}\times\cdots\times d_{k}}$ is $T_{\beta}^{\{k\}}\in\mathbb{R}^{d_{k}\times d_{k-1}\cdots\times d_{1}}$ and $T_{\alpha}^{\{1\}}\in\mathbb{R}^{d_{1}\cdots d_{k}}$ and $T_{\beta}^{\{1\}}\in\mathbb{R}^{d_{k}\cdots d_{1}}$ such that

$\alpha_{\left(i_1, i_2,\ldots, i_{k}\right)_k} = \beta_{\left(i_{k},\ldots,i_2,i_1\right)_k}  $

So, if little endian


\begin{align*}
\alpha_{\left(\sum_{j=1}^{k} i_j \prod_{l=1}^{j-1}d_j \right)_1} &= \beta_{\left(\sum_{j=k}^{1} i_j \prod_{l=k}^{j+1}d_j \right)_1}\\
&= \beta_{\left(\sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j \right)_1}\\
\end{align*}

Let $l=\sum_{j=1}^{k} i_j \prod_{l=1}^{j-1}d_j$ corresponds $m=\sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j$

Suppose $i_1<d_1-1$

So $l+1 = \sum_{j=1}^{k} i_j \prod_{l=1}^{j-1}d_j +1 = i_1+1 + \sum_{j=2}^{k} i_j \prod_{l=1}^{j-1}d_j$

Corresponds to
\begin{align*}
m'&=\left(i_1+1\right)\prod_{l=2}^{k}d_j+ \sum_{j=2}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + i_1 \prod_{l=2}^{k}d_j+ \sum_{j=2}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + \sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + m\\
\end{align*}

If $i_1=d_1-1$ and $ i_2 <d_2-1$

So

\begin{align*}
 l+1 &= \sum_{j=1}^{k} i_j \prod_{l=1}^{j-1}d_j +1 \\
 &= i_1+1 + \sum_{j=2}^{k} i_j \prod_{l=1}^{j-1}d_j \\
 &= d_1 + \sum_{j=2}^{k} i_j \prod_{l=1}^{j-1}d_j \\
 &= d_1 + i_2 d_1 + \sum_{j=3}^{k} i_j \prod_{l=1}^{j-1}d_j \\
 &= (i_2+1) d_1 + \sum_{j=3}^{k} i_j \prod_{l=1}^{j-1}d_j \\
\end{align*}
i.e $i_1'=0$


it corresponds to
\begin{align*}
m' &=\sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + (i_2+1) \prod_{l=3}^k d_l \\
 &=\sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
 &=\sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
 \end{align*}
\begin{align*}
 m'-m &= \sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
 &-\left( (d_1-1)\prod_{l=2}^k d_l +i_2\prod_{l=3}^kd_l + \sum_{j=3}i_3 \prod_{l=j+1}^kd_l \right)\\
 &= \sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
 &-\left( \prod_{l=1}^k d_l-\prod_{l=2}^k d_l +i_2\prod_{l=3}^kd_l + \sum_{j=3}i_3 \prod_{l=j+1}^kd_l \right) \\
 &= \prod_{l=3}^k d_l+\prod_{l=2}^k d_l - \prod_{l=1}^k d_l \\
\end{align*}

 Since $i_1=d_1-1$

 \begin{align*}
 m' &=\prod_{l=2}^{k}d_j + \sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  &=\prod_{l=2}^{k}d_j + \sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  &=\prod_{l=2}^{k}d_j + i_1 \prod_{l=2}^{k}d_j+  i_2 \prod_{l=3}^{k}d_j+ \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  &=\prod_{l=2}^{k}d_j + (d_1-1) \prod_{l=2}^{k}d_j+  i_2 \prod_{l=3}^{k}d_j+ \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  &= d_1 \prod_{l=2}^{k}d_j+  i_2 \prod_{l=3}^{k}d_j+ \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  &= \prod_{l=1}^{k}d_j+  i_2 \prod_{l=3}^{k}d_j+ \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
  & > \prod_{l=1}^{k}d_j
 \end{align*}

 \begin{align*}
 m'-m  &=\sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
&-\left( (d_1-1)\prod_{l=2}^k d_l + i_2\prod_{l=3}d_l +\sum_{j=3}i_j\prod_{l=j+1}d_l \right)\\
&=\sum_{j=3}^k i_j \prod_{l=j+1}^{k}d_l + i_2 \prod_{l=3}^k d_l + \prod_{l=3}^k d_l \\
&-\left( \prod_{l=1}^k d_l-\prod_{l=2}^k d_l + i_2\prod_{l=3}d_l +\sum_{j=3}i_j\prod_{l=j+1}d_l \right)\\
&=  \prod_{l=3}^k d_l -\left( \prod_{l=1}^k d_l-\prod_{l=2}^k d_l  \right)\\
&=  \prod_{l=3}^k d_l + \prod_{l=2}^k d_l - \prod_{l=1}^k d_l
 \end{align*}

If $i_1=d_1-1$ and $i_2=d_2-1$ in $m$ so
\begin{align*}
m'&=\left(i_1+1\right)\prod_{l=2}^{k}d_j+ \sum_{j=2}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + i_1 \prod_{l=2}^{k}d_j+ \sum_{j=2}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + \sum_{j=1}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + m\\
&=\prod_{l=2}^{k}d_j + (d_1-1)\prod_{j=2}^kd_j+(d_2-1)\prod_{j=3}^kd_j + \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + \prod_{j=1}^kd_j -\prod_{j=2}^kd_j+ \prod_{j=2}^kd_j  -\prod_{j=3}^kd_j + \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + \prod_{j=1}^kd_j  -\prod_{j=3}^kd_j + \sum_{j=3}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&=\prod_{l=2}^{k}d_j + \prod_{j=1}^kd_j  -\prod_{j=3}^kd_j +  i_3 \prod_{l=4}^{k}d_j+ \sum_{j=4}^{k} i_j \prod_{l=j+1}^{k}d_j\\
&> \prod_{j=1}^kd_j\\
\end{align*}
\begin{align*}
 m'-m &= \prod_{l=2}^{k}d_j  \\
 \end{align*}



\begin{align*}
m''&= (i_3+1) \prod_{l=4}^{k}d_j + \sum_{j=4}^{k} i_j \prod_{l=j+1}^{k}d_j\\
\end{align*}
\begin{align*}
m''-m &= (i_3+1) \prod_{l=4}^{k}d_j + \sum_{j=4}^{k} i_j \prod_{l=j+1}^{k}d_j - \left((d_1-1)\prod_{l=2}^k d_l + (d_2-1)\prod_{l=3}^kd_l + i_3 \prod_{l=4}^kd_l + \sum_{j=4}^k i_j \prod_{l=j+1}^kd_l \right) \\
m''-m &=  \prod_{l=4}^{k}d_j  - \left((d_1-1)\prod_{l=2}^k d_l + (d_2-1)\prod_{l=3}^kd_l   \right) \\
m''-m &=  \prod_{l=4}^{k}d_j  - \left(\prod_{l=1}^k d_l-\prod_{l=2}^k d_l + \prod_{l=2}^k d_l-\prod_{l=3}^kd_l   \right) \\
m''-m &=  \prod_{l=4}^{k}d_j  - \left(\prod_{l=1}^k d_l-\prod_{l=3}^kd_l   \right) \\
m''-m &= \prod_{l=3}^kd_l + \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l \\
\end{align*}


if $i_1=d_1-1$, $i_2=d_2-1$, $i_3=d_3-1$
\begin{align*}
 m+\prod_{l=3}^kd_l + \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l &= \left( (d_1-1)\prod_{l=2}^kd_l+(d_2-1)\prod_{l=3}^kd_l+(d_3-1)\prod_{l=4}^kd_l +\sum_{j=4}^k i_j\prod_{l=j+1}d_l \right) \\& +\prod_{l=3}^kd_l+  \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l\\
 \end{align*}
\begin{align*}
 m+\prod_{l=3}^kd_l + \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l &= \left( (d_1-1)\prod_{l=2}^kd_l+(d_2-1)\prod_{l=3}^kd_l+(d_3-1)\prod_{l=4}^kd_l +\sum_{j=4}^k i_j\prod_{l=j+1}d_l \right) \\& +\prod_{l=3}^kd_l+  \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l\\
 &= \left(\prod_{l=1}^kd_l-\prod_{l=2}^kd_l+ \prod_{l=2}^kd_l-\prod_{l=3}^kd_l+\prod_{l=3}^kd_l-\prod_{l=4}^kd_l +\sum_{j=4}^k i_j\prod_{l=j+1}d_l \right) \\& + \prod_{l=3}^kd_l+ \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l\\
 &= \left(\prod_{l=1}^kd_l-\prod_{l=4}^kd_l +\sum_{j=4}^k i_j\prod_{l=j+1}d_l \right) \\& + \prod_{l=3}^kd_l+ \prod_{l=4}^{k}d_j  - \prod_{l=1}^k d_l\\
 &= \sum_{j=4}^k i_j\prod_{l=j+1}d_l + \prod_{l=3}^kd_l\\
 &= \sum_{j=4}^k i_j\prod_{l=j+1}d_l + <\prod_{l=3}^kd_l\\
\end{align*}


\begin{align*}
 l+1&=\sum_{j=1}^k i_j\prod_{l=1}^{j-1}d_l +1\\
 &= 1+(d_1-1) + (d_2-1)d_1 + (d_3-1)d_1 d_2+i_4d_1d_2d_3 +\sum_{j=5}^k i_j\prod_{l=1}^{j-1}d_l\\
 &= d_1 + d_2-d_1 + d_1d_2d_3-d_1 d_2+i_4d_1d_2d_3 +\sum_{j=5}^k i_j\prod_{l=1}^{j-1}d_l\\
 &= (i_4+1)d_1d_2d_3 +\sum_{j=5}i_j\prod_{l=1}^{j-1}d_l\\
\end{align*}

corresponds to
\begin{align*}
 m' &= (i_4+1)\prod_{l=5}^kd_l + \sum_{j=5}i_j\prod_{l=j+1}^kd_l\\
 &= i_4\prod_{l=5}^kd_l +\prod_{l=5}^kd_l + \sum_{j=5}i_j\prod_{l=j+1}^kd_l\\
\end{align*}
\begin{align*}
 m'-m &= i_4\prod_{l=5}^kd_l +\prod_{l=5}^kd_l + \sum_{j=5}i_j\prod_{l=j+1}^kd_l\\
 & -\left( (d_1-1)\prod_{l=2}^kd_l + (d_2-1)\prod_{l=3}^kd_l+(d_3-1)\prod_{l=4}^kd_l+i_4\prod_{l=5}^kd_l+\sum_{j=5}^ki_j\prod_{l=j+1}^k d_l \right)\\
&= i_4\prod_{l=5}^kd_l +\prod_{l=5}^kd_l + \sum_{j=5}i_j\prod_{l=j+1}^kd_l\\
 & -\left( \prod_{l=1}^kd_l-\prod_{l=2}^kd_l + \prod_{l=2}^kd_l-\prod_{l=3}^kd_l+\prod_{l=3}^kd_l-\prod_{l=4}^kd_l+i_4\prod_{l=5}^kd_l+\sum_{j=5}^ki_j\prod_{l=j+1}^k d_l \right)\\
 &= \prod_{l=5}^kd_l + \prod_{l=4}^kd_l - \prod_{l=1}^kd_l
 \end{align*}

 \section{Transposition backward}

 $l=\sum_{j=1}^ki_j\prod_{l=1}^{j-1}d_l$ corresponds to $m=\sum_{j=1}^ki'_j\prod_{l=1}^{j-1}d'_l$ such that
 \begin{align*}
  d'_l&=d_{k-l+1} \\
  i'_j&=d'_{j}-i_{k-j+1} -1\\
  &=d_{k-j+1}-i_{k-j+1}-1 \\
 \end{align*}

 \begin{align*}
  m&=\sum_{j=1}^ki'_j\prod_{l=1}^{j-1}d'_l\\
  &=\sum_{j=1}^k\left(d_{k-j+1}-i_{k-j+1}-1\right)\prod_{l=1}^{j-1}d_{k-l+1}\\
&t=k-j+1 \Rightarrow j=k-t+1\\
&j=1 \Rightarrow t=k\\
&j=k \Rightarrow t=1\\
  m&=\sum_{t=k}^1\left(d_{t}-i_{t}-1\right)\prod_{l=1}^{k-t+1-1}d_{k-l+1}\\
  m&=\sum_{t=1}^k\left(d_{t}-i_{t}-1\right)\prod_{l=1}^{k-t}d_{k-l+1}\\
&s=k-l+1 \Rightarrow l=k-s+1\\
&l=1 \Rightarrow s=k\\
&l=k-t \Rightarrow s=k-(k-t)+1=t+1\\
  m&=\sum_{t=1}^k\left(d_{t}-i_{t}-1\right)\prod_{s=k}^{t+1}d_{s}\\
  m&=\sum_{t=1}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
 \end{align*}
if $i_1<d_1-1$ then
\begin{align*}
 l+1&=\sum_{j=1}^ki_j\prod_{l=1}^{j-1}d_l+1\\
 &=i_1 +1 + \sum_{j=2}^ki_j\prod_{l=1}^{j-1}d_l\\
\end{align*}
corresponds to
\begin{align*}
  m'&=(d_1-(i_1+1)-1)\prod_{s=2}^kd_s+ \sum_{t=2}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
  &=(d_1-i_1-2)\prod_{s=2}^kd_s+ \sum_{t=2}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
\end{align*}
\begin{align*}
 m'-m&=(d_1-i_1-2)\prod_{s=2}^kd_s+ \sum_{t=2}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
 &-\left( (d_1-i_1-1) \prod_{s=2}^kd_s+ \sum_{t=2}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s} \right)\\
 &=-\prod_{s=2}^kd_s\\
\end{align*}

if $i_1=d_1-1$ and $i_2<d_2-1$ then
\begin{align*}
 l+1&=\sum_{j=1}^ki_j\prod_{l=1}^{j-1}d_l+1\\
 &=d_1-1 +1 + \sum_{j=2}^ki_j\prod_{l=1}^{j-1}d_l\\
 &=d_1 + i_2d_1+ \sum_{j=3}^ki_j\prod_{l=1}^{j-1}d_l\\
 &=(i_2+1)d_1 +\sum_{j=3}^ki_j\prod_{l=1}^{j-1}d_l\\
\end{align*}
corresponds to
\begin{align*}
  m'&=(d_1-0-1)\prod_{s=2}^kd_s+\left(d_2-(i_2+1)-1\right)\prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
  &=(d_1-1)\prod_{s=2}^kd_s+(d_2-i_2-2)\prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
\end{align*}
\begin{align*}
 m'-m&=(d_1-1)\prod_{s=2}^kd_s+(d_2-i_2-2)\prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
 &-\left( (d_1-(d_1-1)-1) \prod_{s=2}^kd_s+ (d_2-i_2-1) \prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s} \right)\\
&=(d_1-1)\prod_{s=2}^kd_s+(d_2-i_2-2)\prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s}\\
 &-\left( 0\prod_{s=2}^kd_s+ (d_2-i_2-1) \prod_{s=3}^kd_s+ \sum_{t=3}^k\left(d_{t}-i_{t}-1\right)\prod_{s=t+1}^{k}d_{s} \right)\\
  \\
 &= (d_1-1)\prod_{s=2}^kd_s- \prod_{s=3}^kd_s \\
 \end{align*}
 \subsection{properties}
 \begin{align*}
  M_{(k_1,k_n)}&=\sum_{j=k_1}^{k_n}(d_j-1)\prod_{l=j+1}^{k_n}d_j\\
 &=\sum_{j=k_1}^{k_n}\left(\prod_{l=j}^{k_n}d_j-\prod_{l=j+1}^{k_n}d_j\right)\\
 &=\left(\prod_{l=k_1}^{k_n}d_j-\prod_{l=k_1+1}^{k_n}d_j\right)\\
 &+\left(\prod_{l=k_1+1}^{k_n}d_j-\prod_{l=k_1+2}^{k_n}d_j\right)\\
 & + \vdots  \\
 &+\left(\prod_{l=k_n-1}^{k_n}d_j-\prod_{l=k_n}^{k_n}d_j\right)\\
 &+\left(\prod_{l=k_n}^{k_n}d_j-\prod_{l=k_n+1}^{k_n}d_j\right)\\
 &=\prod_{l=k_1}^{k_n}d_j -1\\
 \end{align*}

 \begin{align*}
  M_{(k_1,k_n)}&=\sum_{j=k_1}^{k_n}(d_j-1)\prod_{l=k_1}^{j-1}d_j\\
 &=\sum_{j=k_1}^{k_n}\left(\prod_{l=k_1}^{j}d_j-\prod_{l=k_1}^{j-1}d_j\right)\\
 &=\left(\prod_{l=k_1}^{k_1}d_j-\prod_{l=k_1}^{k_1-1}d_j\right)\\
 &+\left(\prod_{l=k_1}^{k_1+1}d_j-\prod_{l=k_1}^{k_1}d_j\right)\\
 & + \vdots  \\
 &+\left(\prod_{l=k_1}^{k_n-1}d_j-\prod_{l=k_1}^{k_n-2}d_j\right)\\
 &+\left(\prod_{l=k_1}^{k_n}d_j-\prod_{l=k_1}^{k_n-1}d_j\right)\\
 &=\prod_{l=k_1}^{k_n}d_j -1 \\
 \end{align*}

 $m=\sum_{j=1}^ki_j\prod_{l=j+1}^kd_l$ with $i_1=0$ so


 \begin{align*}
 m &=\sum_{j=2}^ki_j\prod_{l=j+1}^kd_l \le  \prod_{l=2}^kd_l-1\\
 m - \prod_{s=2}^kd_s & \le -1\\
 \end{align*}
So if $ m - \prod_{s=2}^kd_s  \le -1$ then
$$m'= m + (d_1-1)\prod_{s=2}^kd_s- \prod_{s=3}^kd_s  $$

but $i_2<d_2-1$ then $m=(d_2-1-i_2)\prod_{l=3}^kd_l+\sum_{j=3}^ki_j\prod_{l=j+1}^kd_l$

\begin{align*}
\prod_{l=2}^kd_l -1 \ge \sum_{j=3}^ki_j\prod_{l=j+1}^kd_l & \ge 0\\
 d_2-1-i_2 &\ge 1 \\
 (d_2-1-i_2)\prod_{l=3}^kd_l  &\ge \prod_{l=3}^kd_l \\
 \prod_{l=2}^kd_l -1 \ge m &\ge \prod_{l=3}^kd_l\\
(d_1-1)\prod_{l=2}^kd_l + \prod_{l=2}^kd_l -1\ge m + (d_1-1)\prod_{l=2}^kd_l  &\ge (d_1-1)\prod_{l=2}^kd_l+ \prod_{l=3}^kd_l \\
(d_1-1)\prod_{l=2}^kd_l + \prod_{l=2}^kd_l -\prod_{l=3}^kd_l -1\ge m + (d_1-1)\prod_{l=2}^kd_l -\prod_{l=3}^kd_l &\ge (d_1-1)\prod_{l=2}^kd_l \\
(d_1-1)\prod_{l=2}^kd_l + (d_2-1)\prod_{l=3}^kd_l -1\ge m + (d_1-1)\prod_{l=2}^kd_l -\prod_{l=3}^kd_l &\ge (d_1-1)\prod_{l=2}^kd_l \\
% -1\ge m-\prod_{l=2}^kd_l &\ge \prod_{l=3}^kd_l - \prod_{l=2}^kd_l \\
% -1\ge m-\prod_{l=2}^kd_l &\ge \prod_{l=3}^kd_l - \prod_{l=2}^kd_l \\
% \prod_{l=1}^kd_l-1\ge m+\prod_{l=1}^kd_l-\prod_{l=2}^kd_l &\ge \prod_{l=1}^kd_l - \prod_{l=2}^kd_l + \prod_{l=3}^kd_l = (d_1-1)\prod_{l=2}^kd_l + \prod_{l=3}^kd_l\\
% \prod_{l=1}^kd_l-1-\prod_{l=3}^kd_l\ge m+\prod_{l=1}^kd_l-\prod_{l=2}^kd_l - \prod_{l=3}^kd_l &\ge \prod_{l=1}^kd_l - \prod_{l=2}^kd_l   = (d_1-1)\prod_{l=2}^kd_l \\
%  &= (d_1-1)\prod_{s=2}^kd_s- \prod_{s=3}^kd_s \\
\end{align*}



if $i_1=d_1-1$ and $i_2=d_2-1$ and $i_3<d_3-1$
\begin{align*}
 l+1&=\sum_{j=1}^ki_j\prod_{l=1}^{j-1}d_l+1\\
 &=d_1-1 +1 + (d_2-1)d_1 +  i_3d_1d_2 + \sum_{j=4}^ki_j\prod_{l=1}^{j-1}d_l\\
 &=d_1 + d_1d_2-d_1+   i_3d_1d_2 + \sum_{j=4}^ki_j\prod_{l=1}^{j-1}d_l\\
 &=(i_3+1)d_1d_2 +\sum_{j=4}^ki_j\prod_{l=1}^{j-1}d_l\\
\end{align*}
corresponds to
\begin{align*}
 m'&=(d_1-1)\prod_{s=2}^kd_s+(d_2-1)\prod_{s=3}^kd_s + (d_3-(i_3+1)-1)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
 m'&=(d_1-1)\prod_{s=2}^kd_s+(d_2-1)\prod_{s=3}^kd_s + (d_3-i_3-2)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
\end{align*}
\begin{align*}
 m'-m&=(d_1-1)\prod_{s=2}^kd_s+(d_2-1)\prod_{s=3}^kd_s + (d_3-i_3-2)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
&-\left((d_1-(d_1-1)-1)\prod_{s=2}^kd_s+(d_2-(d_2-1)-1)\prod_{s=3}^kd_s \right. \\
& \left.+ (d_3-(i_3)-1)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\right)\\
&=(d_1-1)\prod_{s=2}^kd_s+(d_2-1)\prod_{s=3}^kd_s + (d_3-i_3-2)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
&-\left((0)\prod_{s=2}^kd_s+(0)\prod_{s=3}^kd_s + (d_3-(i_3)-1)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\right)\\
&=(d_1-1)\prod_{s=2}^kd_s+(d_2-1)\prod_{s=3}^kd_s -\prod_{s=4}d_s\\
 &=\prod_{s=1}^kd_s-\prod_{s=2}^kd_s+\prod_{s=2}^kd_s-\prod_{s=3}^kd_s -\prod_{s=4}d_s\\
 &=\prod_{s=1}^kd_s-\prod_{s=3}^kd_s -\prod_{s=4}d_s\\
\end{align*}

\begin{align*}
m + \prod_{s=1}^kd_s-\prod_{s=2}^kd_s - \prod_{s=3}^kd_s &= \left((0)\prod_{s=2}^kd_s+(0)\prod_{s=3}^kd_s + (d_3-(i_3)-1)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\right)\\
&+\prod_{s=1}^kd_s-\prod_{s=2}^kd_s - \prod_{s=3}^kd_s\\
&= \prod_{s=1}^kd_s-\prod_{s=2}^kd_s - \prod_{s=3}^kd_s + (d_3-i_3-2)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
\end{align*}
\begin{align*}
 m+ (d_1-1)\prod_{s=2}^kd_s - \prod_{s=3}^kd_s &=\left((0)\prod_{s=2}^kd_s+(0)\prod_{s=3}^kd_s + (d_3-(i_3)-1)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\right)\\
& +(d_1-1)\prod_{s=2}^kd_s - \prod_{s=3}^kd_s\\
 \end{align*}
as $i_1=d_1-1$ and $i_2=d_2-1$ and $i_3<d_3-1$
 \begin{align*}
m&= (d_3-1-i_3)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
m-\prod_{l=2}^kd_l&= -\prod_{l=2}^kd_l+ (d_3-1-i_3)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s\\
 \end{align*}
\begin{align*}
 (d_3-1-i_3)&\ge 1\\
 (d_3-1-i_3)\prod_{s=4}d_s &\ge  \prod_{s=4}d_s \\
 \sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s  &\ge 0 \\
\prod_{l=3}^k d_l \ge (d_3-1-i_3)\prod_{s=4}d_s+\sum_{j=4}^k(d_j-i_j-1)\prod_{s=j+1}^kd_s &\ge  \prod_{s=4}d_s \\
\prod_{l=3}^k d_l -1 \ge m &\ge  \prod_{s=4}d_s \\
0 > \prod_{l=3}^k d_l -1  -\prod_{l=2}^k d_l \ge m-\prod_{l=2}^k d_l  &\ge  \prod_{s=4}d_s - \prod_{l=2}^k d_l  \\
(d_1-1)\prod_{l=2}^k+\prod_{l=3}^k d_l \ge m +(d_1-1)\prod_{l=2}^k -1 &\ge (d_1-1)\prod_{l=2}^k+  \prod_{s=4}d_s \\
% (1-d_2)\prod_{l=3}^k d_l   \ge m-\prod_{l=2}^k d_l  &\ge  \prod_{s=4}d_s - \prod_{l=2}^k d_l  \\
% (1-d_2)\prod_{l=3}^k d_l   \ge m-\prod_{l=2}^k d_l  &\ge  \prod_{s=4}d_s - \prod_{s=3}d_s + \prod_{s=3}d_s - \prod_{l=2}^k d_l  \\
% (1-d_2)\prod_{l=3}^k d_l   \ge m-\prod_{l=2}^k d_l  &\ge  (1-d_3)\prod_{s=4}d_s + (1-d_2) \prod_{s=3}d_s   \\
\end{align*}











 Perhaps, it's a little endian rewrite in big endian


For any $i\in \mathbb{N} , i<n=\prod_{j=1}^kd_j \exists! (i_1, \ldots, i_k) / \forall 1 \le j \le k,  0\le i_j<d_j$ and $$ i=\sum_{j=1}^{k} i_j\left( \prod_{l=1}^{j-1} d_l \right) $$


The inverse of big endian :

For any $i\in \mathbb{N} , i<n=\prod_{j=1}^kd_j \exists! (i_1, \ldots, i_k) / \forall 1 \le j \le k,  0\le i_j<d_j$ and $$ i=\sum_{s=1}^k i_s\left( \prod_{l=s+1}^k d_l \right) $$


\begin{align*}
 \sum_{j=1}^{k} i_j\left( \prod_{l=1}^{j-1} d_l \right) +1
\end{align*}

\begin{align*}
l=0 &\Rightarrow m=0 \\
l=1 &\Rightarrow m=\prod_{l=2}^kd_l \\
l=2 &\Rightarrow m=2\prod_{l=2}^kd_l \\
\vdots\\
l=d_1-1 &\Rightarrow m=(d_1-1)\prod_{l=2}^kd_l = \prod_{l=1}d_l - \prod_{l=2}^k d_l \\
l=d_1 &\Rightarrow m= \prod_{l=3}^kd_l \\
l=d_1+1 &\Rightarrow m= \prod_{l=2}^kd_l + \prod_{l=3}^kd_l \\
l=d_1+2 &\Rightarrow m= 2 \prod_{l=2}^kd_l + \prod_{l=3}^kd_l \\
\vdots \\
l=d_1+d_1-1 = 2 d_1-1 &\Rightarrow m= (d_1-1) \prod_{l=2}^kd_l + \prod_{l=3}^kd_l \\
l=d_1+d_1 = 2d_1 &\Rightarrow m= 2 \prod_{l=3}^kd_l \\
l=2d_1+1 &\Rightarrow m= \prod_{l=2}^kd_l + 2\prod_{l=3}^kd_l \\
l=2d_1+2 &\Rightarrow m= 2 \prod_{l=2}^kd_l + 2\prod_{l=3}^kd_l \\
\end{align*}


\section{Examples}
In these examples, we note ${\alpha}_{(i_1,\ldots,i_k)}^{\left[n_{\left(i_1,\ldots,i_k\right)}\right]} $ such that $\left(i_1,\ldots,i_k\right)\in\mathbb{N}^k $ and $n_{(i_1,\ldots,i_k)}\in \mathbb{N} $, the index of tensor of order $k$ is $\left(i_1,\ldots,i_k \right)$ and the correspondant index in tensor of order $1$ is $\left[n_{\left(i_1,\ldots,i_k\right)}\right]$
\hrule
\vspace{1cm}
Big endian $k=2$
\begin{align*}
 \left( \left( {\alpha}_{(0,0)}^{[0]},{\alpha}_{(0,1)}^{[d_2]},\ldots, {\alpha}_{(0,d_1-1)}^{[(d_1-1)d_2]} \right)\right. \\
\left( {\alpha}_{(1,0)}^{[1]},{\alpha}_{(1,1)}^{[d_2+1]},\ldots, {\alpha}_{(1,d_1-1)}^{[(d_1-1)d_2+1]} \right) \\
   \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
\left( {\alpha}_{(d_2-1,0)}^{[d_2-1]},{\alpha}_{(d_2-1,1)}^{[2d_2-1]},\ldots, {\alpha}_{(d_2-1,d_1-1)}^{[(d_2-1)d_1 +d_1-1]} \right) \\
\end{align*}

\hrule
\vspace{1cm}
little endian $k=2$
\begin{align*}
 \left( \left( {\alpha}_{(0,0)}^{[0]},{\alpha}_{(0,1)}^{[1]},\ldots, {\alpha}_{(0,d_1-1)}^{[d_1-1]} \right)\right. \\
\left( {\alpha}_{(1,0)}^{[d_1]},{\alpha}_{(1,1)}^{[d_1+1]},\ldots, {\alpha}_{(1,d_1-1)}^{[2d_1-1]} \right) \\
   \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
\left( {\alpha}_{(d_2-1,0)}^{[(d_2-1)d_1]},{\alpha}_{(d_2-1,1)}^{[(d_2-1)d_1+1]},\ldots, {\alpha}_{(d_2-1,d_1-1)}^{[(d_2-1)d_1 +d_1-1]} \right) \\
\end{align*}

\hrule
\vspace{1cm}
little endian $k=3$
\begin{align*}
 \left( \left( \left({\alpha}_{(0,0,0)}^{[0]},{\alpha}_{(0,0,1)}^{[1]},\ldots,{\alpha}_{(0,0,d_1-1)}^{[d_1-1]} \right) \right. \right.\\
  \left({\alpha}_{(0,1,0)}^{[d_1]},{\alpha}_{(0,1,1)}^{[d_1+1]},\ldots,{\alpha}_{(0,1,d_1-1)}^{[2d_1-1]} \right)  \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
   \left. \left({\alpha}_{(0,d_2-1,0)}^{[(d_2-1)d_1]},{\alpha}_{(0,d_2-1,1)}^{[(d_2-1)d_1+1]},\ldots,{\alpha}_{(0,d_2-1,d_1-1)}^{[d_1 d_2-1]} \right) \right)  \\
 \left( \left({\alpha}_{(1,0,0)}^{[d_1 d_2]},{\alpha}_{(1,0,1)}^{[d_1 d_2+1]},\ldots,{\alpha}_{(1,0,d_1-1)}^{[d_1 d_2+d_1-1]} \right) \right. \\
  \left({\alpha}_{(1,1,0)}^{[d_1 d_2+d_1]},{\alpha}_{(1,1,1)}^{[d_1 d_2+d_1+1]},\ldots,{\alpha}_{(1,1,d_1-1)}^{[d_1 d_2+2d_1-1]} \right)  \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
   \left. \left({\alpha}_{(1,d_2-1,0)}^{[d_1 d_2+(d_2-1)d_1]},{\alpha}_{(1,d_2-1,1)}^{[d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(1,d_2-1,d_1-1)}^{[d_1 d_2+(d_2-1)d_1+d_1-1]} \right) \right)  \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
   \left( \left({\alpha}_{(d_3-1,0,0)}^{[(d_3-1)d_1 d_2]},{\alpha}_{(d_3-1,0,1)}^{[(d_3-1)d_1 d_2+1]},\ldots,{\alpha}_{(d_3-1,0,d_1-1)}^{[(d_3-1)d_1 d_2+d_1-1]} \right) \right. \\
  \left({\alpha}_{(d_3-1,1,0)}^{[(d_3-1)d_1 d_2+d_1]},{\alpha}_{(d_3-1,1,1)}^{[(d_3-1)d_1 d_2+d_1+1]},\ldots,{\alpha}_{(1,1,d_1-1)}^{[(d_3-1)d_1 d_2+2d_1-1]} \right)  \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
   \left. \left. \left({\alpha}_{(d_3-1,d_2-1,0)}^{[(d_3-1)d_1 d_2+(d_2-1)d_1]},{\alpha}_{(d_3-1,d_2-1,1)}^{[(d_3-1)d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(d_3-1,d_2-1,d_1-1)}^{[(d_3-1)d_1 d_2+(d_2-1)d_1+d_1-1]} \right)\right) \right)  \\
   \end{align*}

   \hrule
\vspace{1cm}
little endian $k=4$

\begin{align*}
& \left( \left( \left( \left({\alpha}_{(0,0,0,0)}^{[0]},{\alpha}_{(0,0,0,1)}^{[1]},\ldots,{\alpha}_{(0,0,0,d_1-1)}^{[d_1-1]} \right) \right. \right. \right. \\
&  \left({\alpha}_{(0,0,1,0)}^{[d_1]},{\alpha}_{(0,0,1,1)}^{[d_1+1]},\ldots,{\alpha}_{(0,0,1,d_1-1)}^{[2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(0,0,d_2-1,0)}^{[(d_2-1)d_1]},{\alpha}_{(0,0,d_2-1,1)}^{[(d_2-1)d_1+1]},\ldots,{\alpha}_{(0,0,d_2-1,d_1-1)}^{[d_1 d_2-1]} \right) \right)  \\
& \left( \left({\alpha}_{(0,1,0,0)}^{[d_1 d_2]},{\alpha}_{(0,1,0,1)}^{[d_1 d_2+1]},\ldots,{\alpha}_{(0,1,0,d_1-1)}^{[d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(0,1,1,0)}^{[d_1 d_2+d_1]},{\alpha}_{(0,1,1,1)}^{[d_1 d_2+d_1+1]},\ldots,{\alpha}_{(0,1,1,d_1-1)}^{[d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(0,1,d_2-1,0)}^{[d_1 d_2+(d_2-1)d_1]},{\alpha}_{(0,1,d_2-1,1)}^{[d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(0,1,d_2-1,d_1-1)}^{[d_1 d_2+(d_2-1)d_1+d_1-1]} \right) \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left( \left({\alpha}_{(0,d_3-1,0,0)}^{[(d_3-1)d_1 d_2]},{\alpha}_{(0,d_3-1,0,1)}^{[(d_3-1)d_1 d_2+1]},\ldots,{\alpha}_{(0,d_3-1,0,d_1-1)}^{[(0,d_3-1)d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(0,d_3-1,1,0)}^{[(d_3-1)d_1 d_2+d_1]},{\alpha}_{(0,d_3-1,1,1)}^{[(d_3-1)d_1 d_2+d_1+1]},\ldots,{\alpha}_{(0,1,1,d_1-1)}^{[(d_3-1)d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
   %\\
&    \left( \left( \left({\alpha}_{(1,0,0,0)}^{[d_1 d_2 d_3]},{\alpha}_{(1,0,0,1)}^{[d_1 d_2 d_3+1]},\ldots,{\alpha}_{(1,0,0,d_1-1)}^{[d_1 d_2 d_3+d_1-1]} \right) \right. \right.\\
&  \left({\alpha}_{(1,0,1,0)}^{[d_1 d_2 d_3+d_1]},{\alpha}_{(1,0,1,1)}^{[d_1 d_2 d_3+d_1+1]},\ldots,{\alpha}_{(1,0,1,d_1-1)}^{[d_1 d_2 d_3+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(1,0,d_2-1,0)}^{[d_1 d_2 d_3+(d_2-1)d_1]},{\alpha}_{(1,0,d_2-1,1)}^{[d_1 d_2 d_3+(d_2-1)d_1+1]},\ldots,{\alpha}_{(1,0,d_2-1,d_1-1)}^{[d_1 d_2 d_3+d_1 d_2-1]} \right) \right)  \\
& \left( \left({\alpha}_{(1,1,0,0)}^{[d_1 d_2 d_3+d_1 d_2]},{\alpha}_{(1,1,0,1)}^{[d_1 d_2 d_3+d_1 d_2+1]},\ldots,{\alpha}_{(1,1,0,d_1-1)}^{[d_1 d_2 d_3+d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(1,1,1,0)}^{[d_1 d_2 d_3+d_1 d_2+d_1]},{\alpha}_{(1,1,1,1)}^{[d_1 d_2 d_3+d_1 d_2+d_1+1]},\ldots,{\alpha}_{(1,1,1,d_1-1)}^{[d_1 d_2 d_3+d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(1,1,d_2-1,0)}^{[d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1]},{\alpha}_{(1,1,d_2-1,1)}^{[d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(1,1,d_2-1,d_1-1)}^{[d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1+d_1-1]} \right) \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
      \end{align*}

   \begin{align*}
&   \left( \left({\alpha}_{(1,d_3-1,0,0)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2]},{\alpha}_{(1,d_3-1,0,1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+1]},\ldots,{\alpha}_{(1,d_3-1,0,d_1-1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(1,d_3-1,1,0)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1]},{\alpha}_{(1,d_3-1,1,1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1+1]},\ldots,{\alpha}_{(1,1,1,d_1-1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left. \left({\alpha}_{(1,d_3-1,d_2-1,0)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1]},{\alpha}_{(1,d_3-1,d_2-1,1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(1,d_3-1,d_2-1,d_1-1)}^{[d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1+d_1-1]} \right)\right) \right)  \\
   %\\
&   \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
      %\\
&    \left( \left( \left({\alpha}_{(d_4-1,0,0,0)}^{[(d_4-1)d_1 d_2 d_3]},{\alpha}_{(d_4-1,0,0,1)}^{[(d_4-1)d_1 d_2 d_3+1]},\ldots,{\alpha}_{(d_4-1,0,0,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+d_1-1]} \right) \right. \right.\\
&  \left({\alpha}_{(d_4-1,0,1,0)}^{[(d_4-1)d_1 d_2 d_3+d_1]},{\alpha}_{(d_4-1,0,1,1)}^{[(d_4-1)d_1 d_2 d_3+d_1+1]},\ldots,{\alpha}_{(d_4-1,0,1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(d_4-1,0,d_2-1,0)}^{[(d_4-1)d_1 d_2 d_3+(d_2-1)d_1]},{\alpha}_{(d_4-1,0,d_2-1,1)}^{[(d_4-1)d_1 d_2 d_3+(d_2-1)d_1+1]},\ldots,{\alpha}_{(d_4-1,0,d_2-1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2-1]} \right) \right)  \\
& \left( \left({\alpha}_{(d_4-1,1,0,0)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2]},{\alpha}_{(d_4-1,1,0,1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+1]},\ldots,{\alpha}_{(d_4-1,1,0,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(d_4-1,1,1,0)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+d_1]},{\alpha}_{(d_4-1,1,1,1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+d_1+1]},\ldots,{\alpha}_{(d_4-1,1,1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left. \left({\alpha}_{(d_4-1,1,d_2-1,0)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1]},{\alpha}_{(d_4-1,1,d_2-1,1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1+1]},\ldots,{\alpha}_{(d_4-1,1,d_2-1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+d_1 d_2+(d_2-1)d_1+d_1-1]} \right) \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
&   \left( \left({\alpha}_{(d_4-1,d_3-1,0,0)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2]},{\alpha}_{(d_4-1,d_3-1,0,1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+1]},\ldots,{\alpha}_{(d_4-1,d_3-1,0,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1-1]} \right) \right. \\
&  \left({\alpha}_{(d_4-1,d_3-1,1,0)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1]},{\alpha}_{(d_4-1,d_3-1,1,1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+d_1+1]},\ldots,{\alpha}_{(d_4-1,1,1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+2d_1-1]} \right)  \\
&  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
& \left.  \left. \left. \left({\alpha}_{(d_4-1,d_3-1,d_2-1,0)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1]},
%{\alpha}_{(d_4-1,d_3-1,d_2-1,1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1+1]},
\ldots,
%\right.\right.\right.\\
%&\ldots,\left.\left.\left.
{\alpha}_{(d_4-1,d_3-1,d_2-1,d_1-1)}^{[(d_4-1)d_1 d_2 d_3+(d_3-1)d_1 d_2+(d_2-1)d_1+d_1-1]} \right)\right) \right) \right) \\
   \end{align*}
\hrule


\iffalse

\begin{align*}
 \left(  \left( \left( {\alpha}_{(0,0,0,0)},{\alpha}_{(0,0,0,1)},\ldots,{\alpha}_{(0,0,0,d_1-1)} \right) \right. \right. \\
  \left( {\alpha}_{(0,0,1,0)},{\alpha}_{(0,0,1,1)},\ldots,{\alpha}_{(0,0,1,d_1-1)} \right) \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
 \left. \left( {\alpha}_{(0,0,d_2-1,0)},{\alpha}_{(0,0,d_2-1,1)},\ldots,{\alpha}_{(0,0,d_2-1,d_1-1)} \right) \right) \\
\left( \left( {\alpha}_{(0,1,0,0)},{\alpha}_{(0,1,0,1)},\ldots,{\alpha}_{(0,1,0,d_1-1)} \right) \right. \\
  \left( {\alpha}_{(0,1,1,0)},{\alpha}_{(0,1,1,1)},\ldots,{\alpha}_{(0,1,1,d_1-1)} \right) \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
 \left. \left( {\alpha}_{(0,1,d_2-1,0)},{\alpha}_{(0,1,d_2-1,1)},\ldots,{\alpha}_{(0,1,d_2-1,d_1-1)} \right) \right) \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
\left( \left( {\alpha}_{(0,d_3-1,0,0)},{\alpha}_{(0,d_3-1,0,1)},\ldots,{\alpha}_{(0,d_3-1,0,d_1-1)} \right) \right. \\
  \left( {\alpha}_{(0,d_3-1,1,0)},{\alpha}_{(0,d_3-1,1,1)},\ldots,{\alpha}_{(0,d_3-1,1,d_1-1)} \right) \\
  \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots \hspace{1cm} \vdots   \\
 \left. \left( {\alpha}_{(0,d_3-1,d_2-1,0)},{\alpha}_{(0,d_3-1,d_2-1,1)},\ldots,{\alpha}_{(0,d_3-1,d_2-1,d_1-1)} \right) \right) \\
\end{align*}
\fi


\iffalse
\begin{EnvTikzEspace}
\draw[->,>=latex] (0,0,0)--(1,0,0) node[right] {$\vec{\imath}$} ;
\draw[->,>=latex] (0,0,0)--(0,1,0) node[right] {$\vec{\jmath}$} ;
\draw[->,>=latex] (0,0,0)--(0,0,1) node[above] {$\vec{k}$} ;
\end{EnvTikzEspace}

\begin{EmpilementCubes}
\BlocPetitsCubes{1,2,3,4,5 / 0,2,1,1,3 / 0,2,1,1,2 / 1,1,1,1,3}
\end{EmpilementCubes}
\fi

\iffalse
\begin{tikzpicture}
 \draw (0,0,0)--(1,0,0)--(1,1,0)--(0,1,0)--cycle; % face arrière
\draw (0,0,1)--(1,0,1)--(1,1,1)--(0,1,1)--cycle; % face avant
% arêtes horizontales, de l’arrière vers l’avant
\draw (0,0,0) -- (0,0,1); % bas gauche
\draw (1,0,0) -- (1,0,1); % bas droit
\draw (1,1,0) -- (1,1,1); % haut droit
\draw (0,1,0) -- (0,1,1); % haut gauche
\end{tikzpicture}

\newcommand{\xangle}{13} %{15}
\newcommand{\yangle}{160}%{153}
\newcommand{\zangle}{90}

\newcommand{\xlength}{1}
\newcommand{\ylength}{1}
\newcommand{\zlength}{1}

\newcommand{\dimension}{1}% actually dimension-1

\pgfmathsetmacro{\xx}{\xlength*cos(\xangle)}
\pgfmathsetmacro{\xy}{\xlength*sin(\xangle)}
\pgfmathsetmacro{\yx}{\ylength*cos(\yangle)}
\pgfmathsetmacro{\yy}{\ylength*sin(\yangle)}
\pgfmathsetmacro{\zx}{\zlength*cos(\zangle)}
\pgfmathsetmacro{\zy}{\zlength*sin(\zangle)}

\begin{tikzpicture}
[   x={(\xx cm,\xy cm)},
    y={(\yx cm,\yy cm)},
    z={(\zx cm,\zy cm)},
]
\foreach \a in {0,...,\dimension}
{   \foreach \b in {0,...,\dimension}
    {   \pgfmathsetmacro{\c}{100-\a*7-\b*7}
        \draw[canvas is xy plane at z=\a, black!\c] (\b,0) -- (\b,\dimension) (0,\b) -- (\dimension,\b);
        \draw[canvas is xz plane at y=\a, black!\c] (\b,0) -- (\b,\dimension) (0,\b) -- (\dimension,\b);
        \draw[canvas is yz plane at x=\a, black!\c] (\b,0) -- (\b,\dimension) (0,\b) -- (\dimension,\b);
    }
}
\pgfmathsetmacro{\dim}{\dimension-1}
\foreach \a in {0,...,\dimension}
{   \foreach \b in {0,...,\dimension}
    {   \foreach \c in {0,...,\dimension}
        {
        \pgfmathsetmacro{\d}{\c+\b*\dimension+\a*\dimension*\dimension}
%        \fill (\a,\b,\c) circle (0.05cm);
        \node (1) at (\a,\b,\c) {$\d$};
        }
    }
}
\end{tikzpicture}
\fi



\end{document}
