Skip to content

Instantly share code, notes, and snippets.

@AndreaPasqualini
Last active July 8, 2019 15:02
Show Gist options
  • Save AndreaPasqualini/707d4982875f71e014b850dbfbdd7b7d to your computer and use it in GitHub Desktop.
Save AndreaPasqualini/707d4982875f71e014b850dbfbdd7b7d to your computer and use it in GitHub Desktop.
A small memo about Kroenecker products and linear indexing
\documentclass{article}
\usepackage{amsmath, amsfonts, amssymb}
\title{Kroenecker Products and Linalg Trickery}
\author{Andrea Pasqualini}
\begin{document}
\maketitle
Consider two vectors, $x$ and $y$.
\begin{align*}
\underset{[n \times 1]}{x} && \underset{[m \times 1]}{y}
\end{align*}
Let $i$ index the elements of $x$ and $j$ index the elements of $y$.
Compute the Kroenecker product $z\equiv x \otimes y$.
The product $x_i \cdot y_j$ will be the element $z_k$, with \textcolor{red}{$k = (i - 1) \cdot m + j$}.
Explicitly, we will have
\begin{align*}
z &\equiv \underset{[(n \cdot m) \times (1 \cdot 1)]}{x \otimes y}
=
\begin{bmatrix}
x_1 \cdot y \\
\hrulefill \\
x_2 \cdot y \\
\hrulefill \\
\vdots \\
\hrulefill \\
x_i \cdot y \\
\hrulefill \\
\vdots \\
\hrulefill \\
x_n \cdot y
\end{bmatrix}
=
\begin{bmatrix}
x_1 \cdot y_1 \\
x_1 \cdot y_2 \\
\vdots \\
x_1 \cdot y_m \\
\hrulefill \\
x_2 \cdot y_1 \\
x_2 \cdot y_2 \\
\vdots \\
x_2 \cdot y_m \\
\hrulefill \\
\vdots \\
\hrulefill \\
x_i \cdot y_1 \\
x_i \cdot y_2 \\
\vdots \\
x_i \cdot y_m \\
\hrulefill \\
\vdots \\
\hrulefill \\
x_n \cdot y_1 \\
x_n \cdot y_2 \\
\vdots \\
x_n \cdot y_m
\end{bmatrix}
\end{align*}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment