home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-08 | 1.2 KB | 40 lines | [TEXT/RLAB] |
- local
-
- Syntax: local ( VAR1 , VAR2 , VAR3, ... )
-
- Description:
-
- The local statement forces a function to resolve specified
- variable reference within the function itself. Each local
- variable is initialized UNDEFINED, and is destroyed after
- execution leaves the function. Each time execution enters the
- function, the local variables are re-initialized.
-
- Declaring argument variables local copies the value of the
- argument variable into the local variable of the same
- name. The argument variable is not accessible while function
- is executing. In essence, this procedure forces arguments to
- be passed by value.
-
- For example:
-
- mgs = function(A)
- {
- local (A)
- m = A.nr; n = A.nc;
- for(k in 1:n)
- {
- r[k;k] = norm( A[1:m;k], "2");
- q[1:m;k] = A[1:m;k]/r[k;k];
- for(j in k+1:n)
- {
- r[k;j] = q[1:m;k]' * A[1:m;j];
- A[1:m;j] = A[1:m;j] - q[1:m;k] * r[k;j];
- }
- }
- return << q = q; r = r >>;
- };
-
-
- The function `mgs' uses the local statement to forces
- pass-by-va