Bernstein basis polynomials: Difference between revisions
→{{header|ALGOL 68}}: Simplify a bit more
(→{{header|ALGOL 68}}: Simplify a little using features of Algol 68 not in Algol 60) |
(→{{header|ALGOL 68}}: Simplify a bit more) |
||
Line 391:
# coefficients q0, q1, q2 to the cubic Bernstein #
# coefficients c0, c1, c2, c3; #
BEGIN
BEGIN
Line 426 ⟶ 428:
OP SHOWEVAL = ( BERNTHREE p, REAL x )VOID:
print( ( " ", label OF p, " ( ", f( x ), " ) = ", f( p EVAL x ), newline ) );
# returns a string representation of the values of p #
OP TOSTRING = ( BERNTWO p )STRING:
# returns a string representation of the values of p #
OP TOSTRING = ( BERNTHREE p )STRING:
BERNTWO p2 := BERNTWO ( "p", 0, 0, 0 );
BERNTWO q2 := BERNTWO ( "q", 0, 0, 0 );
Line 433 ⟶ 441:
BERNTHREE q3 := BERNTHREE( "q", 0, 0, 0, 0 );
BERNTHREE r3 := BERNTHREE( "r", 0, 0, 0, 0 );
REAL p0m = 1, p1m = 0, p2m = 0;
Line 445 ⟶ 450:
print( ( "Subprogram (1) examples:", newline ) );
print( ( " mono ( ", f( p0m ), ", ", f( p1m ), ", ", f( p2m )
, " ) --> bern
)
);
print( ( " mono ( ", f( q0m ), ", ", f( q1m ), ", ", f( q2m )
, " ) --> bern
)
);
Line 465 ⟶ 468:
tobern3( r0m, r1m, r2m, r3m, r3 );
print( ( "Subprogram (3) examples:", newline ) );
print( ( " mono ( ",
, " ) --> bern
)
);
print( ( " mono ( ",
, " ) --> bern
)
);
print( ( " mono ( ", f( r0m ), ", ", f( r1m ), ", ", f( r2m ), ", ", f( r3m )
, " ) --> bern
)
);
Line 489:
r3 SHOWEVAL 7.50;
print( ( "Subprogram (5) examples:", newline ) );
print( ( " bern
print( ( " bern ", TOSTRING q2, "
▲ );
▲ print( ( " bern ( ", f( b0 OF q2 ), ", ", f( b1 OF q2 ), ", ", f( b2 OF q2 )
▲ , " ) --> bern ( ", f( qc0 ), ", ", f( qc1 ), ", ", f( qc2 ), ", ", f( qc3 )
▲ )
END
|