There was no reason for lcm & gcd to refuse complex polynomials.
bug_5686.tst now passes.
Change-Id: I6379cd06ad0ef633ddc1449a4739def57532425c
if type(p)==8 then
if lhs==2 then [x,uu]=%i_gcd(p), else x=%i_gcd(p), end
return
- elseif ~isreal(p) then
- error(msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "gcd", 1));
end
[m, n] = size(p)
if type(p)==8 then
if argn(1)==2 then [p, fact] = %i_lcm(p), else p = %i_lcm(p), end
return
- elseif ~isreal(p) then
- error(msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "lcm", 1));
end
[m, n] = size(p),
// <-- Non-regression test for bug 12679 -->
//
// <-- CLI SHELL MODE -->
-// <-- ENGLISH IMPOSED -->
//
// <-- Bugzilla URL -->
// http://bugzilla.scilab.org/show_bug.cgi?id=12679
[pgcd, u] = gcd(p);
assert_checkequal(p*u, [0 0 s]);
// Complex polynomials should yield an error
-s = poly(%i, 's');
-p = [s, s*(s+1)^2,2*s^2+s^3];
-refMsg = msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "gcd", 1);
-assert_checkerror("[pgcd, u] = gcd(p);", refMsg);
// Normal behavior, with integers
V = int32([2^2*3^5, 2^3*3^2, 2^2*3^4*5]);
[thegcd, U] = gcd(V);
p = [s, s*(s+1)^2, s^2*(s+2)];
[pp, fact] = lcm(p);
assert_checkequal(pp, [2*s^2 + 5*s^3 + 4*s^4 + s^5]);
-// Complex polynomials should yield an error
-s = poly(%i, 's');
-p = [s, s*(s+1)^2, s^2*(s+2)];
-refMsg3 = msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "lcm", 1);
-assert_checkerror("[pp, fact] = lcm(p);", refMsg3);
// Normal behavior, with integers
V = int32([2^2*3^5, 2^3*3^2, 2^2*3^4*5]);
assert_checkequal(lcm(V), int32(9720));
// <-- Non-regression test for bug 12679 -->
//
// <-- CLI SHELL MODE -->
-// <-- ENGLISH IMPOSED -->
//
// <-- Bugzilla URL -->
// http://bugzilla.scilab.org/show_bug.cgi?id=12679
[pgcd, u] = gcd(p);
assert_checkequal(p*u, [0 0 s]);
// Complex polynomials should yield an error
-s = poly(%i, 's');
-p = [s, s*(s+1)^2,2*s^2+s^3];
-refMsg = msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "gcd", 1);
-assert_checkerror("[pgcd, u] = gcd(p);", refMsg);
// Normal behavior, with integers
V = int32([2^2*3^5, 2^3*3^2, 2^2*3^4*5]);
p = [s, s*(s+1)^2, s^2*(s+2)];
[pp, fact] = lcm(p);
assert_checkequal(pp, [2*s^2 + 5*s^3 + 4*s^4 + s^5]);
-// Complex polynomials should yield an error
-s = poly(%i, 's');
-p = [s, s*(s+1)^2, s^2*(s+2)];
-refMsg3 = msprintf(_("%s: Wrong type for argument #%d: Real Polynomial expected.\n"), "lcm", 1);
-assert_checkerror("[pp, fact] = lcm(p);", refMsg3);
// Normal behavior, with integers
V = int32([2^2*3^5, 2^3*3^2, 2^2*3^4*5]);