diff options
| -rwxr-xr-x | challenge-246/wlmb/perl/ch-2b.pl | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/challenge-246/wlmb/perl/ch-2b.pl b/challenge-246/wlmb/perl/ch-2b.pl index d67c1daebf..ff706f1a4a 100755 --- a/challenge-246/wlmb/perl/ch-2b.pl +++ b/challenge-246/wlmb/perl/ch-2b.pl @@ -30,19 +30,7 @@ sub is_linear_2(@x){ } if($D->slice([1,0,0])->approx(0)){ # singular matrix return unless $V->slice([1,0,0])->inner($rhs)->approx(0); - my $coeff=$V->slice([0,0,0])->inner($rhs)/$D->slice([0,0,0]); - my $sol_K=$coeff*$V->slice([0,0,0]); - my $sol_A=$V->slice([1,0,0]); - my $q1=$sol_A->slice([1,0,0]); - # if($q1->approx(0)){...} # I believe it doesn't happenUnneeded - my $z0=-$sol_K->slice([1,0,0])/$q1; - my $dz=1/$sol_A->slice([1,0,0]); - my $sol_q0=$sol_K+$z0*$sol_A; - my $arbitrary_max_q=10; # try to find some integer solution - $_->approx($_->rint)->all && return $_ - for map {$sol_q0+$_*$sol_A} - sort {abs($a)<abs($b)||$a<$b} (-$arbitrary_max_q..$arbitrary_max_q); - return undef, 1; # Uncertain failure + return pdl(0, $x[1]/$x[0]); } my $d_inv=zeroes(2,2); # not singular $d_inv->diagonal(0,1).=1/$D; |
