Calculating determinant