09 Jul 2012 09:36:44 UTC
- Distribution: Algorithm-GaussianElimination-GF2
- Module version: 0.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (461 / 0 / 0)
- KwaliteeBus factor: 1
- 60.69% Coverage
- License: unknown
- Activity24 month
- Download (4.13KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionSALVA Salvador Fandiño García
- SEE ALSO
- COPYRIGHT AND LICENSE
Algorithm::GaussianElimination::GF2 - Solve linear systems of equations on GF(2)
use Algorithm::GaussianElimination::GF2; my $age = Algorithm::GaussianElimination::GF2->new; $age->new_equation(1, 0, 0, 1 => 1); $age->new_equation(0, 0, 1, 1 => 0); my ($sol, @base0) = $age->solve; # or you can also create the equations setting elements at given # positions: my $age = Algorithm::GaussianElimination::GF2->new; my $eq1 = $age->new_equation; $eq1->a(0, 1); $eq1->a(3, 1); $eq1->b(1); my $eq2 = $age->new_equation; $eq2->a(2, 1); $eq2->a(3, 1); $eq2->b(0); my ($sol, @base0) = $age->solve;
This module implements a variation of the Gaussian Elimination algorithm that allows to solve systems of linear equations over GF(2).
Those are the interesting methods:
- $age = Algorithm::GaussianElimination::GF2->new;
- $eq = $age->new_equation(@a, $b)
- $eq = $age->new_equation()
Creates and adds a new equation to the algorithm.
The returned value is a reference to the equation object that can be used to change the equation coeficients before calling the
- ($sol, @base0) = $age->solve
- $sol = $age->solve
This method solves the system of equations.
When the system is inconsistent it returns an empty list.
When the system is consistent and uniquely determined it returns the solution as an array reference.
When the system is consistent and underdetermined it returns one solution as an array reference and a base of the vector space formed by the solutions of the homogeneous system. In scalar context, only the solution vector is returned.
Those are the methods available to manipulate the equation objects:
- $a = $eq->a($ix)
- $eq->a($ix, $a)
Retrieves or sets the value of the equation coeficient at the given index.
- $b = $eq->b
Retrieves or sets the value of the constant term of the equation.
Returns the internal length of the coeficients vector.
Note that this value is just a hint as the internal representation grows transparently when new coeficients are set or inside the
The Wikipedia page about systems of linear equations: http://en.wikipedia.org/wiki/System_of_linear_equations.
The Wikipedia page about the Galois Field of two elements GF(2): http://en.wikipedia.org/wiki/GF%282%29.
The Wikipedia page about the Gaussian Elimination algorithm: http://en.wikipedia.org/wiki/Gaussian_elimination.
The inception of this module lays on this PerlMonks post: http://perlmonks.org/?node_id=940327.
Math::FastGF2 implements a much richer and faster set of operations for GF(2).
Copyright (C) 2011, 2012 by Salvador Fandiño (firstname.lastname@example.org)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
Module Install Instructions
To install Algorithm::GaussianElimination::GF2, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Algorithm::GaussianElimination::GF2
For more information on module installation, please visit the detailed CPAN module installation guide.