Let's say I have an Eigen matrix with many values that are close to zero:
M =
[ 0, 0, 0, 0]
[ 0.0045549, -0.048242, 0.0069165, 9.7007e-07]
[ 0.048251, 0.004541, -0.0046149, 1.8313e-06]
What is the most efficient way to write a function that takes this matrix and sets to 0 the values that are close to zero within a certain tolerance, e.g.:
setAlmostZeroToZero(M, 1e-4) =
[ 0, 0, 0, 0]
[ 0.0045549, -0.048242, 0.0069165, 0]
[ 0.048251, 0.004541, -0.0046149, 0]