making matrix calculation faster on the CPU