GetYacasPID | obtain Yacas process number |
ShowPS | view equations graphically |
MakeFunctionPlugin | compile numerical functions into plugins |
Version | show version of Yacas |
Vi | edit a file or function |
PlatformOS, OSVersion, FilePathSeparator | OS-dependent constants |
CopyFile, DeleteFile, DeleteDir, MakeDir, MakeFilePath, TemporaryDir, TemporaryFile | manipulate files and directories |
SystemCallBg | execute a system command in the background |
GetYacasPID() |
Requires: a Unix shell.
In> GetYacasPID() Out> 26456; |
ShowPS(expr) |
Requires: a Unix shell, latex, dvips, gv or another Postscript viewer.
In> [ PSViewCommand := "ghostview"; \ ShowPS(x+2*Sin(x)); ] Expression exported as /tmp/yacas-tmp file-28802.tex Out> True; |
MakeFunctionPlugin("name", body) MakeFunctionPlugin() |
body -- expression, function of arguments, must evaluate to a function of some variables.
The second form of the function is a predicate that checks that the function plugin facility is supported. (It may not be available on all platforms.)
Requires: a Unix shell, a compiler named c++ with ELF .so support, Yacas headers in FindFile("")/include; current directory must be writable. Error messages will be printed otherwise.
The body expression must be a CForm()-exportable function of the arguments and may contain numerical constants. Pi is allowed and will be converted to floating-point.
All arguments and the return value of the function are assumed to be double precision real numbers. The result of passing a non-numerical argument will be an unevaluated expression.
The function creates the following files in subdirectory plugins.tmp/ of current directory:
double f1_plugin_cc(double x, double y) { return sin(x/y); } |
After creating these files, MakeFunctionPlugin() will:
If you call MakeFunctionPlugin() repeatedly to define a function with the same name, old files will be overwritten and old libraries will be unloaded with DllUnload().
If the numerical calculation does not return a number (for example, it might return the atom nan, "not a number", for some arguments), then the new function will return Undefined. This is the behavior of NFunction which is used to wrap the numerical routine.
In> MakeFunctionPlugin("f1", Sin(x/y)) Function f1(x,y) loaded from plugins.tmp/libf1_plugin_cc.so Out> True; In> f1(2,3) Out> 0.618369803069736989620253; In> f1(x,5) Out> f1(x,5); |
Version() |
In> Version() Out> "1.0.48rev3"; In> LessThan(Version(), "1.0.47") Out> False; In> GreaterThan(Version(), "1.0.47") Out> True; |
The last two calls show that the LessThan and GreaterThan functions can be used for comparing version numbers. This method is only guaranteed, however, if the version is always expressed in the form d.d.dd as above.
Vi(filename); Vi(functionname); |
functionname - name of a function to find for editing
It finds the function by scanning the *.def files that have been reported to the system. (Vi calls FindFunction for this.) If editing a function, the command will jump directly to the first occurrence of the name of the function in the file (usually the beginning of a definition of a function).
If you would like to use Vi() to actually edit the Yacas library source file where the function is defined, you need to start Yacas from the scripts/ directory in the development tree. In that case, FindFunction() will return the filename under that directory. Otherwise, FindFunction() will return a name in the systemwide installation directory (or directory specified in the --rootdir option).
In> Vi("yacasinit.ys") Out> True; In> Vi("Sum") Out> True; |
FilePathSeparator PlatformOS() OSVersion() |
The value of OSVersion() is normally determined when Yacas is compiled. It is usually the operating system name and version as reported by the config.guess script. However, it may be overridden at build time (on non-Unix systems, the script cannot be run and the value must be specified by hand).
The value of PlatformOS() is defined in the library (in osdep.rep/). Thus the library is able to override the platform-specific value. The scripts should use PlatformOS() to distinguish between broad classes of systems. The currently supported values are "Unix" and "Win32".
The constant FilePathSeparator is the string that separates directories in the file system tree. This is the forward slash "/" on Unix and the backslash "\" on Windows.
In> Check(StringMid(1, 5, OSVersion())="linux", \ "BAAA! I WANT LINUX!") Out> True; In> PlatformOS() Out> "Unix"; |
CopyFile("src","dest") DeleteFile("file", ...) DeleteDir("dir", ...) MakeDir("dir1", ...) MakeFilePath("dir1", "dir2", ..., "file") TemporaryDir() TemporaryFile() |
Absolute file paths or relative file paths can be given (the current directory is the directory where Yacas was started).
File and directory names may contain spaces, although the behavior on Windows platform may be incorrect due to its broken filesystem and command interpreter. File and directory names should not contain double quotes ("). (On Unix, double quotes may be escaped by a backslash.)
When operating on many files or directories at once, there may be errors associated with some files but not others. The functions return True only if all operations succeeded. Error messages from the OS are printed on the console as usual for SystemCall.
In> MakeFilePath("", "usr", "bin", "yacas") Out> "/usr/bin/yacas"; In> TemporaryDir() Out> "/tmp"; |
In> CopyFile("f1.txt", "f2.txt") Out> True; |
In> MakeDir(d:=MakeFilePath(TemporaryDir(), \ "subdir")) Out> True; In> d Out> "/tmp/subdir"; |
In> CopyFile("f2.txt", d) Out> True; |
In> MakeDir("a \\\"") Out> True; |
An unsuccessful attempt to delete a directory:
In> DeleteDir("C:\\WINDOWS") Out> False; |
SystemCallBg("command") |
Unlike the SystemCall function, the return status of the command is not available.
Error messages from the OS are printed on the console as usual for SystemCall.
In> SystemCallBg("mozilla") Out> True; |