code for alg - mat_mult