Matrix calculator