File: %25r_m_p.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (39 lines) | stat: -rw-r--r-- 756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [f1]=%r_m_p(f1,n2)
// r=%r_m_p(f1,n2)  <=> r=f1*n2
// f1=rational n2=polynomial
//!
// Copyright INRIA
[n1,d1]=f1(['num','den']),
[l1,m1]=size(n1);[l2,m2]=size(n2),
//
indef=%f
if l1==-1 then 
  n1=n1+0;d1=d1+0;l1=1;m1=1;
  if l2*m2==1 then indef=%t,else error(14),end
end
if l2==-1 then 
  n2=n2+0;l2=1;m2=1;
  if l1*m1==1 then indef=%t,else error(14),end
end 
if mini([l1*m1,l2*m2])==1 then,
  num=n1*n2,
  den=d1*ones(l2,m2),
else,
  if m1<>l2 then error(10),end,
  for i=1:l1,
    n=n1(i,:);
    [y,fact]=lcm(d1(i,:)),
    den(i,1:m2)=ones(1,m2)*y,
      for j=1:m2,
        num(i,j)=n*(n2(:,j).*matrix(fact,l2,1)),
      end,
  end,
end,
[num,den]=simp(num,den),
if indef then
  num=num*eye()
  den=den*eye()
end
f1=rlist(num,den,f1('dt'))