Generic Matrix Multiply Function