Implementing matrix operations based on Cabarcas's thesis