Bernstein basis polynomials: Difference between revisions

→‎{{header|ALGOL 68}}: Simplify a bit more
(→‎{{header|ALGOL 68}}: Simplify a bit more)
Line 435:
OP TOSTRING = ( BERNTHREE p )STRING:
"( " + f( b0 OF p ) + ", " + f( b1 OF p ) + ", " + f( b2 OF p ) + ", " + f( b3 OF p ) + " )";
# returns a string representation of the values of p #
OP TOSTRING = ( []REAL p )STRING:
)BEGIN
STRING result := "(", separator := "";
, "FOR )i -->FROM bernLWB ",p TOSTRINGTO q2,UPB newlinep DO
result +:= separator + " " + f( p[ i ] );
) separator := ","
) OD;
result + " )"
END # )TOSTRING # ;
 
BERNTWO p2 := BERNTWO ( "p", 0, 0, 0 );
Line 450 ⟶ 460:
tobern2( q0m, q1m, q2m, q2 );
print( ( "Subprogram (1) examples:", newline ) );
print( ( " mono ( ", TOSTRING f[]REAL( p0m, p1m, p2m ), ", ",--> f( p1m ),bern ", "TOSTRING p2, f( p2mnewline ) );
print( ( " mono ", TOSTRING []REAL( q0m, "q1m, q2m ), " --> bern ", TOSTRING p2q2, newline ) );
)
);
print( ( " mono ( ", f( q0m ), ", ", f( q1m ), ", ", f( q2m )
, " ) --> bern ", TOSTRING q2, newline
)
);
 
print( ( "Subprogram (2) examples:", newline ) );
Line 469 ⟶ 473:
tobern3( r0m, r1m, r2m, r3m, r3 );
print( ( "Subprogram (3) examples:", newline ) );
print( ( " mono ( ", fTOSTRING []REAL( p0m ), "p1m, "p2m, f(0 p1m ), ", ",--> f(bern p2m )", ",TOSTRING "p3, f(newline 0) );
print( ( " mono ", TOSTRING []REAL( q0m, "q1m, q2m, 0 ), " --> bern ", TOSTRING p3q3, newline ) );
print( ( " mono ( ", TOSTRING f[]REAL( q0m )r0m, "r1m, "r2m, f( q1m r3m ), ", --> bern ", f(TOSTRING r3, q2mnewline ) );
)
);
print( ( " mono ( ", f( q0m ), ", ", f( q1m ), ", ", f( q2m ), ", ", f( 0 )
, " ) --> bern ", TOSTRING q3, newline
)
);
print( ( " mono ( ", f( r0m ), ", ", f( r1m ), ", ", f( r2m ), ", ", f( r3m )
, " ) --> bern ", TOSTRING r3, newline
)
);
 
print( ( "Subprogram (4) examples:", newline ) );
3,021

edits