mass balances using matrix algebra