The implementation of similarity(MatrixRow a, MatrixRow b) has been made faster now because the while loop does no longer have to store the columns two times in the variable.

The implementation of similarity(MatrixRow a, MatrixRow b) has been made faster now because the while loop does no longer have to store the columns two times in the variable.
This will throw an out of bounds index if there are 0 columns. You can just return 0 if one of the vectors has length 0.