Matvec Users’ Guide
Matvec Users' Guide
Matvec Users' Guide
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 7<br />
User-Defined Function<br />
7.1 Syntax<br />
function obj.foo(args) { }<br />
function foo(args) { }<br />
protected function obj.foo(args) { }<br />
protected function foo(args) { }<br />
7.2 Description<br />
User-defined functions in <strong>Matvec</strong> can be constructed or defined) by the above four forms. The first form is<br />
so-called a user-defined member function with respect to object obj, whereas the second form is so-called a<br />
user-defined friend function. The third and fourth are the same as the first two except that functions are<br />
protected. In another word function definition in the last two forms can not be overwritten.<br />
Usually, the definition of a user-defined functions are stored in a disk file. Before calling them, we have<br />
to load them into the computer memory using the <strong>Matvec</strong> builtin function input:<br />
input("")<br />
User-defined functions in <strong>Matvec</strong> are treated as objects, in a manner similar to other objects such as<br />
Matrix, Vector. Thus, in principle, users can assign/copy them like ordinary variables, but users should<br />
avoid to use this feature.<br />
By default all variables within a function are global except those symbolic arguments in function header<br />
and those declared in local statements: local(A,B,C,...);<br />
Note that local statement can appear anywhere only within function definition, and multiple local statements<br />
are also allowed.<br />
Function execution will terminated right after return statement. the returning value of a function is the<br />
last expression evaluated in the function execution. The return statement in the function is optional.<br />
7.3 Scope<br />
7.4 Recursion<br />
not working yet so far.<br />
7.5 Examples<br />
protected function A.sign()<br />
45