EXAMPLES.SPL

 

SPL functions as discussed in the SPL: DADiSP's Series Processing Language manual. The file contains the following functions:

 

CELSIUS(F)

Converts Fahrenheit to Centigrade

FUN1(X)

Example of local variable

FUN2(X)

Setting global variable in a function

ISEVEN(X)

Returns 1 if number is even, else 0

ISODD(X)

Returns 1 if number is odd, else 0

SGN(N)

Returns the sign of a number. 1 = positive, 0 = zero, -1 = negative

REPLACE(S, COND, VAL)

replace the values of a series based on a logical condition

DRANGE(S)

Return the data range of the input series

LARGER(A, B)

Return the larger of two numbers

SRT(NUM)

Square root by Newton's approximation, accurate to about 5 decimal places

POWER(X, N)

Raise X to the N-th power for N > 0

SHELLSORT(S)

sort series S into ascending order

POS2(A)

Double positive values of a series only

DEMEAN1(S)

Slow way to remove the mean

DEMEAN2(S)

Much faster and simpler de-mean algorithm

REPLACEWITH1(S, T, V)

Replace elements > T with V

REPLACEWITH2(S, T, V)

Fast replace using a binary series

OUTLIER(S, COND)

Outlier linear interpolation replacement

FIB(X)

Fibonacci numbers returned as a series

FIB2(N)

Another example of creating Fibonacci numbers

DOUBLE1(X)

Call by value rule

DOUBLE2(X)

Exception to call by value

DOUBLE3(X)

Does not alter input series

FAC(X)

Factorial function

FEVAL(F, VAL)

Evaluates a function F at value VAL, i.e. returns Y = F(VAL). Function F must be passed in as a string, e.g. FEVAL("SIN", PI/2) returns: 1.0

FROOT(F, A, B, EPS,M)

Find root of function F over interval A, B

P(X)

5th root polynomial test for FROOT()

FUNC1(X, Y)

Optional argument example

OPTFUN(A, B)

Defaulting an optional argument

MYFUN(X, A)

Example of avoiding macro conflicts