Simplifying code with matrix_extensions