File: pol2tex.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 (63 lines) | stat: -rw-r--r-- 1,113 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function [tt]=pol2tex(a)
// Latex source code for the scilab polynomial matrix a.
// (For use with texprint)
//!
//origine S Steer INRIA 1989
//
// Copyright INRIA
p=string(coeff(a))
z=varn(a)
lz=length(z)
while part(z,lz)==' ' then lz=lz-1,end
z=part(z,1:lz)
//
np=prod(size(p));ok=' ',tt=' ',
//coeff  degree 0
if part(p(1),1)<>'-' then
  if p(1)<>'0' then
    tt=tt+ok+p(1)
    ok='+'
  end
else
   ok='+'
   tt=tt+p(1)
end
if np==1 then
   if ok==' ' then tt='0',end
   return,
end
//coeff  degree 1
if part(p(2),1)<>'-' then
  select p(2)
    case '0',
    case '1' then tt=tt+ok+z,ok='+'
    else  tt=tt+ok+p(2)+' '+z,ok='+'
  end
else
  if p(2)=='-1' then
    tt=tt+'-'+z
  else
    tt=tt+p(2)+' '+z
  end
  ok='+'
end
//other coefficients
for i=3:np
 if part(p(i),1)<>'-' then
   select p(i)
     case '0',
     case '1' then tt=tt+ok+z+'^{'+string(i-1)+'}',ok='+'
     else    tt=tt+ok+p(i)+' '+z+'^{'+string(i-1)+'}',ok='+'
   end
 else
   ok='+'
   if p(i)=='-1' then
     tt=tt+'-'+z+'^{'+string(i-1)+'}'
   else
     tt=tt+p(i)+' '+z+'^{'+string(i-1)+'}'
   end
 end
end
if ok==' ' then tt='0',end