Debian Codegraph @

t/perl_vs_xs.t

raw symbols SCIP
1 #!/usr/bin/perl
2
3 use Test::More tests => 261;
4
5 use strict;
6 use warnings;
7
8 BEGIN { $Math::Vector::Real::dont_use_XS = 1 }
9 use Math::Vector::Real;
10
11 BEGIN {
12 for (qw(box
13 sum
14 dist2_to_box
15 max_dist2_to_box
16 max_dist2_between_boxes)) {
17 eval "package Math::Vector::Real; *pp_$_ = \\&$_";
18 is ($@, '', "installing pp doesn't fail for $_");
19 }
20 }
21
22 use Math::Vector::Real::XS;
23 use Math::Vector::Real::Test qw(eq_vector eq_vector_norm);
24
25 for my $dim (1, 2, 3, 10) {
26 for my $n (1, 2, 4, 8, 16, 32, 64, 128) {
27
28 my $o = V(map rand(), 1..$dim);
29 my @v = map V(map rand(), 1..$dim), 1..$n;
30 eq_vector(Math::Vector::Real->sum(@v),
31 Math::Vector::Real->pp_sum(@v),
32 "sum dim: $dim, n: $n");
33
34 eq_vector($o->sum(@v),
35 $o->pp_sum(@v),
36 "v->sum dim: $dim, n: $n");
37
38 for my $c (0..1) {
39 eq_vector((Math::Vector::Real->box(@v))[$c],
40 (Math::Vector::Real->pp_box(@v))[$c],
41 "box dim: $dim, n: $n, c: $c");
42
43 eq_vector(($o->box(@v))[$c],
44 ($o->pp_box(@v))[$c],
45 "v->box dim: $dim, n: $n, c: $c");
46 }
47
48 eq_vector([$o->dist2_to_box(@v)],
49 [$o->pp_dist2_to_box(@v)],
50 "v->dist2_to_box dim: $dim, n: $n");
51
52 eq_vector([$o->max_dist2_to_box(@v)],
53 [$o->pp_max_dist2_to_box(@v)],
54 "v->max_dist2_to_box dim: $dim, n: $n");
55 }
56 }
57