# gfmul

Multiply elements of Galois field

## Syntax

``c = gfmul(a,b)``
``c = gfmul(a,b,p)``
``c = gfmul(a,b,field)``

## Description

````c = gfmul(a,b)` returns the Galois field resulting from element-by-element multiplication of input Galois fields `a` and `b`. Each entry of `a` and `b` is an element in GF(2). For more information, see Galois Field Entries.```

example

````c = gfmul(a,b,p)` returns the Galois field resulting from element-by-element multiplication of input Galois fields `a` and `b` in GF(`p`), where `p` is a prime number. For more information, see Galois Field Entries.```
````c = gfmul(a,b,field)` returns the Galois field resulting from element-by-element multiplication of input Galois fields `a` and `b` in GF(`p`m), where `p` is a prime number and m is a positive integer. For more information, see Galois Field Entries.```

## Examples

collapse all

Use `gfmul` to multiply powers of a primitive polynomial root. If$\mathit{A}$ is a root of the primitive polynomial $2+2\mathit{x}+{\mathit{x}}^{2}$ for `gf``(9)`, then ${\mathit{A}}^{2}\cdot {\mathit{A}}^{4}={\mathit{A}}^{6}$.

```p = 3; m = 2; prim_poly = [2 2 1]; field = gftuple([-1:p^m-2]',prim_poly,p); a = gfmul(2,4,field)```
```a = 6 ```

## Input Arguments

collapse all

Galois field, specified as a scalar, vector, or matrix.

Galois field, specified as a scalar, vector, or matrix. `a` and `b` must be the same size.

Prime number, specified as a scalar. Each entry in `a` and `b` represents an element of GF(`p`). The entries of `a` and `b` are integers in the range [0, (`p` – 1)].

List of all elements in GF(`p`m), specified as a matrix arranged relative to the same primitive element. `a` and `b` must be the same size.

Example: To generate a list of all elements in GF(`p`m), use `gftuple([-1:(p^m) - 2]',m,p);`, where `p` is a prime number and m is a positive integer.

## Output Arguments

collapse all

Galois field, returned as a scalar, vector, or matrix. `c` is the exponential format of the product, relative to the same primitive element. For more information, see Galois Field Entries.

collapse all

### Galois Field Entries

When each entry of `a` and `b` is an element in a Galois field of degree:

• GF(2) — `a` and `b` are matrices of the same size and contain values `0` or `1`.

• GF(`p`) — Each entry of `a` and `b` is in the range [0, (`p` – 1)].

• GF(`p`m) in exponential format — Each entry `a` and `b` is an integer in the range [–∞, `p`m – 2].

For more information on Galois formats, see Representing Elements of Galois Fields.

## Tips

• This function multiplies elements of a Galois field.

• To multiply polynomials over a Galois field, use `gfconv` instead.

• This function performs computations in GF(`p`m), where `p` is prime.

• To work in GF(2m), you can also apply the `.*` operator to Galois arrays. For more information, see Example: Multiplication.

## Version History

Introduced before R2006a