clean
cleans matrices (round to zero small entries)
Syntax
B = clean(A) B = clean(A, epsa) B = clean(A, epsa, epsr)
Arguments
- A
scalar, vector, matrix or hypermatrix of decimal numbers or of complex numbers, in dense or sparse encoding, or of polynomials or rationals with real or complex coefficients.
- epsa, epsr
positive real numbers: Cleaning tolerances. Both default values are 10-10.
Description
This function sets to 0 all the elements of A
with absolute value <=epsa
or relative value <=epsr
(relative w.r.t. to max(abs(A)), ignoring %inf and %nan values of A
).
For an array of polynomials or of rationals, clean() applies in the same way to the whole set of their coefficients.
Examples
--> m = grand(3,5,"uin",1,9) .* 10.^grand(3,5,"uin",-16,1) m = 5.000D-08 5. 0.8 7.000D-08 4.000D-11 0.00007 7. 4.000D-09 6.000D-13 2.000D-16 2.000D-08 1.000D-14 1. 8. 0.7 --> clean(m) ans = 5.000D-08 5. 0.8 7.000D-08 0. 0.00007 7. 4.000D-09 0. 0. 2.000D-08 0. 1. 8. 0.7 --> clean(m, 1e-7) ans = 0. 5. 0.8 0. 0. 0.00007 7. 0. 0. 0. 0. 0. 1. 8. 0.7
For rationals:
--> w = [3+2*x, 2+x; 3+x, 2-x]/5 w = 0.6 +0.4x 0.4 +0.2x 0.6 +0.2x 0.4 -0.2x --> r = w * inv(w) r = 2 -3.140D-16 + x -1.110D-15 + 3.331D-16x --------------- ------------------------ 2 x 1.3333333x + x 2 2 1.110D-15 - 2.220D-16x - 5.551D-17x -1.110D-15 + 1.3333333x + x ------------------------------------ ---------------------------- 2 2 1.3333333x + x 1.3333333x + x --> clean(r) ans = 1 0 -- -- 1 1 0 1 -- -- 1 1
See also
- %eps — epsilon (floating-point relative accuracy)
- cond — condition number of a matrix
- nearfloat — get previous or next floating-point number
- number_properties — determine floating-point parameters
Report an issue | ||
<< ceil | Floating point | double >> |