performance optimizations of matrix operations.