Example: confidence

Programming in Scilab

Programming in ScilabMicha el BaudinSeptember 2011 AbstractIn this document, we present Programming in Scilab . In the first part,we present the management of the memory of Scilab . In the second part, wepresent various data types and analyze Programming methods associated withthese data structures. In the third part, we present features to design flexibleand robust functions. In the last part, we present methods which allow toachieve good performances. We emphasize the use of vectorized functions,which allow to get the best performances, based on calls to highly optimizednumerical libraries.

Programming in Scilab Micha el Baudin September 2011 Abstract In this document, we present programming in Scilab. In the rst part, we present the management of the memory of Scilab.

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Programming in Scilab

1 Programming in ScilabMicha el BaudinSeptember 2011 AbstractIn this document, we present Programming in Scilab . In the first part,we present the management of the memory of Scilab . In the second part, wepresent various data types and analyze Programming methods associated withthese data structures. In the third part, we present features to design flexibleand robust functions. In the last part, we present methods which allow toachieve good performances. We emphasize the use of vectorized functions,which allow to get the best performances, based on calls to highly optimizednumerical libraries.

2 Many examples are provided, which allow to see theeffectiveness of the methods that we Introduction52 Variable and memory The stack .. More on memory management .. limitations from Scilab .. limitations of 32 and 64 bit systems .. algorithm instacksize.. The list of variables and the functionwho.. Portability variables and functions .. Destroying variables :clear.. Thetypeandtypeoffunctions .. Notes and references .. Exercises .. 183 Special data Strings .. Polynomials .. Hypermatrices.

3 Type and dimension of an extracted hypermatrix .. Thelistdata type .. Thetlistdata type .. Emulating OO Programming with typed lists .. of positional arguments .. person class in Scilab .. the class .. Overloading typed lists .. Themlistdata type .. Thestructdata type .. The array ofstructs .. Thecelldata type .. Comparison of data types .. Notes and references .. Exercises .. 524 Management of Advanced function management .. to inquire about functions .. are not reserved.

4 Are variables .. Designing flexible functions .. ofargn.. practical issue .. variable arguments in practice .. values of optional arguments .. with variable type input arguments .. Robust functions .. framework for checks of input arguments .. example of robust function .. Usingparameters.. of the module .. practical case .. with theparametersmodule .. The scope of variables in the call stack .. of the scope of variables .. function: an ambiguous case .. function: a silently failing case.

5 Issues with callbacks .. recursion .. index .. with extra arguments .. Meta Programming :execstranddeff.. use forexecstr.. use fordeff.. practical optimization example .. Notes and references .. 10225 Measuring the performance .. uses .. vs CPU time .. a function .. Vectorization principles .. interpreter .. vs vectorization .. example of performance analysis .. Optimization tricks .. danger of dymanic matrices .. matrix indexing .. matrix access .. rows or columns of a vector.

6 Vectorized functions .. access is faster .. Optimized linear algebra libraries .. , LAPACK, ATLAS and the MKL .. optimization methods .. optimized linear algebra libraries for Scilab on Win-dows .. optimized linear algebra libraries for Scilab on Linux example of performance improvement .. Measuring flops .. product .. computations .. Notes and references .. Exercises .. 1446 Acknowledgments1447 Answers to Answers for section 2 .. Answers for section 3 .. Answers for section 5 .. 148 Bibliography151 Index1543 Copyrightc 2008-2010 - Michael BaudinCopyrightc 2010-2011 - DIGITEO - Michael BaudinThis file must be used under the terms of the Creative Commons Attribution-ShareAlike Unported License: IntroductionThis document is an open-source project.

7 The LATEX sources are available on theScilab Forge: LATEX sources are provided under the terms of the Creative Commons Attribution-ShareAlike Unported License: Scilab scripts are provided on the Forge, inside the project, under thescriptssub-directory. The scripts are available under the CeCiLL licence: Variable and memory managementIn this section, we describe several Scilab features which allow to manage the vari-ables and the memory. Indeed, we sometimes face large computations, so that, inorder to get the most out of Scilab , we must increase the memory available for begin by presenting the stack which is used by Scilab to manage its present how to use thestacksizefunction in order to configure the size of thestack.

8 Then we analyze the maximum available memory for Scilab , depending on thelimitations of the operating system. We briefly present thewhofunction, as a toolto inquire about the variables currently defined. Then we emphasize the portabilityvariables and functions, so that we can design scripts which work equally well onvarious operating systems. We present theclearfunction, which allows to deletevariables when there is no memory left. Finally, we present two functions often usedwhen we want to dynamically change the behavior of an algorithm depending onthe type of a variable, that is, we present informations presented in this section will be interesting for those users whowant to have a more in-depth understanding of the internals of Scilab .

9 By the way,explicitely managing the memory is a crucial feature which allows to perform themost memory demanding computations. The commands which allow to managevariables and the memory are presented in figure the first section, we analyze the management of the stack and present thestacksizefunction. Then we analyze the maximum available memory dependingon the operating system. In the third section, we present thewhofunction, whichdisplays the list of current variables. We emphasize in the fourth section the useof portability variables and functions, which allows to design scripts which workequally well on most operating systems.

10 Then we present theclearfunction, whichallows to destroy an existing variable. In the final section, we present thetypeandtypeoffunctions, which allows to dynamically compute the type of a variablesclearglobal kills global variablesglobaldefine global variableisglobalcheck if a variable is globalstacksizeset Scilab stack sizegstacksizeset/get Scilab global stack sizewholisting of variableswhouserlisting of user s variableswhoslisting of variables in long formFigure 1: Functions to manage Variables ( 10%)User Variables ( 40%)Free ( 50%)Stack (100%)Figure 2: The stack of The stackIn Scilab v5 (and previous versions), the memory is managed with astack.


Related search queries