- NAME
- SYNOPSIS
- DESCRIPTION
- OPERATORS
- METHODS
- BUGS AND LIMITATIONS
- SEE ALSO
- AUTHOR
- COPYRIGHT AND LICENSE

# NAME

Math::GF::Extension - Elements for arithmetics over extensions of Zn

# SYNOPSIS

```
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;
```

# DESCRIPTION

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).

# OPERATORS

This module overrides some arithmetic and comparison operators, namely:

```
+ - * / **
== != eq
```

Additionally, the stringification operator `""`

is overloaded too.

# METHODS

In the following, `$e`

is supposed to be a `Math::GF::Extension`

object.

**assert_compatibility**

` my $n = $e->assert_compatibility($other_element);`

Assert the compatibility of this object `$e`

with `$other_element`

. It is defined as follows:

`$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. it shares the same "p" and "n".

Throws an error if the conditions are not met.

Returns the *order* (as "p" elevated to "n", always a true value in Perl) if successful, a false value otherwise.

**divided_by**

` my $d = $e->divided_by($other_element);`

Evaluate `$e`

divided by `$other_element`

. Calls "assert_compatibility". Used in the implementation of the `/`

overloaded operator.

**equal_to**

` 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.

**field**

` my $field = $e->field;`

Accessor for the field where this element belongs.

**i**

` my $i = $e->i;`

The *reference value* for the multiplicative inverse of this object.

**inv**

` my $inv = $e->inv;`

A `Math::GF::Extension`

element belonging to the same "field" that is the multiplicative inverse of this object.

**minus**

` my $difference = $e->minus($other_element);`

Evaluate difference of `$e`

and `$other_element`

. Calls "assert_compatibility". Used in the implementation of the `-`

overloaded operator.

**n**

` my $n = $e->n;`

Power of the prime for the extension field. Same as `$e->field->n`

.

**not_equal_to**

` 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.

**o**

` my $i = $e->o;`

The *reference value* for the additive inverse (opposite) of this object.

**opp**

` my $opp = $e->opp;`

A `Math::GF::Extension`

element belonging to the same "field" that is the additive inverse of this object.

**p**

` my $p = $e->p;`

Prime integer at the base of the extension field. Same as `$e->field->p`

.

**plus**

` my $sum = $e->plus($other_element);`

Evaluate sum of `$e`

and `$other_element`

. Calls "assert_compatibility". Used in the implementation of the `+`

overloaded operator.

**stringify**

` my $string = $e->stringify;`

Get a string representation of the object. It does just return "v". Used in the implementation of the `""`

overloaded operator.

**times**

` my $prod = $e->times($other_element);`

Evaluate product of `$e`

and `$other_element`

. Calls "assert_compatibility". Used in the implementation of the `*`

overloaded operator.

**to_power**

` my $pow = $e->to_power($exp);`

Evaluate the power of `$e`

to `$exp`

. Used in the implementation of the `**`

overloaded operator.

**v**

` 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).

# BUGS AND LIMITATIONS

Report bugs through GitHub (patches welcome).

# SEE ALSO

# AUTHOR

Flavio Poletti <polettix@cpan.org>

# COPYRIGHT AND LICENSE

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.