26 lines
603 B
Plaintext
26 lines
603 B
Plaintext
%begin
|
|
%external %real %fn %spec sqrt %alias "sqrtf" (%real n) {should be in prims. Using Linux/C's external here.}
|
|
|
|
%routine TPK(%real %array %name a, b)
|
|
! given 11 input values a(0),...,a(10), this routine
|
|
! produces 22 output values b(0),...b(21), according
|
|
! to the classical TPK algorithm
|
|
%real %fn f(%real t)
|
|
%result = sqrt(|t|) + 5 * t^3
|
|
%end
|
|
%real y
|
|
%integer i
|
|
%cycle i = 10, -1, 0
|
|
y = f(a(i))
|
|
y = 999 %if y > 400
|
|
b(20-2*i) = i
|
|
b(21-2*i) = y
|
|
%repeat
|
|
%end; ! TPK
|
|
|
|
%real %array a(0:10), b(0:21)
|
|
|
|
TPK(a,b)
|
|
|
|
%endofprogram
|