path: root/scilab
diff options
authorSamuel GOUGEON <>2021-04-27 10:59:27 +0200
committerClement DAVID <>2021-04-29 11:31:48 +0200
commit3b3f272ee6e0d85b2f3000a3648e12cd2785bed8 (patch)
treeca2abfededc3ec97d8194633afcc5fef48e70a14 /scilab
parentf59d6de9f6eef9ec149b9c26dbd86e43b13913a9 (diff)
Fix %r_simp() about preliminary cleaning
Discussion @ 1) clean(n) and clean(d) formerly introduced (by me) are not correct because they implicitly apply some default absolute threshold. Such an absolute threshold is not relevant and even erroneous. Indeed, a numerator with all coefficients very small like 1e-100 + 1e-110*%z *can* be meaningful. By the way, in a rational, (1e-100 + 1e-110*%z)/%z and (1+1e-10*%z)/(1e100*%z) are equivalent. So if clean() is used, it should be so with a 0 absolute threshold. 2) Now for the considered aim, here clean(n,0,reltol) would be useless: At least one non-zero coefficient will always survive to it, with no way to yield a constant null polynomial. This is why these clean() must be removed. This does not cancel the fix against the bug 13893, but makes the fix stricter. If we want to go forward about simplification with some relevant cleaning, this should be done *when operating* (+,-,.*,./) rationals, while operands are still known, *not after* based only on the result. Indeed, cleaning needs to be based on the order of magnitude of *operands coefficients*, compared to the result ones. On this respect, is a good preliminary that could avoid later implementing N times the same improvements. Change-Id: I6fef298bc41b6dd1da45dac3aeaa80dda0b798ef
Diffstat (limited to 'scilab')
1 files changed, 1 insertions, 1 deletions
diff --git a/scilab/modules/overloading/macros/%r_simp.sci b/scilab/modules/overloading/macros/%r_simp.sci
index 943f0602..edb5b65 100644
--- a/scilab/modules/overloading/macros/%r_simp.sci
+++ b/scilab/modules/overloading/macros/%r_simp.sci
@@ -21,8 +21,8 @@ function h = %r_simp(h, d)
21 n = h 21 n = h
22 h = [] 22 h = []
23 end 23 end
24 i = find(clean(n)==0 & clean(d)~=0)
25 [n, d] = simp(n, d); 24 [n, d] = simp(n, d);
25 i = find(n==0 & d~=0)
26 d(i) = 1 26 d(i) = 1
27 h = rlist(n, d, h(4)) 27 h = rlist(n, d, h(4))
28endfunction 28endfunction