Elliptic curve arithmetic: Difference between revisions

m
→‎{{header|Perl}}: clarify package vs local variables, output fixes
m (→‎{{header|REXX}}: changed whitespace, optimized some functions, indented the output, used a template for the output section.)
m (→‎{{header|Perl}}: clarify package vs local variables, output fixes)
Line 873:
{{trans|C}}
<lang perl>package EC;
our ($a, $b) = (0, 7);
{
our ($aA, $bB) = (0, 7);
package EC::Point;
sub new { my $class = shift; bless [ @_ ], $class }
Line 906:
 
package Test;
my $ap = +EC::Point->new(-($EC::bB - 1)**(1/3), 1);
my $bq = +EC::Point->new(-($EC::bB - 4)**(1/3), 2);
print my $cs = $ap + $bq, "\n";
print "$_\n" for $ap, $bq, $cs;
print "check alignementalignment... ";
print abs(($bq->x - $ap->x)*(-$cs->y - $ap->y) - ($bq->y - $ap->y)*($cs->x - $ap->x)) < 0.001
? "ok" : "wrong";</lang>
</lang>
{{out}}
<pre>EC-point at x=-1.817121, y=1.000000
EC-point at x=-1.442250, y=2.000000
EC-point at x=10.375375, y=-33.524509
check alignementalignment... ok
</pre>
 
2,392

edits