Error in the multiplication of a rational vector with a polynomial vector. test_run... 40/18540/6
Adeline CARNIS [Wed, 7 Sep 2016 14:39:58 +0000 (16:39 +0200)]
Change-Id: I1e70b43de50fa816d018e0966a50e33e5f10c85e

scilab/modules/overloading/macros/%p_m_r.sci
scilab/modules/overloading/macros/%r_m_p.sci

index db587b9..343c1fd 100644 (file)
@@ -1,5 +1,5 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA
+// Copyright (C) 2016 - Samuel GOUGEON
 //
 // Copyright (C) 2012 - 2016 - Scilab Enterprises
 //
 // For more information, see the COPYING file which you should have received
 // along with this program.
 
-function f2=%p_m_r(n1,f2)
-    // r=%p_m_r(p,f)  <=> r= p*f with p=polynomial matrix
-    // and f= rational
-    //author Serge Steer INRIA
-
-    //!
-
-    [n2,d2]=f2(["num","den"]);
-    sz1=size(n1);sz2=size(n2);
-    if prod(sz1)==0|prod(sz2)==0 then  f2=[],return,end
-
-
-    indef=%f
-    if or(sz1==-1) then
-        n1=n1+0;sz1=[1 1];
-        if  prod(sz2)==1 then indef=%t,else error(14),end
-    end
-    if  or(sz2==-1) then
-        n2=n2+0;d2=d2+0;sz2=[1 1];
-        if prod(sz1)==1 then indef=%t,else error(14),end
-    end
-
-    //
-    if prod(sz1)==1 then
-        num=n1*n2,
-        den=d2
-    elseif prod(sz2)==1 then
-        num=n1*n2,
-        den=d2(ones(n1))
-    else,
-        if size(sz1,"*")>2|size(sz2,"*")>2 then error(10),end
-        if sz1(2)<>sz2(1) then error(10),end,
-        l1=sz1(1);m1=sz1(2);m2=sz2(2);
-        for j=1:m2,
-            [y,fact]=lcm(d2(:,j)),
-            n2(:,j)=n2(:,j).*fact,
-            den(1:l1,j)=ones(l1,1)*y,
-            for i=1:l1,
-                num(i,j)=n1(i,:)*n2(:,j),
-            end
-        end
-    end
-
-    if ndims(num)<=2 then
-        [num,den]=simp(num,den),
-    else
-        sz=size(num)
-        [num,den]=simp(num(:),den(:)),
-        num=matrix(num,sz)
-        den=matrix(den,sz)
-    end
-
-    if indef then
-        num=num*eye()
-        den=den*eye()
-    end
-    f2=rlist(num,den,f2.dt)
+function r = %p_m_r(p1,r2)
+    r1 =  p1 / (1 + p1(1)*0)
+    r = r1 * r2
 endfunction
index 3e20b08..b731176 100644 (file)
 function [f1] = %r_m_p(r1,p2)
     // r = %r_m_p(r1, p2)  <=> r = r1*p2
     // r1 = rational p2 = polynomial
-    if size(p2,"*")==1 then
-        f1=p2*r1
+    if size(p2, "*") == 1 then
+        num=r1.num*p2;
+        den = r1.den;
+        f1=rlist(num,den,r1("dt"))
     else
-        f1 = p2.'*r1.';
+        if isrow(r1) then
+            f1 = p2.'*r1.';
+        else
+            f1 = (p2.'*r1.')';
+        end
     end
 endfunction