Memory allocation must be zeroes in order to correctly calculate the diagonal elements