Given a point mass $m$, located at a point defined by the vector $\vec{r} = \pmatrix{x \\ y \\ z}$ the mass moment of inertia tensor can me defined with one of two different functions (both yielding the same result)
The vector algebra way $$\mathrm{I} = m \left( \vec{r} \cdot \vec{r} - \vec{r} \odot \vec{r} \right)$$
where $\cdot$ is the vector inner product, and $\odot$ the vector outer product.
Specifically $$ \mathrm{I} = m \left( (x^2+y^2+z^2) \mathrm{1} - \begin{vmatrix} x^2 & x y & x z \\ x y & y^2 & y z \\ x z & y z & z^2 \end{vmatrix} \right) = m \begin{vmatrix} y^2+z^2 & -x y & -x z \\ -x y & x^2+z^2 & -y z \\ -x z & -y z & x^2 + y^2 \end{vmatrix} $$
The linear algebra way $$\mathrm{I} = m \left( - [\vec{r}\times][\vec{r}\times] \right)$$
where $[\vec{r}\times]$ is the skew-symmetric cross product operator matrix defined by $ [\vec{r}\times] = \begin{vmatrix} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{vmatrix}$
Specifically $$\mathrm{I} = m \left( - \begin{vmatrix} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{vmatrix} \begin{vmatrix} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{vmatrix} \right) = m \begin{vmatrix} y^2+z^2 & -x y & -x z \\ -x y & x^2+z^2 & -y z \\ -x z & -y z & x^2 + y^2 \end{vmatrix} $$
Both of them are derived from calculating the angular momentum vector of an orbiting point mass and factoring out the rotational velocity vector. The result is $$ \vec{L} = m \,\vec{r} \times (\vec{\omega} \times \vec{r})$$ and if you use the identity $a \times (b \times c) = b (a\cdot c) - c (a \cdot b)$ you end up with the fist expression, and if you use matrix cross product operator $\vec{a}\times \vec{b} = [\vec{a}\times] \vec{b}$ you end up with the second expression.
In terms of programming, I prefer the second one as computers do better with linear algebra, compared with vector algebra
r = vector(x,y,z) = [x,y,z]
cross(r) = [ [0,-r(3),r(2)], [r(3),0,-r(1)], [-r(2),r(1),0] ]
I = m*(-cross(r)*cross(c))
provided that the *
operator can handle matrix multiplication