Geometric algebra: Difference between revisions

Content added Content deleted
(→‎{{header|Raku}}: modernize)
(→‎{{header|raku}}: minor simplification)
Line 2,095: Line 2,095:
}
}


sub infix:<·>(Vector $x, Vector $y) returns Real is export { (($x*$y + $y*$x)/2){0} }
multi infix:<+>(::?CLASS $A, ::?CLASS $B) returns ::?CLASS is export {
multi infix:<+>(::?CLASS $A, ::?CLASS $B) returns ::?CLASS is export {
return ::?CLASS.new-from-pairs: |$A.pairs, |$B.pairs;
return ::?CLASS.new-from-pairs: |$A.pairs, |$B.pairs;
Line 2,158: Line 2,160:
constant N = 10;
constant N = 10;
plan 5;
plan 5;
sub infix:<·>(Vector $x, Vector $y) { ($x*$y + $y*$x)/2 }
subtest "Orthonormality", {
subtest "Orthonormality", {
Line 2,175: Line 2,175:
my @coeff = (.5 - rand) xx 5;
my @coeff = (.5 - rand) xx 5;
my $v = [+] @coeff Z* @e[^5];
my $v = [+] @coeff Z* @e[^5];
ok ($v**2).narrow ~~ Real, 'contraction';
ok ($v**2).narrow ~~ Real, 'contraction';</syntaxhighlight>
</syntaxhighlight>


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==