summaryrefslogtreecommitdiffstats
path: root/scilab_doc/Matlab_Scilab_dictionary/makedoc.sce
diff options
context:
space:
mode:
Diffstat (limited to 'scilab_doc/Matlab_Scilab_dictionary/makedoc.sce')
-rw-r--r--scilab_doc/Matlab_Scilab_dictionary/makedoc.sce1017
1 files changed, 1017 insertions, 0 deletions
diff --git a/scilab_doc/Matlab_Scilab_dictionary/makedoc.sce b/scilab_doc/Matlab_Scilab_dictionary/makedoc.sce
new file mode 100644
index 0000000..698b91c
--- /dev/null
+++ b/scilab_doc/Matlab_Scilab_dictionary/makedoc.sce
@@ -0,0 +1,1017 @@
1mode(-1);
2// Copyright INRIA
3
4// Contents of this file
5// - function []=xml2htmlpdf(XMLFILE,dic)
6// - function [MATNAME,DESCR,SCINAME,NOTE,MATEX,SCIEX]=get_func_info(data,index)
7// - function []=write_html_data(matname,descr,sciname,note,matex,sciex,funnb,dic)
8// - function []=write_latex_data(matname,descr,sciname,note,matex,sciex,funnb,dic)
9// - function [matname,descr,sciname,note,matex,sciex]=datatohtml(matname,descr,sciname,note,matex,sciex)
10// - function [matname,descr,sciname,note,matex,sciex]=datatolatex(matname,descr,sciname,note,matex,sciex)
11// - function []=create_html_index(indexfile,names,dic)
12// - function [out]=special_name(in)
13// - function [entry]=index_entry(in)
14// - Some batch instructions
15
16//****************************************************************************************
17// function []=xml2htmlpdf(XMLFILE,dic)
18// Copyright INRIA
19// XMLFILE : XML file containing data to convert
20// dic : dictionary we want to build (M2SCI or SCI2M)
21//****************************************************************************************
22function []=xml2htmlpdf(XMLFILE,dic)
23LATEXFILE=dic+".tex"
24HTMLFILE="./html/"+dic+".htm"
25HTMLINDEXFILE="./html/"+dic+"_index.htm"
26
27// Verify that XML file is well formed
28//ierr=execstr("unix_s(""xmllint --noout --valid "+XMLFILE+""")","errcatch")
29//if ierr<>0 then
30 //mprintf("File : "+XMLFILE+" does not follow DTD");
31 //return
32//end
33
34// Read data in XML file
35[xmlfile,ierr]=mopen(XMLFILE,"r")
36if ierr<>0 then
37 mprintf("Could not open file : "+XMLFILE);
38 return
39end
40xmldata=mgetl(xmlfile);
41mclose(xmlfile);
42
43// Create function table
44funtable=[] // line matname sciname
45k=1
46while k<size(xmldata,1)
47 while strindex(xmldata(k),"<MATSCIFUN>")==[] & k<size(xmldata,1)
48 k=k+1
49 end
50 tmp=string(k)
51 while strindex(xmldata(k),"<MATNAME>")==[] & k<size(xmldata,1)
52 k=k+1
53 end
54 tmp=[tmp,stripblanks(strsubst(strsubst(xmldata(k),"<MATNAME>",""),"</MATNAME>",""))]
55 while strindex(xmldata(k),"<SCINAME>")==[] & k<size(xmldata,1)
56 k=k+1
57 end
58 tmp=[tmp,stripblanks(strsubst(strsubst(xmldata(k),"<SCINAME>",""),"</SCINAME>",""))]
59 if k<size(xmldata,1) then
60 funtable=[funtable;tmp]
61 end
62end
63
64// Parameter initialization according to dic
65if dic=="M2SCI" then
66 title="Matlab-Scilab equivalent functions"
67 leftimage="<B>Matlab</B>"
68 rightimage="<IMG SRC=scilab.gif>"
69 lefthead="Matlab function"
70 righthead="Scilab function"
71
72 // Del No equivalent funnames
73 k=1
74 while k<=size(funtable,1)
75 if funtable(k,2)=="No equivalent" then
76 functable(k,:)=[]
77 else
78 funtable(k,4)=special_name(funtable(k,2)) // Name in index
79 funtable(k,5)=index_entry(funtable(k,2)) // Entry in index
80 k=k+1
81 end
82 end
83
84 [tmp,indexes]=sort(convstr(funtable(:,2)))
85
86 funlines=[];funnames=[];indexnames=[];indexentries=[]
87 oplines=[];opnames=[];
88 varlines=[];varnames=[];
89 for k=1:size(indexes,1)
90 if length(funtable(indexes(k),5))==1 then
91 funlines=[funlines;funtable(indexes(k),1)] // Line in XML file
92 funnames=[funnames;funtable(indexes(k),2)] // Name of function
93 indexnames=[indexnames;funtable(indexes(k),4)] // Name in index
94 indexentries=[indexentries;funtable(indexes(k),5)] // Entry in index
95 elseif funtable(indexes(k),5)=="Operators" then
96 oplines=[oplines;funtable(indexes(k),1)];
97 opnames=[opnames;funtable(indexes(k),2)];
98 elseif funtable(indexes(k),5)=="Variables" then
99 varlines=[varlines;funtable(indexes(k),1)];
100 varnames=[varnames;funtable(indexes(k),2)];
101 else
102 error("Wrong index entry : "+funtable(indexes(k),5));
103 end
104 end
105
106 // Add operators
107 for k=1:size(opnames,1)
108 funlines=[funlines;oplines(k)]
109 funnames=[funnames;opnames(k)]
110 indexnames=[indexnames;special_name(opnames(k))]
111 indexentries=[indexentries;"Operators"]
112 end
113
114 // Add Variables
115 for k=1:size(varnames,1)
116 funlines=[funlines;varlines(k)]
117 funnames=[funnames;varnames(k)]
118 indexnames=[indexnames;special_name(varnames(k))]
119 indexentries=[indexentries;"Variables"]
120 end
121else
122 title="Scilab-Matlab equivalent functions"
123 leftimage="<IMG SRC=scilab.gif>"
124 rightimage="<B>Matlab</B>"
125 lefthead="Scilab function"
126 righthead="Matlab function"
127
128 // Del No equivalent funnames
129 k=1
130 while k<=size(funtable,1)
131 write(%io(2),funtable(k,3))
132 if funtable(k,3)=="No equivalent" then
133 funtable(k,:)=[]
134 elseif part(stripblanks(funtable(k,3)),1)=="1" then
135 funtable(k,:)=[]
136 else
137 funtable(k,4)=special_name(funtable(k,3)) // Name in index
138 funtable(k,5)=index_entry(funtable(k,3)) // Entry in index
139 k=k+1
140 end
141 end
142
143 [tmp,indexes]=sort(convstr(funtable(:,3)))
144
145 funlines=[];funnames=[];indexnames=[];indexentries=[]
146 oplines=[];opnames=[];
147 varlines=[];varnames=[];
148 for k=1:size(indexes,1)
149 if length(funtable(indexes(k),5))==1 then
150 funlines=[funlines;funtable(indexes(k),1)] // Line in XML file
151 funnames=[funnames;funtable(indexes(k),3)] // Name of function
152 indexnames=[indexnames;funtable(indexes(k),4)] // Name in index
153 indexentries=[indexentries;funtable(indexes(k),5)] // Entry in index
154 elseif funtable(indexes(k),5)=="Operators" then
155 oplines=[oplines;funtable(indexes(k),1)];
156 opnames=[opnames;funtable(indexes(k),3)];
157 elseif funtable(indexes(k),5)=="Variables" then
158 varlines=[varlines;funtable(indexes(k),1)];
159 varnames=[varnames;funtable(indexes(k),3)];
160 else
161 error("Wrong index entry : "+funtable(indexes(k),5));
162 end
163 end
164
165 // Add operators
166 for k=1:size(opnames,1)
167 funlines=[funlines;oplines(k)]
168 funnames=[funnames;opnames(k)]
169 indexnames=[indexnames;special_name(opnames(k))]
170 indexentries=[indexentries;"Operators"]
171 end
172
173 // Add Variables
174 for k=1:size(varnames,1)
175 funlines=[funlines;varlines(k)]
176 funnames=[funnames;varnames(k)]
177 indexnames=[indexnames;special_name(varnames(k))]
178 indexentries=[indexentries;"Variables"]
179 end
180end
181
182if dic=="M2SCI" then
183 ref="Matlab"
184 eq="Scilab"
185else
186 eq="Matlab"
187 ref="Scilab"
188end
189
190LATEX_FORWORD=[
191 "This document contains a list of some "+ref+" basis functions and compare them ";
192 "with the "+eq+" equivalent functions if there are. It gives the main differences ";
193 "and gives examples of particular cases.\newline";
194 "\newline"
195 "However not all "+ref+" and "+eq+" functions are described here.\newline";
196 "\newline"
197 "Equivalents for operators and variables can be found at the end of this document.\newline"
198 "\newline"
199 "Caution:\newline"
200 "This document is not dedicated to explain how functions work. ";
201 "Users can used online manuals of "+ref+" and "+eq+" for it.\newline"
202 "\newline"
203 ]
204HTML_FOREWORD=[
205 LATEX_FORWORD;
206 "How to use this HTML guide:\newline";
207 "To have more details about functions and examples, clic on the ""triangles"" just ";
208 "at the left of "+ref+" function name.\newline";
209 "To have a more detailed index, clic on the letters and keywords.\newline"
210 ]
211
212// Write HTML file beginning
213HTML_FILE_BEG=[
214 "<!-- FILE GENERATED BY SCILAB - PLEASE DO NOT EDIT -->"
215 "<HTML>"
216 "<HEAD>"
217 " <TITLE>"+title+"</title>"
218 " <META HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=iso-8859-1"">"
219 " <SCRIPT SRC=""matsci.js""></SCRIPT>"
220 "</HEAD>"
221 "<BODY BACKGROUND=""back.jpg"">"
222 "<P ALIGN=""center"">"
223 "<FONT FACE=""arial"">"
224 ]
225[htmlfile,ierr]=mopen(HTMLFILE,"w")
226if ierr<>0 then
227 mprintf("Could not open file : "+HTMLFILE);
228 return
229end
230mputl([HTML_FILE_BEG;
231 "<A NAME=""Foreword""></A>"
232 "<TABLE WIDTH=""80%"">";
233 " <TR WIDTH=""100%"">"
234 " <TD COLSPAN=""4"" ALIGN=""center"">"
235 " <FONT SIZE=""+2"" COLOR=""red"">Foreword</FONT>"
236 " <HR WIDTH=""100%"">"
237 " </TD>"
238 " </TR>"
239 " <TR WIDTH=""100%"">"
240 " <TD COLSPAN=""4"">"
241 strsubst(HTML_FOREWORD,"\newline","<BR>")
242 " </TD>"
243 " </TR>"
244 "</TABLE>"
245 ],htmlfile)
246mclose(htmlfile)
247
248// Write LATEX file beginning
249LATEX_FILE_BEG=[
250 "% FILE GENERATED BY SCILAB - PLEASE DO NOT EDIT %"
251 "\documentclass[12pt]{report}"
252 "\usepackage[a4paper,text={170mm,250mm},pdftex,twoside]{geometry}"
253 "\usepackage{fancyheadings}"
254 "\lhead{"+lefthead+"}"
255 "\rhead{"+righthead+"}"
256 "\cfoot{DRAFT - Page {\thepage}}"
257 "\addtolength{\parskip}{5mm}"
258 "\usepackage{makeidx}"
259 "\makeindex"
260 "\usepackage{amssymb}"
261 "\usepackage{hyperref}"
262 "\begin{document}"
263 "\pagestyle{empty}"
264 "\begin{center}"
265 "\vspace*{9cm}"
266 "\begin{minipage}[c]{\linewidth}"
267 "\begin{center}"
268 "\textbf{\Large{"+dic+":\\"+title+"\\}}"
269 "Version 1.0"
270 "\end{center}"
271 "\begin{center}"
272 "Scilab Project\\"
273 "INRIA Rocquencourt - BP 105\\"
274 "78153 Le Chesnay Cedex - France\\"
275 "Email: \texttt{scilab@inria.fr}\\"
276 "2004"
277 "\end{center}"
278 "\end{minipage}"
279 "\end{center}"
280 "\cleardoublepage"
281 "\newpage"
282 "\pdfbookmark[0]{Foreword}{Forword}"
283 "\begin{center}"
284 "\textbf{Forword}"
285 "\end{center}"
286 LATEX_FORWORD
287 "\cleardoublepage"
288 "\printindex"
289 "\cleardoublepage"
290 "\pagestyle{fancy}"
291 ]
292[latexfile,ierr]=mopen(LATEXFILE,"w")
293if ierr<>0 then
294 mprintf("Could not open file : "+LATEXFILE);
295 return
296end
297mputl(LATEX_FILE_BEG,latexfile)
298mclose(latexfile)
299
300// Write all function informations
301indentry_sav=""
302for l=1:size(funnames,1)
303
304 // Get infos from xml data
305 [matname,descr,sciname,note,matex,sciex]=get_func_info(xmldata,evstr(funlines(l)))
306
307 // Add indexes to files (HTML and TEX)
308 indentry=indexentries(l)
309 if indentry<>indentry_sav then
310
311 // Index HTML file (A, B, ...)
312 HTML_DATA=[
313 "<A NAME="""+indentry+"""></A>";
314 "<TABLE WIDTH=""80%"">";
315 " <TR WIDTH=""100%"">"
316 " <TD COLSPAN=""4"">"
317 " <HR WIDTH=""100%"">"
318 " </TD>"
319 " </TR>"
320 " <TR WIDTH=""100%"">";
321 " <TD HEIGHT=""20"" WIDTH=""100%"" COLSPAN=""4"">";
322 " </TD>";
323 " </TR>";
324 " <TR WIDTH=""100%"">";
325 " <TD WIDTH=""5%"" ALIGN=""center""></TD>";
326 " <TD WIDTH=""10%"" ALIGN=""center"">"+leftimage+"</TD>";
327 " <TD WIDTH=""70%"" ALIGN=""center""><FONT SIZE=""+2"" COLOR=""red"">"+indentry+"</FONT></TD>";
328 " <TD WIDTH=""10%"" ALIGN=""center"">"+rightimage+"</TD>";
329 " </TR>";
330 "</TABLE>"]
331
332 [htmlfile,ierr]=mopen(HTMLFILE,"a+")
333 if ierr<>0 then
334 mprintf("Could not open file : "+HTMLFILE);
335 return
336 end
337 mputl(HTML_DATA,htmlfile)
338 mclose(htmlfile)
339
340 // Index LATEX file (A, B, ...)
341 LATEX_DATA=[
342 "\newpage"
343 "\pdfbookmark[0]{"+indentry+"}{"+indentry+"}"
344 "\begin{center}\textbf{"+indentry+"}\end{center}"
345 ]
346 [latexfile,ierr]=mopen(LATEXFILE,"a+")
347 if ierr<>0 then
348 mprintf("Could not open file : "+LATEXFILE);
349 return
350 end
351 mputl(LATEX_DATA,latexfile)
352 mclose(latexfile)
353
354 indentry_sav=indentry
355 end
356
357 // Write data according to data read
358 write_html_data(matname,descr,sciname,note,matex,sciex,l,dic);
359 write_latex_data(matname,descr,sciname,note,matex,sciex,l,dic,indexnames(l),indexentries(l));
360end
361
362// Write HTML file end
363HTML_FILE_END=[
364 "</P>"
365 "</FONT>"
366 "</BODY>"
367 "</HTML>"
368 ]
369[htmlfile,ierr]=mopen(HTMLFILE,"a+")
370if ierr<>0 then
371 mprintf("Could not open file : "+HTMLFILE);
372 return
373end
374mputl(["<HR WIDTH=""80%"">";HTML_FILE_END],htmlfile)
375mclose(htmlfile)
376
377// Write LATEX file end
378LATEX_FILE_END=[
379 "\end{document}"
380 ]
381[latexfile,ierr]=mopen(LATEXFILE,"a+")
382if ierr<>0 then
383 mprintf("Could not open file : "+LATEXFILE);
384 return
385end
386mputl(LATEX_FILE_END,latexfile)
387mclose(latexfile)
388
389// Create HTML index file (done automatically for TEX)
390create_html_index(HTMLINDEXFILE,funnames,dic,indexentries)
391endfunction
392
393
394//****************************************************************************************
395//function [MATNAME,DESCR,SCINAME,NOTE,MATEX,SCIEX]=get_func_info(data,index)
396// Copyright INRIA
397// data : XML data
398// index : position of function in data
399//****************************************************************************************
400function [MATNAME,DESCR,SCINAME,NOTE,MATEX,SCIEX]=get_func_info(data,index)
401index=index+1
402MATNAME=stripblanks(strsubst(strsubst(data(index),"<MATNAME>",""),"</MATNAME>",""))
403index=index+1
404SCINAME=stripblanks(strsubst(strsubst(data(index),"<SCINAME>",""),"</SCINAME>",""))
405index=index+1
406DESCR=stripblanks(strsubst(strsubst(data(index),"<DESCR>",""),"</DESCR>",""))
407index=index+1
408disp(data(index-3))
409if strindex(data(index),"</MATSCIFUN>")==[] then
410 index=index+1
411 NOTE=""
412 while strindex(data(index),"</NOTE>")==[]
413 NOTE=NOTE+stripblanks(data(index))
414 index=index+1
415 end
416 index=index+1
417 if strindex(data(index),"</MATSCIFUN>")==[] then
418
419 if strindex(data(index),"<MATEX>")<>[] then
420 index=index+1
421 MATEX=[]
422 while strindex(data(index),"</MATEX>")==[] then
423 MATEX=[MATEX;stripblanks(data(index))]
424 index=index+1
425 end
426 index=index+1
427 end
428
429 if strindex(data(index),"<SCIEX>")<>[] then
430 index=index+1
431 SCIEX=[]
432 while strindex(data(index),"</SCIEX>")==[] then
433 SCIEX=[SCIEX;stripblanks(data(index))]
434 index=index+1
435 end
436 end
437 else
438 MATEX=""
439 SCIEX=""
440 end
441else
442 NOTE=""
443 MATEX=""
444 SCIEX=""
445end
446endfunction
447
448//****************************************************************************************
449//function []=write_html_data(matname,descr,sciname,note,matex,sciex,funnb,dic)
450// Copyright INRIA
451//****************************************************************************************
452function []=write_html_data(matname,descr,sciname,note,matex,sciex,funnb,dic)
453[matname,descr,sciname,note,matex,sciex]=datatohtml(matname,descr,sciname,note,matex,sciex)
454
455if dic=="M2SCI" then
456 leftname=matname
457 rightname=sciname
458 leftex=matex
459 rightex=sciex
460else
461 leftname=sciname
462 rightname=matname
463 leftex=sciex
464 rightex=matex
465end
466
467[htmlfile,ierr]=mopen(HTMLFILE,"a+")
468if ierr<>0 then
469 mprintf("Could not open file : "+HTMLFILE);
470 return
471end
472
473// Prepare data to write in HTML file
474ind_name=strsubst(special_name(leftname)," ","-")
475ind_name=strsubst(ind_name,"&#8596;","")
476
477HTML_DATA = [
478 "<!---------- "+special_name(leftname)+" ---------->"
479 "<A NAME="""+ind_name+"""></A>";
480 "<TABLE CELLPADING=""0"" CELLSPACING=""0"" WIDTH=""80%"">";
481 " <TR>"
482 " <TD>"
483 " <HR WIDTH=""100%"">"
484 " </TD>"
485 " </TR>"
486 " <TR WIDTH=""100%""> "
487 " <TD>"
488 " <TABLE WIDTH=""100%"" CELLSPACING=""0"">"
489 " <TR>"
490 " <TD WIDTH=""5%"" ALIGN=""right"" VALIGN=""top"">"
491 ]
492if or(leftex<>"") | or(rightex<>"") | or(note<>"") then
493 HTML_DATA=[
494 HTML_DATA;
495 " <A HREF=""javascript:swap_couche(''"+string(funnb)+"'');"">"
496 " <IMG NAME=""arrow"+string(funnb)+""" SRC=""rightarrow.gif?1"" BORDER=""0"">"
497 " </A>"
498 ]
499end
500HTML_DATA=[
501 HTML_DATA;
502 " </TD>"
503 " <TD WIDTH=""10%"" ALIGN=""center""><B>"+leftname+"</B></TD>"
504 " <TD WIDTH=""75%"" ALIGN=""center""><I>"+descr+"</I></TD>"
505 " <TD WIDTH=""10%"" ALIGN=""center""><B>"+rightname+"</B></TD>"
506 " </TR>"
507 " </TABLE>"
508 " </TD>"
509 " </TR>"]
510if or(leftex<>"") | or(rightex<>"") | or(note<>"") then
511 HTML_DATA=[
512 HTML_DATA;
513 " <SCRIPT LANGUAGE=''JavaScript''>"
514 " <!-- "
515 " vis[''"+string(funnb)+"''] = ''hide'';"
516 " //-->"
517 " </SCRIPT>"
518 " <TR WIDTH=""100%"">"
519 " <TD>"
520 " <DIV ID=''Layer"+string(funnb)+"'' STYLE=''display: none;''>"
521 " <TABLE WIDTH=""100%"" CELLSPACING=""0"" BORDER=""1"" BORDERCOLOR=""silver"">"
522 ]
523 if or(note<>"") then
524 HTML_DATA=[
525 HTML_DATA
526 " <TR>"
527 " <TD COLSPAN=""2"">"+note+"</TD>"
528 " </TR>"
529 ]
530 end
531 if or(rightex<>"") | or(leftex<>"") then
532 if leftex=="" then leftex="None";end
533 if rightex=="" then rightex="None";end
534 HTML_DATA=[
535 HTML_DATA
536 " <TR>"
537 " <TD VALIGN=""top"" WIDTH=""50%""><TT>"+leftex+"</TT></td>"
538 " <TD VALIGN=""top"" WIDTH=""50%""><TT>"+rightex+"</TT></td>"
539 " </TR>"
540 ]
541
542 end
543 HTML_DATA=[
544 HTML_DATA
545 " </TABLE>"
546 " <BR>"
547 " </DIV>"
548 " </TD>"
549 " </TR>"
550 ]
551end
552
553HTML_DATA=[
554 HTML_DATA
555 "</TABLE>"
556 ]
557
558mputl(HTML_DATA,htmlfile)
559mclose(htmlfile)
560endfunction
561
562//****************************************************************************************
563// function [matname,descr,sciname,note,matex,sciex]=datatohtml(matname,descr,sciname,note,matex,sciex)
564// Copyright INRIA
565// Convert XML data to HTML
566//****************************************************************************************
567function [matname,descr,sciname,note,matex,sciex]=datatohtml(matname,descr,sciname,note,matex,sciex)
568
569// Syntax modification
570matname=strsubst(matname,"<MATH>","")
571matname=strsubst(matname,"</MATH>","")
572matname=strsubst(matname,"|-|","&#8596;")
573
574sciname=strsubst(sciname,"<MATH>","")
575sciname=strsubst(sciname,"</MATH>","")
576sciname=strsubst(sciname,"|-|","&#8596;")
577
578note=strsubst(note,"<P>","")
579note=strsubst(note,"</P>","<BR>")
580note=strsubst(note,"<B>","<B>")
581note=strsubst(note,"<MATH>","")
582note=strsubst(note,"</MATH>","")
583note=strsubst(note,"|-|","&#8596;")
584
585note=strsubst(note,"</NOTE_ITEM>","")
586kitem=strindex(note,"<NOTE_ITEM")
587kitem=[kitem,length(note)+1]
588klabel=strindex(note,"LABEL")
589kend=strindex(note,""">")
590if kitem<>[] then
591 tmp=part(note,1:kitem(1)-1)
592 for m=1:size(kitem,"*")-1
593 label=strsubst(part(note,klabel(m)+7:kend(m)-1),"|-|","&#8596;")
594 tmp=tmp+"&#9657; "+label+":<BR>"+part(note,kend(m)+2:kitem(m+1)-1)+"<BR>"
595 end
596 note=stripblanks(tmp)
597end
598
599// Remove useless newline
600if max(strindex(note,"<BR>"))==length(note)-3 then
601 note=part(note,1:(length(note)-4))
602end
603
604if matex<>"" then
605 tmp="<TT>"
606 for m=1:size(matex,1)
607 matex(m)=strsubst(matex(m),"<MATH>","")
608 matex(m)=strsubst(matex(m),"</MATH>","")
609 tmp=tmp+matex(m)+"<BR>"
610 end
611 tmp=tmp+"</TT>"
612 matex=tmp
613end
614
615if sciex<>"" then
616 tmp="<TT>"
617 for m=1:size(sciex,1)
618 tmp=tmp+sciex(m)+"<BR>"
619 end
620 tmp=tmp+"</TT>"
621 sciex=tmp
622end
623
624rhs=argn(2)
625if rhs<3 then
626 note=""
627end
628if rhs<4 then
629 matex=""
630end
631if rhs<5 then
632 sciex=""
633end
634
635endfunction
636
637//****************************************************************************************
638//function []=write_latex_data(matname,descr,sciname,note,matex,sciex,funnb,dic)
639// Copyright INRIA
640//****************************************************************************************
641function []=write_latex_data(matname,descr,sciname,note,matex,sciex,funnb,dic,index_name,index_entry)
642[matname,descr,sciname,note,matex,sciex]=datatolatex(matname,descr,sciname,note,matex,sciex)
643
644if dic=="M2SCI" then
645 leftname=matname
646 rightname=sciname
647 leftex=matex
648 rightex=sciex
649else
650 leftname=sciname
651 rightname=matname
652 leftex=sciex
653 rightex=matex
654end
655
656[latexfile,ierr]=mopen(LATEXFILE,"a+")
657if ierr<>0 then
658 mprintf("Could not open file : "+LATEXFILE);
659 return
660end
661
662// Prepare data to write in LATEX file
663ind_name=strsubst(special_name(leftname)," ","-")
664ind_name=strsubst(ind_name,"$\Leftrightarrow$","")
665
666LATEX_DATA = [
667 "%---------- "+ind_name+" ----------"
668 "\pdfbookmark[1]{"+leftname+"}{"+index_name+"}"
669 ]
670
671if index_entry=="Operators" then
672 LATEX_DATA = [
673 LATEX_DATA;
674 "\index{"+index_entry+"!"+index_name+"\textsf{("+leftname+")}}"
675 ]
676elseif index_entry=="Variables" & index_name=="Last index" then
677 LATEX_DATA = [
678 LATEX_DATA;
679 "\index{"+index_entry+"!"+index_name+"\textsf{(end)}}"
680 ]
681else
682 LATEX_DATA = [
683 LATEX_DATA;
684 "\index{"+index_entry+"!"+index_name+"}"
685 ]
686end
687
688LATEX_DATA = [
689 LATEX_DATA;
690 "\begin{center}"
691 "\begin{tabular}{|p{4.5cm}|p{3.25cm}p{3.25cm}|p{4.5cm}|}"
692 "\hline\multicolumn{1}{|p{4.5cm}}{\centering\textbf{"+leftname+"}} & "
693 "\multicolumn{2}{|p{6.5cm}|}{\centering\textit{"+descr+"}} & "
694 "\multicolumn{1}{p{4.5cm}|}{\centering\textbf{"+rightname+"}} \\ \hline"
695 ]
696if note<>"" then
697 LATEX_DATA=[
698 LATEX_DATA
699 "\multicolumn{4}{|p{16.5cm}|}{"+note+"} \\ \hline"
700 ]
701end
702
703if or(rightex<>"") | or(leftex<>"") then
704 if leftex=="" then leftex="None";end
705 if rightex=="" then rightex="None";end
706 LATEX_DATA=[
707 LATEX_DATA
708 "\multicolumn{2}{|p{7.75cm}|}{"+leftex+"} & "
709 "\multicolumn{2}{p{7.75cm}|}{"+rightex+"} \\ \hline"
710 ]
711end
712
713LATEX_DATA=[
714 LATEX_DATA
715 "\end{tabular}"
716 "\end{center}"
717 ]
718
719mputl(LATEX_DATA,latexfile)
720mclose(latexfile)
721endfunction
722
723//****************************************************************************************
724// function [matname,descr,sciname,note,matex,sciex]=datatolatex(matname,descr,sciname,note,matex,sciex)
725// Copyright INRIA
726// Convert XML data to LATEX
727//****************************************************************************************
728function [matname,descr,sciname,note,matex,sciex]=datatolatex(matname,descr,sciname,note,matex,sciex)
729
730matname=strsubst(matname,"\","\textbackslash");
731matname=strsubst(matname,"<MATH>^</MATH>","\textasciicircum")
732matname=strsubst(matname,"%","\%")
733matname=strsubst(matname,"$","\$")
734matname=strsubst(matname,"&amp;","\&")
735matname=strsubst(matname,"&lt;","<")
736matname=strsubst(matname,"&gt;",">")
737matname=strsubst(matname,"<MATH>","$")
738matname=strsubst(matname,"</MATH>","$")
739matname=strsubst(matname,"|-|","$\Leftrightarrow$")
740matname=strsubst(matname,"_","\_")
741
742sciname=strsubst(sciname,"\","\textbackslash");
743sciname=strsubst(sciname,"<MATH>^</MATH>","\textasciicircum")
744sciname=strsubst(sciname,"%","\%")
745sciname=strsubst(sciname,"$","\$")
746sciname=strsubst(sciname,"&amp;","\&")
747sciname=strsubst(sciname,"&lt;","<")
748sciname=strsubst(sciname,"&gt;",">")
749sciname=strsubst(sciname,"<MATH>","$")
750sciname=strsubst(sciname,"</MATH>","$")
751sciname=strsubst(sciname,"|-|","$\Leftrightarrow$")
752sciname=strsubst(sciname,"_","\_")
753
754note=strsubst(note,"\","\textbackslash")
755note=strsubst(note,"$","\$")
756note=strsubst(note,"<P>","")
757note=strsubst(note,"</P>","\newline ")
758note=strsubst(note,"<B>","\textbf{")
759note=strsubst(note,"</B>","}")
760note=strsubst(note,"<MATH>^</MATH>","\textasciicircum")
761note=strsubst(note,"<MATH>","$")
762note=strsubst(note,"</MATH>","$")
763note=strsubst(note,"</NOTE_ITEM>","")
764note=strsubst(note,"&lt;","<")
765note=strsubst(note,"&gt;",">")
766note=strsubst(note,"%","\%")
767note=strsubst(note,"|-|","$\Leftrightarrow$")
768
769kitem=strindex(note,"<NOTE_ITEM")
770kitem=[kitem,length(note)+1]
771klabel=strindex(note,"LABEL")
772kend=strindex(note,""">")
773if kitem<>[] then
774 tmp=part(note,1:kitem(1)-1)
775 for m=1:size(kitem,"*")-1
776 label=strsubst(part(note,klabel(m)+7:kend(m)-1),"|-|","$\Leftrightarrow$")
777 tmp=tmp+"$\triangleright$ "+label+":\newline "+part(note,kend(m)+2:kitem(m+1)-1)+"\newline "
778 end
779 note=tmp
780 note=stripblanks(strsubst(note,"_","\_"))
781end
782
783// Remove useless newline
784if max(strindex(note,"\newline"))==length(note)-7 then
785 note=part(note,1:(length(note)-8))
786end
787
788if or(matex<>"") then
789 tmp="\texttt{"
790 for m=1:size(matex,1)
791 matex(m)=strsubst(matex(m),"&amp;","\&")
792 matex(m)=strsubst(matex(m),"&lt;","<")
793 matex(m)=strsubst(matex(m),"&gt;",">")
794 matex(m)=strsubst(matex(m),"^","\textasciicircum")
795 matex(m)=strsubst(matex(m),"_","\_")
796 matex(m)=strsubst(matex(m),"$","\$")
797 matex(m)=strsubst(matex(m),"<MATH>","$")
798 matex(m)=strsubst(matex(m),"</MATH>","$")
799 tmp=tmp+matex(m)
800 if m<>size(matex,1) then
801 tmp=tmp+"\newline "
802 end
803 end
804 tmp=tmp+"}"
805 matex=tmp
806end
807
808if or(sciex<>"") then
809 tmp="\texttt{"
810 for m=1:size(sciex,1)
811 sciex(m)=strsubst(sciex(m),"&amp;","\&")
812 sciex(m)=strsubst(sciex(m),"&lt;","<")
813 sciex(m)=strsubst(sciex(m),"&gt;",">")
814 sciex(m)=strsubst(sciex(m),"^","\textasciicircum")
815 sciex(m)=strsubst(sciex(m),"_","\_")
816 sciex(m)=strsubst(sciex(m),"%","\%")
817 sciex(m)=strsubst(sciex(m),"$","\$")
818 sciex(m)=strsubst(sciex(m),"<MATH>","$")
819 sciex(m)=strsubst(sciex(m),"</MATH>","$")
820 tmp=tmp+sciex(m)
821 if m<>size(sciex,1) then
822 tmp=tmp+"\newline "
823 end
824 end
825 tmp=tmp+"}"
826 sciex=tmp
827end
828
829rhs=argn(2)
830if rhs<3 then
831 note=""
832end
833if rhs<4 then
834 matex=""
835end
836if rhs<5 then
837 sciex=""
838end
839
840endfunction
841
842//****************************************************************************************
843// function []=create_html_index(indexfile,names,dic)
844// Copyright INRIA
845// - indexfile: name of file to create
846// - names: function names
847// - dic: dic to create
848//****************************************************************************************
849function []=create_html_index(indexfile,names,dic,indentries)
850
851htmlfile=mopen(indexfile,"w")
852
853mputl(HTML_FILE_BEG,htmlfile)
854
855firstlettersav=""
856for kname=1:size(names,"*")
857
858 firstletter=indentries(kname)
859 if length(firstletter)==1 then
860 couche=string(ascii(firstletter))
861 elseif firstletter=="Operators" then
862 couche=string(1000)
863 else
864 couche=string(1001)
865 end
866 if firstletter<>firstlettersav then
867 firstlettersav=firstletter
868 if kname<>1 then
869 HTML_DATA=[
870 " </DIV>"
871 " </TD>"
872 " </TR>"
873 "</TABLE>"
874 ]
875 else
876 if dic=="M2SCI" then
877 HTML_DATA="<A HREF=""SCI2M_doc.htm"" TARGET=""_top"">Go to SCI2M</A><BR>"
878 else
879 HTML_DATA="<A HREF=""M2SCI_doc.htm"" TARGET=""_top"">Go to M2SCI</A><BR>"
880 end
881 HTML_DATA=[
882 HTML_DATA
883 "<BR><A HREF="""+dic+".htm#Foreword"" TARGET=""dic"">Foreword</A><BR><BR>"
884 ]
885 end
886 HTML_DATA = [
887 HTML_DATA;
888 "<TABLE WIDTH=""70"">"
889 " <TR>"
890 " <TD>"
891 " <A HREF=""javascript:void(0)"" onClick=""javascript:swap_couche(''"+couche+"''); parent.dic.document.location.href = ''"+dic+".htm#"+firstletter+"''"">"+firstletter+"</A><BR>"
892 " </TD>"
893 " </TR>"
894 " <SCRIPT language=''JavaScript''>"
895 " <!-- "
896 " vis[''"+couche+"''] = ''hide'';"
897 " //-->"
898 " </SCRIPT>"
899 " <TR>"
900 " <TD>"
901 " <DIV ID=''Layer"+couche+"'' STYLE=''display: none;''>"
902 ]
903 mputl(HTML_DATA,htmlfile)
904 end
905
906 ind_name=strsubst(special_name(names(kname))," ","-")
907 ind_name=strsubst(ind_name,"|-|","")
908
909 HTML_DATA=[
910 "<A HREF="""+dic+".htm#"+ind_name+""" TARGET=""dic"">"+strsubst(names(kname)," |-| ","--")+"</A><BR>"]
911 mputl(HTML_DATA,htmlfile)
912
913end
914HTML_DATA=[
915 " </DIV>"
916 " </TD>"
917 " </TR>"
918 "</TABLE>"
919 HTML_FILE_END]
920
921mputl(HTML_DATA,htmlfile)
922mclose(htmlfile);
923endfunction
924
925//****************************************************************************************
926// function [out]=special_name(in)
927// Copyright INRIA
928// Deals with operator names
929//****************************************************************************************
930function [out]=special_name(in)
931if in=="+" then
932 out="plus"
933elseif in=="-" then
934 out="minus"
935elseif in==".*." then
936 out="kronecker product"
937elseif in=="./." then
938 out="kronecker right division"
939elseif in==".\." then
940 out="kronecker letf division"
941elseif in=="/" then
942 out="right division"
943elseif in=="./" then
944 out="elementwise right division"
945elseif in==".\" | in==".\textbackslash" then
946 out="elementwise left division"
947elseif in=="<MATH>^</MATH>" | in=="^" | in=="\textasciicircum" then
948 out="exponent"
949elseif in==".<MATH>^</MATH>" | in==".^" | in==".\textasciicircum" then
950 out="elementwise exponent"
951elseif in=="*" then
952 out="multiplication"
953elseif in==".*" then
954 out="elementwise multiplication"
955elseif in=="<MATH>&gt;</MATH>" | in=="$>$" | in=="&gt;" then
956 out="greater than"
957elseif in=="<MATH>&lt;</MATH>" | in=="$<$" | in=="&lt;"then
958 out="smaller than"
959elseif in=="<MATH>&gt;</MATH>=" | in=="$>$=" | in=="&gt;=" then
960 out="greater or equal to"
961elseif in=="<MATH>&lt;</MATH>=" | in=="$<$=" | in=="&lt;=" then
962 out="smaller or equal to"
963elseif in=="==" then
964 out="equal to"
965elseif in=="~=" then
966 out="not equal to"
967elseif in=="''" then
968 out="transpose"
969elseif in==".''" then
970 out="elementwise transpose"
971elseif in=="&amp;" | in=="\&" then
972 out="logical AND"
973elseif in=="<MATH>|</MATH>" | in=="|" | in=="$|$" then
974 out="logical OR"
975elseif in=="\" | in=="\textbackslash" then
976 out="left division"
977elseif in==":" then
978 out="colon"
979elseif in=="~" then
980 out="negation"
981elseif in=="\$" | in=="$" | in=="end (index)" then
982 out="Last index"
983elseif in=="~MSDOS" then
984 out="isunix"
985else
986 out=strsubst(in,"\_","");
987 out=strsubst(out,"_","");
988 out=strsubst(out,"%","");
989 out=strsubst(out,"$","");
990end
991endfunction
992
993//****************************************************************************************
994// function [entry]=index_entry(in)
995// Copyright INRIA
996// Finds index entries
997//****************************************************************************************
998function [entry]=index_entry(in)
999if dic=="M2SCI" & or(in==["i","j","eps","ans","pi","end (index)"]) then
1000 entry="Variables"
1001elseif part(in,1)=="%" | part(in,2)=="%" | in=="$" | in=="\$" | ~isempty(strindex(in,"MSDOS")) then
1002 entry="Variables"
1003elseif special_name(in)<>in & isempty(strindex(in,"_")) then
1004 entry="Operators"
1005else
1006 entry=convstr(part(in,1),"u")
1007end
1008endfunction
1009
1010//****************************************************************************************
1011// Batch instructions
1012//****************************************************************************************
1013disp("M2SCI");
1014xml2htmlpdf("matscifuns.xml","M2SCI")
1015disp("SCI2M");
1016xml2htmlpdf("matscifuns.xml","SCI2M")
1017disp("Doc done !")