/* We correct the off-diagonal elements,
* which can grow indefinitely during shearing,
* so the shifts do not get messed up.
*/
for (int i = 1; i < DIM; i++)
{
for (int j = i - 1; j >= 0; j--)
{
while (updatedBox[j] - box[j] > 0.5 * updatedBox[j][j])
{
rvec_dec(updatedBox, updatedBox[j]);
}
while (updatedBox[j] - box[j] < -0.5 * updatedBox[j][j])
{
rvec_inc(updatedBox, updatedBox[j]);
}
}
}
invertBoxMatrix(box, invbox);
// Return the updated box
copy_mat(updatedBox, box);
mmul_ur0(box, invbox, mu);