JSMatrix

We will be dealing with lots of vectors and matrices. This course uses the JSMatrix library for all vector and matrix operations.

While probably not the fastest library, it should be decently feature complete, with some advanced features like matrix decompositions. Additionally it is designed to provide lots of ways to access and work with elements of matrices and vectors, such as non-copy transpose, block-views, reductions and more. I am also the author, so sorry about the blatant self promotion!

Documentation can be found at the linked repository.

All functions are accessible under the variable jsm.

Since JavaScript sadly does not have operator overloading, math operations such as ++ have to be computed using functions, in this case jsm.add.

To make things slightly easier, a number of common functions are already provided at the scope of your scripts.

For any of these functions that take an out parameter, you can omit it, in which case a new matrix is created. This is mainly for optimization.

Here is a list of those:

Additionally, as it is commonly used, we defined some helper functions for the common 2D, 3D and 4D vectors:

You can try out these functions or any others below to get a feeling. The code section contains example code, but you can change it as you like.