Lyme User Manual ©1999-2008, Calerga Sàrl
Total Page:16
File Type:pdf, Size:1020Kb
Calerga LyME 3.1 User Manual 2 LyME User Manual ©1999-2008, Calerga Sàrl Copyright 1999-2008, Calerga Sàrl. No part of this publication may be reproduced, transmitted or stored in any form or by any means including electronic, mechanical, recording or oth- erwise, without the express written permission of Calerga Sàrl. The information provided in this manual is for reference and information use only, and Calerga assumes no responsibility or liability for any inaccura- cies or errors that may appear in this documentation. LyME, Sysquake, LME, Calerga, the Calerga logo, and icons are copyrighted and are protected under the Swiss and international laws. Copying this soft- ware for any reason beyond archival purposes is a violation of copyright, and violators may be subject to civil and criminal penalties. LyME, Sysquake, LME, and Calerga are trademarks of Calerga Sàrl. All other trademarks are the property of their respective owners. LyME User Manual, August 2008. Yves Piguet, Calerga Sàrl, Lausanne, Switzerland. Most of the material in LyME User Manual has first been written as a set of XHTML files, with lots of cross-reference links. Since (X)HTML is not very well suited for printing, it has been converted to LATEX with the help of a home-made conversion utility. Additional XML tags have been used to benefit from LATEX features: e.g. raster images have been replaced with EPS images, equations have been converted from text to real mathematic notation, and a table of contents and an index have been added. The same method has been used to create the material for the help command. Thanks to the make utility, the whole process is completely automatic. This system has proved to be very flexible to maintain three useful formats in parallel: two for on-line help, and one for high-quality printing. World Wide Web: http://www.calerga.com E-mail: [email protected] Mail: Calerga Sàrl Av. de la Chablière 35 1004 Lausanne Switzerland Typesetting: 2008-8-2 Contents 1 Using LyME 5 1.1 LyME Installation . 5 1.2 Using LyME . 5 1.3 User input . 12 1.4 Data exchange . 13 1.5 License . 13 1.6 What’s more in Sysquake . 14 1.7 MathLib . 14 2 LME Tutorial 15 2.1 Simple operations . 15 2.2 Complex Numbers . 16 2.3 Vectors and Matrices . 18 2.4 Polynomials . 21 2.5 Strings . 22 2.6 Variables . 22 2.7 Loops and Conditional Execution . 23 2.8 Functions . 23 2.9 Local and Global Variables . 26 3 LME Reference 29 3.1 Program format . 29 3.2 Function Call . 30 3.3 Libraries . 32 3.4 Types . 32 3.5 Input and Output . 40 3.6 Error Messages . 41 3.7 Variable Assignment and Subscripting . 46 3.8 Programming Constructs . 53 3.9 Debugging Commands . 69 3.10 Miscellaneous Functions . 76 3.11 Sandbox Function . 101 3.12 Operators . 103 3.13 Mathematical Functions . 135 4 LyME User Manual ©1999-2008, Calerga Sàrl 3.14 Linear Algebra . 188 3.15 Array Functions . 233 3.16 Triangulation Functions . 267 3.17 Integer Functions . 274 3.18 Non-Linear Numerical Functions . 277 3.19 String Functions . 294 3.20 List Functions . 308 3.21 Structure Functions . 312 3.22 Object Functions . 319 3.23 Logical Functions . 321 3.24 Dynamical System Functions . 333 3.25 Input/Output Functions . 340 3.26 Palm Database Functions . 356 3.27 Palm File Streaming Functions . 362 3.28 Palm VFS Functions . 364 3.29 Time Functions . 368 3.30 Date Conversion Functions . 370 3.31 Quaternions . 372 3.32 Serial Port Functions . 382 3.33 Long Integers . 385 3.34 LyME Functions . 387 3.35 Dialog Functions . 397 3.36 Audio output . 399 3.37 Machine Code Functions . 401 3.38 Introduction . 401 3.39 Functions . 402 4 Libraries 409 4.1 stdlib . 410 4.2 stat . 426 4.3 classes . 437 4.4 ratio . 446 4.5 bitfield . 449 4.6 filter . 455 4.7 lti . 465 4.8 sigenc . 490 4.9 wav . 496 4.10 date . 498 4.11 constants . 501 Index 502 Chapter 1 Using LyME LyME is a port of LME ("Lightweight Math Engine", the heart of Sysquake) to Palm OS handheld devices. It implements about 320 native commands, functions and operators, mostly compatible with Matlab. It requires Palm OS 3.1 or higher and at least 1 MBytes of memory free. 1.1 LyME Installation Install at least MathLib.prc (unless it has already been installed for another application or it is included in the device ROM) and LyME.prc. You can also install library files (the files which end with .pdb) which add more functions to LyME. 1.2 Using LyME Launch LyME by tapping its icon. Figure 1.1 6 LyME User Manual ©1999-2008, Calerga Sàrl Figure 1.2 Figure 1.3 Simple expressions Write expressions in the top field, tap the Eval button or write return (topright-to-bottomleft Graffiti stroke), and read the result in the bot- tom field. To enter parenthesis or operators, you can also tap one of the sym- bols at the botton of the screen. To enter a function or to check its arguments, tap fn and the bottom right of the screen, scroll the list, and tap the function you want. You can also tap outside the list to discard it. Previous commands can be retrieved with the arrows at the top left of the screen. The command field can be cleared completely with a tap on the C near the arrows. An Edit menu is also available for the usual Cut/Copy/Paste/Undo commands; tap the window title "LyME" or the menu button below the screen. To stop execution, press the Page Down key until the Eval button label is displayed. Graphics Some commands produce graphical output. Graphics replace the text output below the command field. Graphics and text output may be toggled with the T and G buttons at the top of the screen. Graphics are usually scaled to fill the graphics area. No axis is drawn, because of the constrained screen size. To check the scale, tap anywhere in the graphics area and read the coordinates of the point below the pen. Most graphical functions support an additional argument to specify the color. Using LyME 7 Figure 1.4 Figure 1.5 Figure 1.6 8 LyME User Manual ©1999-2008, Calerga Sàrl Figure 1.7 Programs There are two kinds of programs in LyME: scripts and functions. Scripts are simply collections of statements, variable assignments and ex- pressions which are evaluated exactly as if they were written in the command field. Functions (collected in libraries) have input and output arguments, and local variables. They cannot modify the workspace variables you define from the command field or from scripts. Both scripts and functions are entered in an editor window, and are saved in a persistant database. Standard Edit menu commands are available to Cut, Copy and Paste text in LyME or between LyME and other Palm applications such as Memo Pad. Scripts To program a script in LyME, tap the Edit button and (new). Replace "untitled" with a script name (such as "test"). Write your statements, typically one per line, below. When you’re ready, tap OK or Load. OK just stores your new script in the LyME database, while Load also executes it. Functions To program functions in LyME, tap the Edit button and (new). Replace "untitled" with a library name (such as "stat" or "control"). Write all your functions below. When you’re satisfied, tap OK or Load. OK stores your new library in the LyME database, while Load also issues a "use" command to LME Using LyME 9 Figure 1.8 Figure 1.9 Figure 1.10 10 LyME User Manual ©1999-2008, Calerga Sàrl Figure 1.11 Figure 1.12 to make your functions available from the command line. You can then test your library. To edit again your script or your library, tap the Edit button, then pick its name from the list. The "Load" button will remove the previous definitions and replace them with the new ones. Error correction When you execute a function and an error occurs, the library name, the function name and the line number are displayed. If you tap some- where on the library or function name, then tap the Edit button, LyME displays directly the offending line to help you correct the bug. Here is an example of a problematic function. Tap Load, then write bugfn. LyME stops when it tries to write to the 10th element of the 3-by-3 matrix. Using LyME 11 Figure 1.13 Figure 1.14 Tap the function name in the error message ("bugfn"), then tap the Edit button to jump to the line where the error occurred. Using libraries To use a library when you restart LyME, tap the Ld (load) button and the name of the library. The command to do the same is "use library- name". You can also use this command in another library; note however that functions in nested libraries are hidden, unless their library is explicitly used where they are called. If you use frequently the same libraries, you may want to use them Figure 1.15 12 LyME User Manual ©1999-2008, Calerga Sàrl Figure 1.16 automatically at startup. Select Startup Commands in the File menu, then type any command you want to be executed every time you launch LyME or Clear All. Another useful command is info: info l lists the currently loaded libraries; info f lists all referenced functions, with parenthesis for those not compiled yet; info b lists the builtin functions; and info v lists the variables with their type and size.