funcs.pl

filter: Statementstmt 71.4% 35 / 49 Branchbran 40.9% 9 / 22 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 63.8% 53 / 83 CC 14 SCAR 27.5
CC
14
Cov
63%
_debug_info
42.0
ok_eigenvectors
5.2
similar
3.0
CRAP 15.6
« blib/lib/Math/MatrixReal.pm ↑ Summary
1 56 $DEBUG = 0;
2 56 my $eps = 1e-8;
3 ######### help funcs
4 sub ok_matrix ($$$)
5 69 ▶{
Subroutine ok_matrix: called CC=2 SCAR=7.0
6 69 my ($a, $b, $msg) = @_;
7 69 my $res = abs($a-$b);
8 69 ok( similar($a,$b) , $msg);
9 69 ▶ print " (|Delta| = $res)\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 69 69
10 }
11 sub ok_matrix_orthogonal ($)
12 7 ▶{
Subroutine ok_matrix_orthogonal: called CC=2 SCAR=6.9
13 7 my ($M) = @_;
14 7 my $tmp = $M->shadow();
15 7 $tmp->one();
16 7 my $transp = $M->shadow();
17 7 $transp->transpose($M);
18 7 $tmp->subtract($M->multiply($transp), $tmp);
19 7 my $v = $tmp->norm_one();
20 7 ok(($v < $eps), 'matrix is orthogonal');
21 7 ▶ print " (|M * ~M - I| = $v)\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG 0 7 7
22 }
23 sub ok_eigenvectors ($$$;$)
24 7 ▶{
Subroutine ok_eigenvectors: called CC=5 SCAR=16.4
25 7 my ($M, $L, $V, $msg) = @_;
26 7 ▶ $msg ||= 'eigenvectors computed correctly';
Condition50%1/2
$msg ||= "eigenvectors computed correctly"
l!l
07
MC/DC0%0/1
$msg ||= "eigenvectors computed correctly"
$msg
Truth table50%1/2
A
A= $msg
Aresult
11
00
27 # Now check that all of them correspond to eigenvalue * eigenvector
28 7 my ($rows, $columns) = $M->dim();
29 7 ▶ unless ($rows == $columns) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rows == $columns) 0 7 7
30 0 ok(0,'matrix should be square to compute eigenvalues');
31 0 return;
32 }
33 # Computes the result of all eigenvectors...
34 7 my $test = $M * $V;
35 7 my $test2 = $V->clone();
36 7 ▶ for (my $i = 1; $i <= $columns; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $columns) 105 7 112
37 {
38 105 my $lambda = $L->element($i,1);
39 105 ▶ for (my $j = 1; $j <= $rows; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $rows) 2541 105 2646
40 { # Compute new vector via lambda * x
41 2541 $test2->assign($j, $i, $lambda * $test2->element($j, $i));
42 }
43 }
44 7 ok_matrix($test,$test2, $msg );
45 7 return;
46 }
47 108 ▶sub similar($$;$) {
Subroutine similar: called CC=3 SCAR=11.0
48 108 my ($x,$y, $eps) = @_;
49 108 ▶ $eps ||= 1e-8;
Condition100%2/2
$eps ||= "1e-08"
l!l
1494
MC/DC100%1/1
$eps ||= "1e-08"
$eps
Truth table100%2/2
A
A= $eps
Aresult
11
00
50 108 ▶ abs($x-$y) < $eps ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
abs $x - $y < $eps ? : 104 4 108
51 }
52  
53 sub _debug_info
54 0 ▶{
Subroutine _debug_info: not called CC=6 SCAR=37.4
55 0 my($text,$object,$argument,$flag) = @_;
56  
57 0 ▶ unless (defined $object) { $object = 'undef'; };
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $object) 0 0 0
58 0 ▶ unless (defined $argument) { $argument = 'undef'; };
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argument) 0 0 0
59 0 ▶ unless (defined $flag) { $flag = 'undef'; };
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $flag) 0 0 0
60 0 ▶ if (ref($object)) { $object = ref($object); }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $object) 0 0 0
61 0 ▶ if (ref($argument)) { $argument = ref($argument); }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argument) 0 0 0
62 0 print "$text: \$obj='$object' \$arg='$argument' \$flag='$flag'\n";
63 }
64  
65 sub assert_dies($;$)
66 13 ▶{
Subroutine assert_dies: called CC=1 SCAR=0.0
67 13 my ($code,$msg) = @_;
68 13 eval { &$code };
69 13 ok($@, $msg);
70 }
71  
72 56 1;
« blib/lib/Math/MatrixReal.pm ↑ Summary