Math::GF::Extension - Elements for arithmetics over extensions of Zn
use Math::GF; my $field = Math::GF->new(order => 8); # one is-a Math::GF::Extension because 8 is 2 elevated to 3 my $one = $field->multiplicative_neutral;
This module implements elements and operations over a Galois Field based on powers of a prime (where the power is greater than 1). You are not supposed to generate instances of this class directly, but only through Math::GF (see "SYNOPSIS" above for an example).
This module overrides some arithmetic and comparison operators, namely:
+ - * / ** == != eq
Additionally, the stringification operator "" is overloaded too.
""
In the following, $e is supposed to be a Math::GF::Extension object.
$e
Math::GF::Extension
my $n = $e->assert_compatibility($other_element);
Assert the compatibility of this object $e with $other_element. It is defined as follows:
$other_element
$other_element is-a Math::GF::Extension
$other_element is based on the same field, i.e. it has the same order as $e, i.e. the same "p" and "n".
Throws an error if the conditions are not met.
Returns the order (always a true value in Perl) if successful, a false value otherwise.
my $d = $e->divided_by($other_element);
Evaluate $e divided by $other_element. Calls "assert_compatibility". Used in the implementation of the / overloaded operator.
/
my $bool = $e->equal_to($other_element);
Asses equality of $e and $other_element. Calls "assert_compatibility". Used in the implementation of the == and eq overloaded operators.
==
eq
my $field = $e->field;
Accessor for the field where this element belongs.
my $i = $e->i;
The reference value for the multiplicative inverse of this object.
my $inv = $e->inv;
A Math::GF::Extension element belonging to the same "field" that is the multiplicative inverse of this object.
my $difference = $e->minus($other_element);
Evaluate difference of $e and $other_element. Calls "assert_compatibility". Used in the implementation of the - overloaded operator.
-
my $n = $e->n;
Power of the prime for the extension field. Same as $e->field->n.
$e->field->n
my $bool = $e->not_equal_to($other_element);
Asses disequality of $e and $other_element. Calls "assert_compatibility". Used in the implementation of the != overloaded operator.
!=
my $i = $e->o;
The reference value for the additive inverse (opposite) of this object.
my $opp = $e->opp;
A Math::GF::Extension element belonging to the same "field" that is the additive inverse of this object.
my $p = $e->p;
Prime integer at the base of the extension field. Same as $e->field->p.
$e->field->p
my $sum = $e->plus($other_element);
Evaluate sum of $e and $other_element. Calls "assert_compatibility". Used in the implementation of the + overloaded operator.
+
my $string = $e->stringify;
Get a string representation of the object. It does just return "v". Used in the implementation of the "" overloaded operator.
my $prod = $e->times($other_element);
Evaluate product of $e and $other_element. Calls "assert_compatibility". Used in the implementation of the * overloaded operator.
*
my $pow = $e->to_power($exp);
Evaluate the power of $e to $exp. Used in the implementation of the ** overloaded operator.
$exp
**
my $v = $e->v;
A reference integer value for this object, comprised between 0 and one less than the order (i.e. "p" elevated to "n"). This value can not be used directly for modulo operations (this does not work in extension fields).
0
Report bugs either through RT or GitHub (patches welcome).
Foo::Bar.
Flavio Poletti <polettix@cpan.org>
Copyright (C) 2017, 2018 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Math::GF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::GF
CPAN shell
perl -MCPAN -e shell install Math::GF
For more information on module installation, please visit the detailed CPAN module installation guide.