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.

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.

Using LyME

Launch LyME by tapping its icon.

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 bottom field.

To enter parenthesis or operators, you can also tap one of the symbols 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.

Programs

There are two kinds of programs in LyME: scripts and functions. Scripts are simply collections of statements, variable assignments and expressions 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 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 somewhere 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.

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 libraryname".

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 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.

User input

The best way to develop reusable code is to write functions with input and output arguments. Variables can be created in the context of the command line to pass values between different functions, and new values are entered directly in the command line, with access to the history of past commands, the list of functions, and buttons for common operators and symbols.

It may also be useful to prompt the user for more input in the middle of a computation. One mechanism can be used.

Standard input
General input functions such as fgets or fscanf can be used with the predefined file descripor 0. The user can enter data and click button "OK" to resume execution, or button "Cancel" to cancel it completely. In the example below, a single integer is requested (note that the default file descriptor for fscanf is 0).
n = fscanf('%d');

Data exchange

Libraries are synchronized during backup, but those deleted on the Palm device are currently preserved on the desktop computer.

To transfer a library to another Palm device, you can send it via infrared or Bluetooth. Select Send in the File menu, align your device to the destination device if you use infrared, and tap the library to be sent in the list, and select the transfer type if your device offers the choice. The receiving device will display a dialog box asking if the library should be accepted; if OK, the library will be stored in the LyME database.

Another way to exchange libraries with the outside is to convert it to or from a Memo Pad note. To export a library, edit it (Edit button), then select Export in the File menu; a new Memo Pad note is created. To import a library, create a new library (Edit button, then (New)), then select Import in the File menu and choose the first line of one of the Memo Pad notes; its entire contents will be inserted in the library.

At a lower level, serialdevopen, in addition to the physical serial ports whose list can be obtained with serialdevname, accepts the four-character codes of virtual serial drivers recognized by the Palm OS function SrmOpen. Two codes are documented: 'ircm' for infrared, and 'rfcm' for Bluetooth in client mode. To open a Bluetooth connection, for instance, you can use the code below. serialdevopen will let the user pick a Bluetooth device from a list.

try
  fd = serialdevopen('rfcm');
  // functions like fread/fwrite/fprintf/fscanf/fgets
  fclose(fd);
catch
  // Bluetooth not supported or user cancel

License

LyME and its documentation: Copyright 1997-2006, Calerga. All rights reserved. LyME may not be redistributed without the prior written permission of Calerga.

The user assumes all the risks caused by the use of LyME and the results obtained with LyME. Under no circumstance will Calerga, its emplyees or resellers be responsible for any loss of money, time, data, goods, or lives.

What's more in Sysquake

While it is based on the same computation engine and language, Sysquake has a completely different graphical system, whose goal is nearly-instantaneous interactivity with the mouse. This interactivity opens a new dimension (effect of parametric variations, relationships between different figures, etc.) and permits the user to get an intuitive understanding of his/her problems and to solve them more efficiently. Sysquake also has file support, extensions, large high-quality numerical libraries, a user interface which supports many more options, print support, and a lot of other features.

LyME runs on much slower hardware (typically 1000 times slower); it is useful for small-to-medium-size problems and is located somewhere between high-end scientific calculators and desktop numeric software such as Matlab, with which it is largely compatible.

For more information about Sysquake and LyME, please visit http://www.calerga.com.

MathLib

MathLib is a free shared library that can be used by any OS 2.0+ Pilot program that needs IEEE 754 double precision math functions. It is distributed under the terms of the GNU Library General Public License, and is freely available with full source code and documentation at the MathLib Information web page. It is not a part of the LyME program, and you're not paying anything for its use; a copy is simply included in this archive for your convenience. Thanks, Rick!


Copyright 1998-2006, Calerga.
All rights reserved.