⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch37.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 2 页
字号:


<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




 



<UL>



	<LI><A HREF="#Heading1">Mathematics on Linux</A>



	<UL>



		<LI><A HREF="#Heading2">Scilab</A>



		<UL>



			<LI><A HREF="#Heading3">Where to Get Scilab</A>



		</UL>



		<LI><A HREF="#Heading4">NOTE</A>



		<UL>



			<LI><A HREF="#Heading5">More Information on Scilab</A>



		</UL>



		<LI><A HREF="#Heading6">Pari</A>



		<UL>



			<LI><A HREF="#Heading7">Where to Get Pari</A>



			<LI><A HREF="#Heading8">Running Pari</A>



		</UL>



		<LI><A HREF="#Heading9">Using LISP-STAT</A>



		<UL>



			<LI><A HREF="#Heading10">Where to Get LISP-STAT</A>



			<LI><A HREF="#Heading11">Running xlispstat</A>



			<LI><A HREF="#Heading12">Where to Get More Information About LISP-STAT</A>



		</UL>



		<LI><A HREF="#Heading13">A Last Note</A>



		<LI><A HREF="#Heading14">Summary</A>



	</UL>



</UL>







<P>



<HR SIZE="4">







<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">Mathematics on Linux</FONT></H2>



<P><I>by Kamran Husain</I></P>



<P>IN THIS CHAPTER</P>







<UL>



	<LI>Scilab 



	<P>



	<LI>Pari 



	<P>



	<LI>Using LISP-STAT 



	<P>



	<LI>A Last Note 



</UL>







<P>This book has dealt with many issues regarding the tools available for Linux.



Now, let's look at some of the mathematics tools for Linux. Specifically, we will



work with tools for doing mathe-matical and statistical applications under Linux.



One such tool we will be working with is Scilab, an interactive math and graphics



package. Another tool for symbolic math is Pari. For statistical operations using



LISP choose LISP-STAT.</P>







<P>Hopefully, this chapter will give you a comfortable alternative to writing applications



in languages other than FORTRAN on Linux. (The FORTRAN compiler is called <TT>f77</TT>.)



<H3 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">Scilab</FONT></H3>



<P>The Scilab application is developed by the Institut National de Recherche de Informatique



et en Automatique (INRIA) in France. Although this application is not as formidable



as MATLAB, a commercial product with more bells and whistles, Scilab is still powerful



enough to provide decent graphics and solutions to math problems.</P>



<P>With Scilab you can do matrix multiplication, plot graphs, and so on. Using its



built-in functions, Scilab enables you to write your own functions. With its toolbox,



you can build your own signal-processing functions in addition to those provided



by Scilab.</P>



<P>Added to all its features, the help file is quite voluminous. If you want to find



out how to do a math problem with Scilab, you will probably find it in the docs.



Added to the good documentation are sample programs to get you started.



<H4 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">Where to Get Scilab</FONT></H4>



<P>Now that you are probably interested in Scilab, you will want to know where to



get it. Scilab is free via the Internet. The primary site is <TT>ftp.inria.fr</TT>,



and the directory for this is in <TT>INRIA/Projects/Meta2/Scilab</TT>. Look for the



zipped file with the latest date. Each zipped file is complete in itself. Mirror



sites include <TT>sunsite.unc.edu</TT> and <TT>tsx-11.mit.edu</TT>.</P>



<P>The file you are looking for is called <TT>scilab-2.1.1-linux.tar.gz</TT>. In



its unzipped form, the file is about 17MB in size. After utarring this file, you



will have a directory called <TT>scilab-2.1.1</TT> with all related files and accessories.</P>



<P>After you have installed it, go to the bin subdirectory and modify the <TT>Scilab</TT>



shell script file. Replace the assignment of the <TT>SCI</TT> variable with the path



to the location of your <TT>Scilab</TT> files. For example, in my case I set the



value to<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">SCI=&quot;/home/khusain/scilab-2.1.1&quot;



</FONT></PRE>







<DL>



	<DT><FONT COLOR="#0066FF"></FONT></DT>



</DL>











<DL>



	<DD>



<HR>



<A NAME="Heading4<FONT COLOR="#000077"><B>NOTE:</B> </FONT>If Scilab does not



	show up in color the first time you invoke it, try <TT>*customization: -color</TT>



	in your <TT>.Xdefaults</TT> file. Don't forget to run <TT>xrdb .Xdefaults</TT> to



	enforce the change.



<HR>







</DL>







<P>The prompt for Scilab is <TT>--&gt;</TT>. You will see responses to your commands



immediately below where you type in entries.</P>







<P>A healthy example of how to use Scilab would probably be beneficial. Let's see



how to declare values:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;x=1.0



</FONT></PRE>



<P>This sets x equal to 1.0. To declare an array, use square brackets:<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;x=[1 2 3]



x =



!  1. 2. 3. !



</FONT></PRE>



<P>See Figure 37.1 to see what it looks like on your screen. <BR>



<BR>











<A HREF="../art/37/36fig01.gif"><B>Figure 37.1.</B></a> <I>The main screen for Scilab. </I><BR>



<BR>



To declare a large array you can use indices of the form [start<TT>:</TT>end]. Use



a semicolon at the end of the line to indicate that you really do not want Scilab



to echo the results back to you. So the statement<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;x=[1:100];



</FONT></PRE>



<P>declares <TT>x</TT> as a vector of values from 1 to 100 and does not display the



contents of <TT>x</TT> back to you. If you want to give staggered values of <TT>x</TT>,



you can use an increment operator in the form [<TT>start:increment:stop</TT>]. So,



this statement declares <TT>x</TT> to contain five odd numbers from <TT>1</TT>:<FONT



COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;x=[1:2:10]



x =



! 1. 3. 5. 7. 9. !



</FONT></PRE>



<P>Let's try an example of a simple matrix multiplication problem of ax=b. First



declare the <TT>a</TT> matrix, separating all the rows with semicolons. If you do



not use semicolons, the values in matrix <TT>a</TT> will be interpreted as a 25x1



vector instead of a 5x5 matrix.<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;a=[ 1 1 0 0 0; 1 1 1 0 0; 0 1 1 1 0; 0 0 1 1 1; 0 0 0 1 1]



a =



! 1. 1. 0. 0. 0. !



! 1. 1. 1. 0. 0. !



! 0. 1. 1. 1. 0. !



! 0. 0. 1. 1. 1. !



! 0. 0. 0. 1. 1. !



</FONT></PRE>



<P>Then declare <TT>X</TT> as a vector.<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;X=[ 1 3 5 7 9 ]



X =



! 1. 3. 5. 7. 9. !



</FONT></PRE>



<P>To get the dimensions right for the multiplication, you have to use the single



quote operator (') to get the transpose of <TT>X</TT>. Then put the results of the



multiplication of <TT>a</TT> and <TT>X</TT> transpose into <TT>b</TT>.<FONT COLOR="#0066FF"></FONT>



<PRE><FONT COLOR="#0066FF">--&gt;b= a * X'



b =



!  4. !



!  9. !



! 15. !



! 21. !



! 16. !



--&gt;



</FONT></PRE>



<P>The results look right. In fact, Scilab displayed the dimensions correctly too,



since the results of the multiplication are a matrix of size 5x1.



<H4 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">More Information



on Scilab</FONT></H4>



<P>The documentation for the Scilab application is in the <TT>doc/intro</TT> directory

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -