home *** CD-ROM | disk | FTP | other *** search
- UNIT ExternalFunction;
- {Note: Creating plug-in functions for the non-FPU version is possible, but not that helpful}
- {The overhead of SANE outweighs the overhead of the function interpreter, whereas with}
- {the FPU, the overhead of the function interpreter slows the application down considerably }
- {from optimum speed.}
-
- {For other language platforms: Your code must be stored un a file of type 'Plug' with creator}
- {'GrFP'. The actual code must be stored in a resource of type 'Func'. You must use the }
- {FPU, since the program uses the FPU extended format. Your code must accept a message }
- {integer and a variable info pointer. It should not ever allocate memory for the pointer. }
- {It should return an extended type (96 bits) as it's result. The messages are fairly self }
- {explanatory. Variables are passed each time in the Info pointer, and the numbers are stored as }
- {pointers to extended type. X is the main variable and P is a variable parameter (used, for}
- {example in the bifurcation plot) . For operations requiring a number of iterations, an integer N }
- {is passed}
-
- INTERFACE
-
- CONST
- GetName = -1;
- {Return the nameof the function in Info^ as you want it to appear in the menu}
- {Assume the space has been allocated}
- InitFunc = 0;
- {Return the default parameters, bounds in the form of Initrec.)}
- {Assume the space has been allocated}
- ReturnFunc = 1;
- {return the flat out first iterate of your function}
- ReturnNthX = 2;
- {return the Nth iterate with respect to x of your function}
- {YOU MUST RESTORE the value of X^ to its original value}
- ReturnNthP = 3;
- {Not used}
- Return1DerivX = 4;
- {return the real first derivative of x}
- Return2DerivX = 5;{Not used - maybe in the future}
- Return3DerivX = 6;{Not used}
- return4DerivX = 7;{Not used}
- Return1DerivP = 8;{Not used}
- Return2DerivP = 9;{Not used}
- Return3DerivP = 10;{Not used}
- return4DerivP = 11;{Not used}
- ReturnIntegralX = 12;{Not used}
- ReturnIntegralP = 13;{Not used}
-
- TYPE
- NumberPtr = ^NumberType;
- NumberType = extended;
-
- NamePtr = ^Str255;
-
- InitPtr = ^InitRec;
- InitRec = RECORD
- Xmin, XMax, FXmin, FXmax, PMin, PMax: NumberType;
- InitialX, InitialX0, InitialP: NumberType;
- END;
-
- DoFuncPtr = ^DoFuncRec;
- DoFuncRec = RECORD
- X, P: NumberPtr;
- N: Integer;
- END;
-
-
- FUNCTION Main (message: integer; VAR Info: ptr): NumberType;
-
- IMPLEMENTATION
-
- FUNCTION Main (message: integer; VAR Info: ptr): NumberType;
- VAR
- result, XHold: extended;
- i: integer;
- BEGIN
- WITH DoFuncPtr(Info)^ DO
- CASE message OF
-
- GetName:
- NamePtr(info)^ := 'p*x*(1-x)';
-
-
- ReturnFunc:
- {*****************INSERT FUNCTION HERE*********************}
- result := p^ * x^ * (1 - x^);
- {******************************************************}
-
- ReturnNthX:
- BEGIN
- XHold := X^;
- FOR I := 1 TO N DO
- {*****************INSERT FUNCTION HERE*********************}
- X^ := p^ * x^ * (1 - x^);
- {******************************************************}
- Result := X^;
- X^ := XHold;
- END;
-
- Return1DerivX:
- {*****************INSERT DERIVATIVE HERE*********************}
- result := p^ - 2 * p^ * x^;
- {******************************************************}
-
- InitFunc:
- WITH initptr(Info)^ DO
- BEGIN
- XMin := 0;
- XMax := 1;
- FXMin := 0;
- FXMax := 1;
- PMin := 0;
- PMax := 4;
- InitialX := 0.5;
- InitialX0 := 0.5;
- initialP := 3.839;
- result := 0;
- END;
-
- OTHERWISE
- info := NIL;
- END;
-
- Main := Result;
- END;
-
- END.