Algorithm-GaussianElimination-GF2
view release on metacpan or search on metacpan
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
package Algorithm::GaussianElimination::GF2;
our $VERSION = '0.02';
use strict;
use warnings;
sub new {
my $class = shift;
my $self = { eqs => [] };
bless $self, $class;
}
sub _add_equation {
my ($self, $eq) = @_;
push @{$self->{eqs}}, $eq;
}
sub new_equation {
my $self = shift;
my $eq = Algorithm::GaussianElimination::GF2::Equation->_new(@_);
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
push @base0, \@sol0;
}
return \@sol, @base0;
}
package Algorithm::GaussianElimination::GF2::Equation;
sub _new {
my $class = shift;
my $self = ['', 0, 0];
bless $self, $class;
if (@_) {
$self->[1] = (pop @_ ? 1 : 0);
for my $ix (0..$#_) {
vec($self->[0], $ix, 1) = $_[$ix]
}
$self->[2] = @_;
}
$self
}
lib/Algorithm/GaussianElimination/GF2.pm view on Meta::CPAN
my $b = 0;
for my $ix (0..$#_) {
$b ^= vec($v, $ix, 1) if $_[$ix];
}
return ($b == $self->[1]);
}
sub clone {
my $self = shift;
my @self = @$self;
bless \@self, ref $self;
}
1;
__END__
=head1 NAME
Algorithm::GaussianElimination::GF2 - Solve linear systems of equations on GF(2)
=head1 SYNOPSIS
( run in 0.622 second using v1.01-cache-2.11-cpan-de7293f3b23 )