Spoiler alert: It’s just a bunch of dot products

The way I’m currently twiddling my thumbs and waiting for the world to end is building my very own linear algebra package in Java (make fun of it on github). It’s a good excuse to revisit Euclidean vector spaces through a programming lens, to figure out if I really understand it as well as I like to pretend I do.

I always had to double and triple check my computations when doing multiplying matrices on timed linear algebra exams (because I was prone to making a mistake while trying to take a shortcut), so I had built it up as something much worse than it actually turned out to be in my head.

Fortunately, past me did present me a solid by including a dot product function in my Vector class, which I posted about last week. The Vector class has a private field, v , which is a double array, so we can think of Vector objects as lists of numbers.

If you aren’t familiar with the dot product, it is a binary operation which takes two vectors and maps them to a real number by multiplying the corresponding entries, then adding all of the products together.

Image for post

Example of a dot product from Wikipedia

Dot products are an important operation when working with vectors (and are they key to making matrix multiplication so simple), so if you’re still not quite sure what you’re looking at, the “good stuff” in this post will get confusing fast. Here’s a great explanation from Khan Academy of how to compute the dot product––we’ll get to why this is so useful in a little bit.

#java #dot-product #linear-algebra #matrix-multiplication #mathematics

Matrix Multiplication Made Easy (In Java)
2.90 GEEK