inverse matrix calculations in R