# Operations on tensors.

I was self-learning about linear algebra, vectors, matrices, and tensors out of curiosity. When I came upon tensor operations, it was somewhat difficult to digest. I saw its Wikipedia pages and was overwhelmed by the sheer amount of cross references to other pages and similar topics. After going through a bit, here is what I understood. I wanted to know what I learnt was correct.

Sum:
It is an operation that takes in two tensors $$T^p_q$$ and $$U^p_q$$, both with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$ and results in a tensor $$V^p_q$$ with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$.
It is defined as $$v^{i_1...i_p}_{j_1...j_q}=t^{i_1...i_p}_{j_1...j_q}+u^{i_1...i_p}_{j_1...j_q}$$.

Scalar product:
It is an operation that takes in one tensor $$T^p_q$$, with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$ and one scalar $${\lambda}$$ and results in a tensor $$V^p_q$$ with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$.
It is defined as $$v^{i_1...i_p}_{j_1...j_q}={\lambda}{\cdot}t^{i_1...i_p}_{j_1...j_q}$$.

Tensor product:
It is an operation that takes in two tensors $$T^p_q$$ and $$U^r_s$$, with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$ and $$(c_1, c_2, ..., c_r, d_1, d_2, ..., d_s)$$ respectively and results in a tensor $$V^{p+r}_{q+s}$$ with dimensions $$(a_1, a_2, ..., a_p, c_1, c_2, ..., c_r, b_1, b_2, ..., b_q, d_1, d_2, ..., d_s)$$.
It is defined as $$v^{i_1...i_pk_1...k_r}_{j_1...j_ql_1...l_s}=t^{i_1...i_p}_{j_1...j_q}{\cdot}u^{k_1...k_r}_{l_1...l_s}$$.

Kronecker product:
It is an operation that takes in two tensors $$T^p_q$$ and $$U^p_q$$, with dimensions $$(a_1, a_2, ..., a_p, b_1, b_2, ..., b_q)$$ and $$(c_1, c_2, ..., c_p, d_1, d_2, ..., d_q)$$ respectively and results in a tensor $$V^p_q$$ with dimensions $$(a_1c_1, a_2c_2, ..., a_pc_p, b_1d_1, b_2d_2, ...,b_qd_q)$$.
It is defined as $$v^{i_1...i_p}_{j_1...j_q}=t^{w_1...w_p}_{x_1...x_q}{\cdot}u^{y_1...y_p}_{z_1...z_q}$$ where $$w_n=i_n//a_n$$ , $$x_n=j_n//b_n$$ , $$y_n=i_n\%a_n$$ , $$z_n=j_n\%b_n$$.

Contraction:
It is an operation that takes in one tensor $$T^p_q$$, with dimensions $$(a_1, a_2, ..., a_x, ..., a_p, b_1, b_2, ..., b_y, ..., b_q)$$ and two ranks $$x\in1..p$$ and $$y\in1..q$$ and results in a tensor $$V^{p-1}_{q-1}$$ with dimensions $$(a_1, a_2, ..., a_{x-1}, a_{x+1}, ..., a_p, b_1, b_2, ..., b_{y-1}, b_{y+1}, ..., b_q)$$.
It is defined as $$v^{i_1...i_{p-1}}_{j_1...j_{q-1}}=t^{i_1...z...i_p \hspace{1mm};\hspace{1mm} z=i_x}_{j_1...z...j_q \hspace{1mm};\hspace{1mm} z=j_y}$$.

Inner product:
It is just a vector product followed by contraction.

• Notation for physicists? Mar 15, 2022 at 17:30
• @Wuestenfux It was called Einstein notation in the lecture I watched (on YouTube). Mar 15, 2022 at 17:50
• Note that in the definition I wrote for Kronecker product, it assumes a zero-based indexing of dimensions. Aka, $w_n$ and $y_n$ ranges from $0...{a_n-1}$, $x_n$ and $z_n$ ranges from $0...{b_n-1}$. Similar is the case with $i_n$ and $j_n$. Mar 15, 2022 at 20:46

Your assessments are mostly correct, but here are a few nitpicks/clarifications that you might consider helpful. I will use the term "rank" to describe the number of dimension in the array that characterizes the tensor; for instance, vectors are rank 1 tensors and any matrices are rank 2 tensors. A tensor $$T^p_q$$ (per your notation) has rank $$p+q$$.
• Many operations (in addition to the inner product) can be thought of as a contraction. For example, the usual "product" of two matrices is a tensor product of two $$(1,1)$$ tensors followed by a contraction. The trace of a matrix is simply a contraction of a $$(1,1)$$ tensor.