Added dot product and matrix/vector code, before optimisation
FInal optimisation