summaryrefslogtreecommitdiffstats
path: root/scilab/modules/texmacs
diff options
context:
space:
mode:
authorYann Collette <yann.collette@scilab.org>2009-11-25 15:09:25 +0100
committerYann Collette <yann.collette@scilab.org>2009-11-25 15:09:25 +0100
commit276a524f3d0494cbd994d266785653d43eb13fc1 (patch)
tree81f01a03e63d75e96c9e44e71a0b61da0c78aa02 /scilab/modules/texmacs
parent7a4c73cdfcca126aaaa68bb124a115f6b041735f (diff)
parent62734d899e955c4f2715377823e5e137b0d9631f (diff)
downloadscilab-276a524f3d0494cbd994d266785653d43eb13fc1.zip
scilab-276a524f3d0494cbd994d266785653d43eb13fc1.tar.gz
Merge remote branch 'origin/5.2'
Diffstat (limited to 'scilab/modules/texmacs')
-rw-r--r--scilab/modules/texmacs/help/en_US/pol2tex.xml5
-rw-r--r--scilab/modules/texmacs/help/en_US/texprint.xml6
-rw-r--r--scilab/modules/texmacs/macros/pol2tex.sci94
-rw-r--r--scilab/modules/texmacs/macros/texprint.sci107
4 files changed, 13 insertions, 199 deletions
diff --git a/scilab/modules/texmacs/help/en_US/pol2tex.xml b/scilab/modules/texmacs/help/en_US/pol2tex.xml
index d3b511f..e158151 100644
--- a/scilab/modules/texmacs/help/en_US/pol2tex.xml
+++ b/scilab/modules/texmacs/help/en_US/pol2tex.xml
@@ -16,7 +16,7 @@
16 </info> 16 </info>
17 <refnamediv> 17 <refnamediv>
18 <refname>pol2tex</refname> 18 <refname>pol2tex</refname>
19 <refpurpose> convert polynomial to TeX format</refpurpose> 19 <refpurpose> convert polynomial to TeX format. This function is obsolete and will be removed in Scilab 5.3. Please use <link linkend="prettyprint">prettyprint</link></refpurpose>
20 </refnamediv> 20 </refnamediv>
21 <refsynopsisdiv> 21 <refsynopsisdiv>
22 <title>Calling Sequence</title> 22 <title>Calling Sequence</title>
@@ -44,6 +44,7 @@
44 <para> 44 <para>
45 Latex source code for the polynomial <literal>x</literal>. 45 Latex source code for the polynomial <literal>x</literal>.
46 (For use with <literal>texprint</literal>)</para> 46 (For use with <literal>texprint</literal>)</para>
47<para>This function is obsolete and will be removed in Scilab 5.3. Please use <link linkend="prettyprint">prettyprint</link></para>
47 </refsection> 48 </refsection>
48 <refsection> 49 <refsection>
49 <title>Examples</title> 50 <title>Examples</title>
@@ -57,7 +58,7 @@ pol2tex(p)
57 <title>See Also</title> 58 <title>See Also</title>
58 <simplelist type="inline"> 59 <simplelist type="inline">
59 <member> 60 <member>
60 <link linkend="texprint">texprint</link> 61 <link linkend="prettyprint">prettyprint</link>
61 </member> 62 </member>
62 </simplelist> 63 </simplelist>
63 </refsection> 64 </refsection>
diff --git a/scilab/modules/texmacs/help/en_US/texprint.xml b/scilab/modules/texmacs/help/en_US/texprint.xml
index b4aaa93..477dde9 100644
--- a/scilab/modules/texmacs/help/en_US/texprint.xml
+++ b/scilab/modules/texmacs/help/en_US/texprint.xml
@@ -16,7 +16,7 @@
16 </info> 16 </info>
17 <refnamediv> 17 <refnamediv>
18 <refname>texprint</refname> 18 <refname>texprint</refname>
19 <refpurpose> TeX output of Scilab object</refpurpose> 19 <refpurpose> TeX output of Scilab object. This function is obsolete and will be removed in Scilab 5.3. Please use <link linkend="prettyprint">prettyprint</link></refpurpose>
20 </refnamediv> 20 </refnamediv>
21 <refsynopsisdiv> 21 <refsynopsisdiv>
22 <title>Calling Sequence</title> 22 <title>Calling Sequence</title>
@@ -45,6 +45,8 @@
45 returns the Tex source code of the Scilab variable <literal>a</literal>. 45 returns the Tex source code of the Scilab variable <literal>a</literal>.
46 <literal>a</literal> is a matrix (constant, polynomial, rational) or a linear system 46 <literal>a</literal> is a matrix (constant, polynomial, rational) or a linear system
47 (<literal>syslin</literal> list).</para> 47 (<literal>syslin</literal> list).</para>
48<para>This function is obsolete and will be removed in Scilab 5.3. Please use <link linkend="prettyprint">prettyprint</link></para>
49
48 </refsection> 50 </refsection>
49 <refsection> 51 <refsection>
50 <title>Examples</title> 52 <title>Examples</title>
@@ -57,7 +59,7 @@ texprint([1/s,s^2])
57 <title>See Also</title> 59 <title>See Also</title>
58 <simplelist type="inline"> 60 <simplelist type="inline">
59 <member> 61 <member>
60 <link linkend="pol2tex">pol2tex</link> 62 <link linkend="prettyprint">prettyprint</link>
61 </member> 63 </member>
62 <member> 64 <member>
63 <link linkend="pol2str">pol2str</link> 65 <link linkend="pol2str">pol2str</link>
diff --git a/scilab/modules/texmacs/macros/pol2tex.sci b/scilab/modules/texmacs/macros/pol2tex.sci
index 5d455c8..225804f 100644
--- a/scilab/modules/texmacs/macros/pol2tex.sci
+++ b/scilab/modules/texmacs/macros/pol2tex.sci
@@ -1,6 +1,7 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 1989 - INRIA - Serge STEER 2// Copyright (C) 1989 - INRIA - Serge STEER
3// Copyright (C) INRIA 3// Copyright (C) INRIA
4// Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU (tag this function as obsolete)
4// 5//
5// This file must be used under the terms of the CeCILL. 6// This file must be used under the terms of the CeCILL.
6// This source file is licensed as described in the file COPYING, which 7// This source file is licensed as described in the file COPYING, which
@@ -10,96 +11,7 @@
10 11
11function [tt]=pol2tex(a) 12function [tt]=pol2tex(a)
12 13
13 // Latex source code for the scilab polynomial matrix a. 14 warnobsolete("prettyprint","5.3");
14 // (For use with texprint) 15 tt=prettyprint(a,"tex");
15 //
16
17
18 p = string(coeff(a));
19 z = varn(a);
20 lz = length(z);
21
22 while part(z,lz) == ' ' then
23 lz = lz-1;
24 end
25
26 z = part(z,1:lz);
27
28 np = prod(size(p));
29 ok = " ";
30 tt = " ";
31
32 //coeff degree 0
33
34 if part(p(1),1)<>'-' then
35 if p(1)<>'0' then
36 tt = tt+ok+p(1);
37 ok = "+";
38 end
39 else
40 tt = tt+p(1);
41 ok = "+";
42 end
43
44 if np==1 then
45 if ok==' ' then
46 tt='0';
47 end
48 return;
49 end
50
51 //coeff degree 1
52
53 if part(p(2),1)<>'-' then
54
55 select p(2)
56 case "0",
57 case "1" then
58 tt = tt+ok+z;
59 ok = "+";
60 else
61 tt = tt+ok+p(2)+"\*"+z
62 ok = "+";
63 end
64
65 else
66
67 if p(2)=='-1' then
68 tt=tt+"-"+z;
69 else
70 tt=tt+p(2)+"\*"+z;
71 end
72
73 ok="+";
74
75 end
76
77 //other coefficients
78 for i=3:np
79
80 if part(p(i),1)<>'-' then
81 select p(i)
82 case "0",
83 case "1" then
84 tt = tt+ok+z+'^{'+string(i-1)+'}';
85 ok = "+";
86 else
87 tt = tt+ok+p(i)+"\*"+z+"^{"+string(i-1)+"}";
88 ok = "+";
89 end
90 else
91 ok = "+"
92 if p(i)=="-1" then
93 tt=tt+"-"+z+"^{"+string(i-1)+"}"
94 else
95 tt=tt+p(i)+"\*"+z+"^{"+string(i-1)+"}"
96 end
97 end
98
99 end
100
101 if ok == " " then
102 tt="0";
103 end
104 16
105endfunction 17endfunction
diff --git a/scilab/modules/texmacs/macros/texprint.sci b/scilab/modules/texmacs/macros/texprint.sci
index 633a452..1755d66 100644
--- a/scilab/modules/texmacs/macros/texprint.sci
+++ b/scilab/modules/texmacs/macros/texprint.sci
@@ -1,5 +1,6 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA 2// Copyright (C) INRIA
3// Copyright (C) DIGITEO - 2009 - Sylvestre LEDRU (tag this function as obsolete)
3// 4//
4// This file must be used under the terms of the CeCILL. 5// This file must be used under the terms of the CeCILL.
5// This source file is licensed as described in the file COPYING, which 6// This source file is licensed as described in the file COPYING, which
@@ -8,109 +9,7 @@
8// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt 9// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9 10
10function [tt]=texprint(a) 11function [tt]=texprint(a)
11// text = texprint(a) returns the Tex source code of the scilab variable a. 12 warnobsolete("prettyprint","5.3");
12// a is a matrix (scalar, polynomial, rational) or a linear system 13 tt=prettyprint(a,"tex");
13// (syslin list).
14//!
15//
16typ=type(a)
17
18select typ
19case 1 then //scalars
20 [m,n]=size(a)
21 if norm(imag(a))<=%eps*norm(real(a)) then
22 a=string(real(a))
23 else
24 a=string(a)
25 end
26 if m*n==0 then tt='{\pmatrix{}}',return,end
27 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
28 for l=1:m,tt=tt+strcat(a(l,:),'&')+'\cr '; end
29 tt=part(tt,1:length(tt)-4)+'}}'
30 tt=strsubst(tt,'%','')
31case 2 then //polynomials
32 [m,n]=size(a)
33 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
34 z=varn(a)
35 nz=1;while part(z,nz)<>' ' then nz=nz+1,end
36 z=part(z,1:nz-1)
37//
38 for l=1:m
39 for k=1:n,tt=tt+pol2tex(a(l,k))+'&',end
40 tt=part(tt,1:length(tt)-1)+'\cr '
41 end
42 tt=part(tt,1:length(tt)-4)+'}}'
43 tt=strsubst(tt,'%','')
44case 4 then //booleans
45 [m,n]=size(a)
46 x='F'+emptystr(a);x(a)='T';a=x;
47 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
48 for l=1:m,tt=tt+strcat(a(l,:),'&')+'\cr '; end
49 tt=part(tt,1:length(tt)-4)+'}}'
50case 8 then //int
51 [m,n]=size(a);a=string(a)
52 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
53 for l=1:m,tt=tt+strcat(a(l,:),'&')+'\cr '; end
54 tt=part(tt,1:length(tt)-4)+'}}'
55
56case 10 then //strings
57 [m,n]=size(a)
58 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
59 for l=1:m,tt=tt+strcat(a(l,:),'&')+'\cr '; end
60 tt=part(tt,1:length(tt)-4)+'}}'
61
62case 16 then
63 a1=a(1)//transfer and linear systems
64 select a1(1)
65 case 'r' then //rationals
66 num=a('num');a=a('den')
67 [m,n]=size(a)
68 if m*n<>1 then tt='{\pmatrix{',else tt='{{',end
69 z=varn(a)
70 nz=1;while part(z,nz)<>' ' then nz=nz+1,end
71 z=part(z,1:nz-1)
72 //
73 for l=1:m
74 for k=1:n,
75 if degree(a(l,k))==0 then
76 num(l,k)=num(l,k)/coeff(a(l,k)),pol=1
77 else
78 pol=0
79 end
80 nlk=pol2tex(num(l,k));
81 if nlk=='0' then
82 tt=tt+'0&'
83 else
84 if pol==1 then
85 tt=tt+nlk+'&'
86 else
87 dlk=pol2tex(a(l,k))
88 tt=tt+'{'+nlk+'}\over{'+dlk+'}&',
89 end
90 end
91 end
92 tt=part(tt,1:length(tt)-1)+'\cr '
93 end
94 tt=part(tt,1:length(tt)-4)+'}}'
95 tt=strsubst(tt,'%','')
96 case 'lss' //linear state space
97 if a(7)=='c' then der=' \dot{x}',else der=' \stackrel{+}{X}',end
98 debut='\begin{eqnarray}';fin='\end{eqnarray}'
99 tt=debut+der+' &=& '+texprint(a(2))+' X + '+...
100 texprint(a(3))+'U \\ \\ Y &=& '+texprint(a(4))+' X '
101 if norm(a(5),1)==0 then
102 tt=tt+fin
103 else
104 tt=tt+' + '+texprint(a(5))+fin
105 end
106 else
107 execstr('tt=%'+a1(1)+'_texprint(a)','errcatch')
108 end
109case 17 then
110 a1=getfield(1,a)
111 execstr('tt=%'+a1(1)+'_texprint(a)','errcatch')
112else
113 execstr('tt=%'+typeof(a)+'_texprint(a)','errcatch')
114end
115endfunction 14endfunction
116 15