Scilab Library

genlib

     
     

build library from functions in given directory

Calling Sequence

genlib(lib_name [[,dir_name, [ Force [,verb [,Names]]]])
genlib(lib_name [,path=dir_name] [,verbose=verb] [,force=Force] [,names=Names])

Arguments

lib_name:

Scilab string. The variable name of the library to (re)create.

dir_name:

Scilab string. The name of the directory to look for .sci-files.

Force

boolean value (default value is %f). Set it to %t to force the sci-files recompilation.

verb

boolean values (default value is %f). Set it to %t to get information.

Names

a vector of strings, the names of function to include in the library. By default all the sci-files are taken into account

Description

For each .sci file in dir_name (or only those specified by the Names argument), genlib executes a exec and saves the functions to the corresponding .bin file. The .sci file must not contain anything but Scilab functions. If a .bin file is newer than the associated .sci file, genlib does not translate and save the file.

This default behaviour can be changed if force is given and set to %t. In this latter case the recompilation is always performed for each .sci file.

When all .sci files have been processed, genlib creates a library variable named lib_name and saves it in the file lib in dir_name. If the Scilab variable lib_name is not protected (see predef) this variable is updated.

If verbose is et to %t information are displayed during the build process.

If dir_name argument is not given and if lib_name Scilab variable exists and it is a library dir_name is taken equal to the lib_name library path (update mode).

Restrictions

Scilab tacitly assumes that file foo.sci defines at least a function named foo. If subsidiary functions are included, they are made known to Scilab only after the function foo had been referenced.

 

lib

library definition

Calling Sequence

namelib = lib('lib-dir')

Arguments

lib-dir

character string

namelib

library variable returned by 'lib'.

Description

lib-dir is a character string defining a directory that contains compiled Scilab function (.bin) files.

In addition to these files lib-dir must have a file called names, that contains the names of the functions defined in lib-dir. On success, all functions in lib-dir are available from within Scilab. They are loaded on demand when called for the first time.

Binary files can be created from within Scilab with the command save. A library variable usually is saved for later loading, either on-line or from the user-specific startup file (see startup).

value returned by 'lib' must be insert in a variable 'namelib' to access to macro functions of this library.

Restrictions

Scilab tacitly assumes that each xxxx.bin file defines a variable named xxxx.

 

Examples

//define some functions
function z=myplus(x, y)
  z = x + y
endfunction

function z=yourplus(x, y)
  x = x - y
endfunction

//create the *.bin files in libdir
libdir = TMPDIR;
save(libdir + '/myplus.bin', myplus);
save(libdir + '/yourplus.bin', yourplus);

//create the name file
mputl(['myplus';'yourplus'],TMPDIR+'/names');

//build the library containing myplus and yourplus
mylibfoo = lib(libdir+'/');

//erase the variables
clear myplus yourplus

//Automatic loading and execution
myplus(1,2)

//erase the variables
clear myplus yourplus

mylibfoo
[n,p] = libraryinfo('mylibfoo')

isdef('myplus')
clear mylibfoo
isdef('myplus')


         
         

           
           

library

library datatype description

Calling Sequence

Description

A library is a data type with type number 14. It contains a path-name and a set of names. It allows automatic loading of variables using the following algorithm:

Suppose the Scilab user references the variable named foo. Scilab first looks if foo is the name of a primitive or of an already defined variable. If not, it looks for foo sequentially (the newest first) in all defined library .

Suppose foo belongs to the set of names of the library xlib then Scilab tries to load the file <xlib-path-name>/foo.bin. <xlib-path-name>/foo.bin must have been created using the save function

Library are often used for collection of functions, but they can also be used for any collection of scilab variables

If a function is defined in more than one library, the default search algorithm loads thode contained in the newest. It possible to force the use of a specific library using dot notation:

xlib.foo loads the variable foo contained in xlib. if foo is a function and xlib.foo(args) executes the functions

Examples

// elemlib is a predefined library
elementary_functionlib //displays the contents of the library
A=rand(3,3);
cosm(A) //loads cosm and executes it
whos -name cosm // now cosm is a variable
elementary_functionlib.sinm //loads sinm from the library
elementary_functionlib.cosm(A) //reloads cosm and executes it


            
            
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值