Bernstein basis polynomials: Difference between revisions
Content added Content deleted
m (→{{header|ALGOL 68}}: Added note) |
(→{{header|ALGOL 68}}: Simplify a bit more) |
||
Line 435: | Line 435: | ||
OP TOSTRING = ( BERNTHREE p )STRING: |
OP TOSTRING = ( BERNTHREE p )STRING: |
||
"( " + f( b0 OF p ) + ", " + f( b1 OF p ) + ", " + f( b2 OF p ) + ", " + f( b3 OF p ) + " )"; |
"( " + 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: |
|||
⚫ | |||
STRING result := "(", separator := ""; |
|||
⚫ | |||
result +:= separator + " " + f( p[ i ] ); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
BERNTWO p2 := BERNTWO ( "p", 0, 0, 0 ); |
BERNTWO p2 := BERNTWO ( "p", 0, 0, 0 ); |
||
Line 450: | Line 460: | ||
tobern2( q0m, q1m, q2m, q2 ); |
tobern2( q0m, q1m, q2m, q2 ); |
||
print( ( "Subprogram (1) examples:", newline ) ); |
print( ( "Subprogram (1) examples:", newline ) ); |
||
print( ( " mono |
print( ( " mono ", TOSTRING []REAL( p0m, p1m, p2m ), " --> bern ", TOSTRING p2, newline ) ); |
||
, |
print( ( " mono ", TOSTRING []REAL( q0m, q1m, q2m ), " --> bern ", TOSTRING q2, newline ) ); |
||
⚫ | |||
); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
); |
|||
print( ( "Subprogram (2) examples:", newline ) ); |
print( ( "Subprogram (2) examples:", newline ) ); |
||
Line 469: | Line 473: | ||
tobern3( r0m, r1m, r2m, r3m, r3 ); |
tobern3( r0m, r1m, r2m, r3m, r3 ); |
||
print( ( "Subprogram (3) examples:", newline ) ); |
print( ( "Subprogram (3) examples:", newline ) ); |
||
print( ( " mono |
print( ( " mono ", TOSTRING []REAL( p0m, p1m, p2m, 0 ), " --> bern ", TOSTRING p3, newline ) ); |
||
, |
print( ( " mono ", TOSTRING []REAL( q0m, q1m, q2m, 0 ), " --> bern ", TOSTRING q3, newline ) ); |
||
⚫ | |||
⚫ | |||
); |
|||
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 ) ); |
print( ( "Subprogram (4) examples:", newline ) ); |