In my current macro, I have:
DeleteCases[Chop[FullSimplify[RowReduce[something]]], {0 ..}]
This works fine for both, exact and numeric complex numbers (with modules of the order of 1 at most) in my "something".
However, the returned result is "Chop
-ped", of course.
I would like to get the full precision (for all elements) also in numeric cases.
I tried to use:
DeleteCases[RowReduce[something], {x_..}/;PossibleZeroQ[Chop[FullSimplify[x]]]]
This works fine as long as long as all "x
" (in a "row") are exactly equal.
So, e.g. it does remove {1.*^-11, 1.*^-11}
but unfortunately it does not remove {0, 1*.^-11}
nor {1.*^-11, 0}
.
Could you, please, help me with it.
Update (2019.08.05): Thank you very much for all your neat examples. I decided to use (I hope it really does what I "intend" it to do):
DeleteCases[FullSimplify[RowReduce[FullSimplify[something], ZeroTest->(PossibleZeroQ[Chop[FullSimplify[#]]]&)]], {__?(PossibleZeroQ[Chop[FullSimplify[#]]]&)}]
Solutions based on Pick
have two problems for me. First, they completely remove "rows" with empty lists (i.e. {}
). Second, the very first step is Chop
, which unconditionally evaluates all elements of all "rows" while, in the solution based on DeleteCases
, the {__?(TrueOrFalse[#]&)}
pattern will evaluate elements of each "row" only until the first one that returns "False" (at least that's how I imagine it works). Also, the solution which uses Total
would need an additional Abs
inside, otherwise it completely removes "rows" which elements sum up to 0 (e.g. {-1, 1}
).