line |
!l |
l&&!r |
l&&r |
condition |
59
|
0 |
124 |
14 |
ref $matrix eq 'ARRAY' and not @$matrix |
64
|
0 |
0 |
124 |
ref $matrix eq 'ARRAY' and ref $matrix->[0] eq 'ARRAY' |
692
|
0 |
0 |
2 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
728
|
0 |
0 |
2 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
754
|
0 |
0 |
0 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
780
|
0 |
0 |
0 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
806
|
0 |
0 |
0 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
840
|
0 |
0 |
2 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
874
|
0 |
0 |
2 |
$rows == $m2->{'rows'} and $cols == $m2->{'cols'} |
954
|
2 |
14 |
10 |
$_ != $t and $_ < 0 |
972
|
2 |
2 |
4 |
$_ != $t and $_ > 0 |
1010
|
4 |
0 |
2 |
$neg and $pow == 1 |
line |
l |
!l&&r |
!l&&!r |
condition |
68
|
14 |
123 |
1 |
$rows //= $#{$matrix;} |
69
|
14 |
120 |
4 |
$cols //= $#{$$matrix[0];} |
115
|
0 |
0 |
0 |
$col_count //= $row_count |
410
|
2 |
20 |
0 |
$self->{'_decomposition'} //= $self->_LUP_decomposition |
417
|
0 |
2 |
0 |
$self->{'_rref'} //= do {
my(@m) = map({[@$_];} @{$$self{'matrix'};});
return 'Math::MatrixLUP'->new([]) unless @m;
my($j, $rows, $cols) = (0, $self->{'rows'} + 1, $self->{'cols'} + 1);
OUTER: foreach my $r (0 .. $rows - 1) {
last unless $j < $cols;
my $i = $r;
while ($m[$i][$j] == 0) {
next unless ++$i == $rows;
$i = $r;
last OUTER if ++$j == $cols;
};
@m[$i, $r] = @m[$r, $i];
my $mr = $m[$r];
my $mrj = $mr->[$j];
foreach my $k (0 .. $cols - 1) {
$mr->[$k] /= $mrj;
};
foreach my $i (0 .. $rows - 1) {
next if $i == $r;
my $mr = $m[$r];
my $mi = $m[$i];
my $mij = $m[$i][$j];
foreach my $k (0 .. $cols - 1) {
$mi->[$k] -= $mij * $mr->[$k];
};
};
++$j;
};
'Math::MatrixLUP'->new(\@m)
} |
1076
|
4 |
3 |
0 |
$self->{'_inverse'} //= do {
my($N, $A, $P) = $self->decompose;
my @I;
foreach my $j (0 .. $N) {
foreach my $i (0 .. $N) {
$I[$i][$j] = $P->[$i] == $j ? 1 : 0;
foreach my $k (0 .. $i - 1) {
$I[$i][$j] -= $A->[$i][$k] * $I[$k][$j];
};
};
for (my $i = $N; $i >= 0; --$i) {
foreach my $k ($i + 1 .. $N) {
$I[$i][$j] -= $A->[$i][$k] * $I[$k][$j];
};
$I[$i][$j] /= $A->[$i][$i] // (return 'Math::MatrixLUP'->new([]));
};
};
'Math::MatrixLUP'->new(\@I)
} |
1112
|
0 |
17 |
1 |
$self->{'_determinant'} //= do {
my($N, $A, $P) = $self->decompose;
my $det = $A->[0][0] // (return 1);
foreach my $i (1 .. $N) {
$det *= $A->[$i][$i];
};
if (($$P[$N + 1] - $N) % 2 == 0) {
$det *= -1;
};
$det
} |
1134
|
5 |
8 |
0 |
$self->{'_stringification'} //= "[\n " . join(",\n ", map({'[' . join(', ', @$_) . ']';} @{$$self{'matrix'};})) . "\n]" |