Main
Home
Quick tour
Documentation
Mailing Lists
Demonstration
Download
Sourceforge project
FAQ
History
Links


Toolboxes
Char
Control
Crypto
Finance
FunFun
General
Graphics
Image
Internal
InputOutput
LinearAlgebra
Matrix
Miscellaneous
Net
Polynomial
Set
Signal
SpecFun
SpecialMatrix
Statistics
String
System
Time
Trigonometric
...


Contact
Developers

JMathLib
A Java Clone of Octave, SciLab, Freemat and Matlab.

[Index] [Documentation] [Demonstration] [Download]

Chapter 19. Extending MathLib

Table of Contents

m Files
External Functions

There are two ways to add add extra functions to the MathLib. These are:

1) m files

2) External Functions

m Files

M files are script files written in the MathLib language.

  
function A = perms (v)
  v = v(:);
  n = length (v);
  if (n == 1)
    A = v;
  else
    B = perms (v(1:n-1));
    Bidx = 1:size (B, 1);
    A = v(n) * ones (prod (2:n), n);
    A(Bidx,1:n-1) = B;
    k = size (B, 1);
    for x = n-1:-1:2
      A(k+Bidx,1:x-1) = B(Bidx,1:x-1);
      A(k+Bidx,x+1:n) = B(Bidx,x:n-1);
      k = k + size (B, 1);
    endfor
    A(k+Bidx,2:n) = B;
  endif
endfunction

Last modified
SourceForge Logo