Matrix and tensor calculus