Skip to content

Commit

Permalink
Convert from :math:... to $...$
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Aug 6, 2023
1 parent a39c7b4 commit 26e2f50
Show file tree
Hide file tree
Showing 35 changed files with 1,417 additions and 1,417 deletions.
16 changes: 8 additions & 8 deletions docs/basic-usage/array-arithmetic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Array Arithmetic
After creating a :obj:`~galois.FieldArray` subclass and one or two arrays, nearly any arithmetic operation can be
performed using normal NumPy ufuncs or Python operators.

In the sections below, the finite field :math:`\mathrm{GF}(3^5)` and arrays :math:`x` and :math:`y` are used.
In the sections below, the finite field $\mathrm{GF}(3^5)$ and arrays $x$ and $y$ are used.

.. ipython:: python
Expand Down Expand Up @@ -81,7 +81,7 @@ Expand any section for more details.
np.multiply(x, 4)
x + x + x + x

In finite fields :math:`\mathrm{GF}(p^m)`, the characteristic :math:`p` is the smallest value when multiplied by
In finite fields $\mathrm{GF}(p^m)$, the characteristic $p$ is the smallest value when multiplied by
any non-zero field element that results in 0.

.. ipython-with-reprs:: int,poly,power
Expand Down Expand Up @@ -168,7 +168,7 @@ Expand any section for more details.
.. example:: Logarithm: `np.log(x)` or `x.log()`
:collapsible:

Compute the logarithm base :math:`\alpha`, the primitive element of the field.
Compute the logarithm base $\alpha$, the primitive element of the field.

.. ipython-with-reprs:: int,poly,power

Expand All @@ -177,7 +177,7 @@ Expand any section for more details.
alpha = GF.primitive_element; alpha
alpha ** z == y

Compute the logarithm base :math:`\beta`, a different primitive element of the field. See :func:`FieldArray.log`
Compute the logarithm base $\beta$, a different primitive element of the field. See :func:`FieldArray.log`
for more details.

.. ipython-with-reprs:: int,poly,power
Expand Down Expand Up @@ -291,8 +291,8 @@ Advanced arithmetic
.. example:: FFT: `np.fft.fft(x)`
:collapsible:

The Discrete Fourier Transform (DFT) of size :math:`n` over the finite field :math:`\mathrm{GF}(p^m)` exists when
there exists a primitive :math:`n`-th root of unity. This occurs when :math:`n\ |\ p^m - 1`.
The Discrete Fourier Transform (DFT) of size $n$ over the finite field $\mathrm{GF}(p^m)$ exists when
there exists a primitive $n$-th root of unity. This occurs when $n\ |\ p^m - 1$.
.. ipython-with-reprs:: int,poly,power

Expand All @@ -309,8 +309,8 @@ Advanced arithmetic
.. example:: Inverse FFT: `np.fft.ifft(X)`
:collapsible:

The inverse Discrete Fourier Transform (DFT) of size :math:`n` over the finite field :math:`\mathrm{GF}(p^m)`
exists when there exists a primitive :math:`n`-th root of unity. This occurs when :math:`n\ |\ p^m - 1`.
The inverse Discrete Fourier Transform (DFT) of size $n$ over the finite field $\mathrm{GF}(p^m)$
exists when there exists a primitive $n$-th root of unity. This occurs when $n\ |\ p^m - 1$.
.. ipython-with-reprs:: int,poly,power

Expand Down
14 changes: 7 additions & 7 deletions docs/basic-usage/array-classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The :obj:`galois` library subclasses :obj:`~numpy.ndarray` to provide arithmetic

The main abstract base class is :obj:`~galois.Array`. It has two abstract subclasses: :obj:`~galois.FieldArray` and
:obj:`~galois.RingArray` (future). None of these abstract classes may be instantiated directly. Instead, specific
subclasses for :math:`\mathrm{GF}(p^m)` and :math:`\mathrm{GR}(p^e, m)` are created at runtime with :func:`~galois.GF`
subclasses for $\mathrm{GF}(p^m)$ and $\mathrm{GR}(p^e, m)$ are created at runtime with :func:`~galois.GF`
and :func:`~galois.GR` (future).

:obj:`~galois.FieldArray` subclasses
Expand All @@ -26,7 +26,7 @@ A :obj:`~galois.FieldArray` subclass is created using the class factory function
:collapsible:

For very large finite fields, the :obj:`~galois.FieldArray` subclass creation time can be reduced by explicitly specifying
:math:`p` and :math:`m`. This eliminates the need to factor the order :math:`p^m`.
$p$ and $m$. This eliminates the need to factor the order $p^m$.

.. ipython:: python
Expand All @@ -35,7 +35,7 @@ A :obj:`~galois.FieldArray` subclass is created using the class factory function
Furthermore, if you already know the desired irreducible polynomial is irreducible and the primitive element is a generator of
the multiplicative group, you can specify `verify=False` to skip the verification step. This eliminates the need to factor
:math:`p^m - 1`.
$p^m - 1$.

.. ipython:: python
Expand All @@ -57,16 +57,16 @@ Class singletons

:obj:`~galois.FieldArray` subclasses of the same type (order, irreducible polynomial, and primitive element) are singletons.

Here is the creation (twice) of the field :math:`\mathrm{GF}(3^5)` defined with the default irreducible
polynomial :math:`x^5 + 2x + 1`. They *are* the same class (a singleton), not just equivalent classes.
Here is the creation (twice) of the field $\mathrm{GF}(3^5)$ defined with the default irreducible
polynomial $x^5 + 2x + 1$. They *are* the same class (a singleton), not just equivalent classes.

.. ipython:: python
galois.GF(3**5) is galois.GF(3**5)
The expense of class creation is incurred only once. So, subsequent calls of `galois.GF(3**5)` are extremely inexpensive.

However, the field :math:`\mathrm{GF}(3^5)` defined with irreducible polynomial :math:`x^5 + x^2 + x + 2`, while isomorphic to the
However, the field $\mathrm{GF}(3^5)$ defined with irreducible polynomial $x^5 + x^2 + x + 2$, while isomorphic to the
first field, has different arithmetic. As such, :func:`~galois.GF` returns a unique :obj:`~galois.FieldArray` subclass.

.. ipython:: python
Expand All @@ -76,7 +76,7 @@ first field, has different arithmetic. As such, :func:`~galois.GF` returns a uni
Methods and properties
......................

All of the methods and properties related to :math:`\mathrm{GF}(p^m)`, not one of its arrays, are documented as class methods
All of the methods and properties related to $\mathrm{GF}(p^m)$, not one of its arrays, are documented as class methods
and class properties in :obj:`~galois.FieldArray`. For example, the irreducible polynomial of the finite field is accessed
with :obj:`~galois.FieldArray.irreducible_poly`.

Expand Down
16 changes: 8 additions & 8 deletions docs/basic-usage/array-creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Array Creation
==============

This page discusses the multiple ways to create arrays over finite fields. For this discussion, we are working in
the finite field :math:`\mathrm{GF}(3^5)`.
the finite field $\mathrm{GF}(3^5)$.

.. ipython-with-reprs:: int,poly,power

Expand Down Expand Up @@ -41,15 +41,15 @@ A finite field array may also be created by exponentiating the primitive element
Polynomial coefficients
.......................

Rather than strings, the polynomial coefficients may be passed into `GF`'s constructor as length-:math:`m` vectors using
Rather than strings, the polynomial coefficients may be passed into `GF`'s constructor as length-$m$ vectors using
the :func:`~galois.FieldArray.Vector` classmethod.

.. ipython-with-reprs:: int,poly,power

GF.Vector([[0, 0, 1, 2, 2], [0, 0, 0, 1, 1]])

The :func:`~galois.FieldArray.vector` method is the opposite operation. It converts extension field elements from :math:`\mathrm{GF}(p^m)`
into length-:math:`m` vectors over :math:`\mathrm{GF}(p)`.
The :func:`~galois.FieldArray.vector` method is the opposite operation. It converts extension field elements from $\mathrm{GF}(p^m)$
into length-$m$ vectors over $\mathrm{GF}(p)$.

.. ipython-with-reprs:: int,poly,power

Expand Down Expand Up @@ -104,7 +104,7 @@ useful for initializing empty arrays.
:title: There is no :func:`numpy.empty` equivalent.
:collapsible:

This is because :obj:`~galois.FieldArray` instances must have values in :math:`[0, p^m)`. Empty NumPy arrays have whatever values
This is because :obj:`~galois.FieldArray` instances must have values in $[0, p^m)$. Empty NumPy arrays have whatever values
are currently in memory, and therefore would fail those bounds checks during instantiation.

Ordered arrays
Expand Down Expand Up @@ -153,22 +153,22 @@ able to store all the field elements (in their :ref:`integer representation <int
Valid data types
................

For small finite fields, like :math:`\mathrm{GF}(2^4)`, every NumPy integer data type is supported.
For small finite fields, like $\mathrm{GF}(2^4)$, every NumPy integer data type is supported.

.. ipython:: python
GF = galois.GF(2**4)
GF.dtypes
For medium finite fields, like :math:`\mathrm{GF}(2^{10})`, some NumPy integer data types are not supported. Here,
For medium finite fields, like $\mathrm{GF}(2^{10})$, some NumPy integer data types are not supported. Here,
:obj:`numpy.uint8` and :obj:`numpy.int8` are not supported.

.. ipython:: python
GF = galois.GF(2**10)
GF.dtypes
For large finite fields, like :math:`\mathrm{GF}(2^{100})`, only the "object" data type (:obj:`numpy.object_`) is
For large finite fields, like $\mathrm{GF}(2^{100})$, only the "object" data type (:obj:`numpy.object_`) is
supported. This uses arrays of Python objects, rather than integer data types. The Python objects used are Python integers,
which have unlimited size.

Expand Down
8 changes: 4 additions & 4 deletions docs/basic-usage/compilation-modes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ to speed up arithmetic computations. These tables are built once at :obj:`~galoi
during the call to :func:`~galois.GF`.

The exponential and logarithm lookup tables map every finite field element to a power of the primitive element
:math:`\alpha`.
$\alpha$.

.. math::
x = \alpha^i
Expand Down Expand Up @@ -64,7 +64,7 @@ integer subtraction.
&= \alpha^m \alpha^{Z(n - m)} \\
&= \alpha^{m + Z(n - m)}
Finite fields with order less than :math:`2^{20}` use lookup tables by default. In the limited cases where explicit calculation
Finite fields with order less than $2^{20}$ use lookup tables by default. In the limited cases where explicit calculation
is faster than table lookup, the explicit calculation is used.

.. ipython:: python
Expand All @@ -77,7 +77,7 @@ is faster than table lookup, the explicit calculation is used.
Explicit calculation
--------------------

Finite fields with order greater than :math:`2^{20}` use explicit calculation by default. This eliminates the need to store large lookup
Finite fields with order greater than $2^{20}$ use explicit calculation by default. This eliminates the need to store large lookup
tables. However, explicit calculation is usually slower than table lookup.

.. ipython:: python
Expand Down Expand Up @@ -118,7 +118,7 @@ Recompile the ufuncs
The compilation mode may be explicitly set during creation of the :obj:`~galois.FieldArray` subclass using the
`compile` keyword argument to :func:`~galois.GF`.

Here, the :obj:`~galois.FieldArray` subclass for :math:`\mathrm{GF}(3^5)` would normally select `"jit-lookup"` as its
Here, the :obj:`~galois.FieldArray` subclass for $\mathrm{GF}(3^5)$ would normally select `"jit-lookup"` as its
default compilation mode. However, we can intentionally choose explicit calculation.

.. ipython:: python
Expand Down
28 changes: 14 additions & 14 deletions docs/basic-usage/element-representation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Element Representation
The representation of finite field elements can be set to either their integer (`"int"`), polynomial (`"poly"`),
or power (`"power"`) representation.

In prime fields :math:`\mathrm{GF}(p)`, elements are integers in :math:`\{0, 1, \dots, p-1\}`. Their two useful representations
In prime fields $\mathrm{GF}(p)$, elements are integers in $\{0, 1, \dots, p-1\}$. Their two useful representations
are the integer and power representation.

In extension fields :math:`\mathrm{GF}(p^m)`, elements are polynomials over :math:`\mathrm{GF}(p)` with degree less than :math:`m`.
In extension fields $\mathrm{GF}(p^m)$, elements are polynomials over $\mathrm{GF}(p)$ with degree less than $m$.
All element representations are useful. The polynomial representation allows *proper* representation of the element as a polynomial
over its prime subfield. However, the integer representation is more compact for displaying large arrays.

Expand Down Expand Up @@ -58,17 +58,17 @@ The element representation can be permanently changed using the :func:`~galois.F
Integer representation
----------------------

The integer representation (the default) displays all finite field elements as integers in :math:`\{0, 1, \dots, p^m-1\}`.
The integer representation (the default) displays all finite field elements as integers in $\{0, 1, \dots, p^m-1\}$.

In prime fields, the integer representation is simply the integer element in :math:`\{0, 1, \dots, p-1\}`.
In prime fields, the integer representation is simply the integer element in $\{0, 1, \dots, p-1\}$.

.. ipython:: python
GF = galois.GF(31)
GF(11)
In extension fields, the integer representation converts and element's degree-:math:`m-1` polynomial over :math:`\mathrm{GF}(p)` into
its integer equivalent. The integer equivalent of a polynomial is a radix-:math:`p` integer of its coefficients, with the highest-degree
In extension fields, the integer representation converts and element's degree-$m-1$ polynomial over $\mathrm{GF}(p)$ into
its integer equivalent. The integer equivalent of a polynomial is a radix-$p$ integer of its coefficients, with the highest-degree
coefficient as the most-significant digit and zero-degree coefficient as the least-significant digit.

.. ipython:: python
Expand All @@ -84,9 +84,9 @@ coefficient as the most-significant digit and zero-degree coefficient as the lea
Polynomial representation
-------------------------

The polynomial representation displays all finite field elements as polynomials over their prime subfield with degree less than :math:`m`.
The polynomial representation displays all finite field elements as polynomials over their prime subfield with degree less than $m$.

In prime fields :math:`m = 1`, therefore the polynomial representation is equivalent to the integer representation because the
In prime fields $m = 1$, therefore the polynomial representation is equivalent to the integer representation because the
polynomials all have degree 0.

.. ipython:: python
Expand Down Expand Up @@ -116,7 +116,7 @@ This is useful, however it can become cluttered for large arrays.
Power representation
--------------------

The power representation displays all finite field elements as powers of the field's primitive element :math:`\alpha`.
The power representation displays all finite field elements as powers of the field's primitive element $\alpha$.

.. slow-performance::

Expand All @@ -125,7 +125,7 @@ The power representation displays all finite field elements as powers of the fie
take a while. However, when using :ref:`lookup tables <lookup-tables>` this representation is just as fast as
the others.

In prime fields, the elements are displayed as :math:`\{0, 1, \alpha, \alpha^2, \dots, \alpha^{p-2}\}`.
In prime fields, the elements are displayed as $\{0, 1, \alpha, \alpha^2, \dots, \alpha^{p-2}\}$.

.. ipython:: python
Expand All @@ -138,7 +138,7 @@ In prime fields, the elements are displayed as :math:`\{0, 1, \alpha, \alpha^2,
alpha = GF.primitive_element; alpha
alpha ** 23
In extension fields, the elements are displayed as :math:`\{0, 1, \alpha, \alpha^2, \dots, \alpha^{p^m-2}\}`.
In extension fields, the elements are displayed as $\{0, 1, \alpha, \alpha^2, \dots, \alpha^{p^m-2}\}$.

.. ipython:: python
Expand All @@ -165,8 +165,8 @@ The vector representation is accessed using the :func:`~galois.FieldArray.vector
GF("x^2 + 2x + 2")
GF("x^2 + 2x + 2").vector()
An N-D array over :math:`\mathrm{GF}(p^m)` is converted to a (N + 1)-D array over :math:`\mathrm{GF}(p)` with the added dimension having
size :math:`m`. The first value of the vector is the highest-degree coefficient.
An N-D array over $\mathrm{GF}(p^m)$ is converted to a (N + 1)-D array over $\mathrm{GF}(p)$ with the added dimension having
size $m$. The first value of the vector is the highest-degree coefficient.

.. ipython:: python
Expand All @@ -188,7 +188,7 @@ NumPy displays arrays with a default line width of 75 characters. This is proble
for arrays using the polynomial representation, where each element occupies a lot of space. This can be changed by modifying
NumPy's print options.

For example, below is a :math:`5 \times 5` matrix over :math:`\mathrm{GF}(3^5)` displayed in the polynomial representation.
For example, below is a $5 \times 5$ matrix over $\mathrm{GF}(3^5)$ displayed in the polynomial representation.
With the default line width, the array is quite difficult to read.

.. ipython:: python
Expand Down
8 changes: 4 additions & 4 deletions docs/basic-usage/poly-arithmetic.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Polynomial Arithmetic
=====================

In the sections below, the finite field :math:`\mathrm{GF}(7)` and polynomials :math:`f(x)` and :math:`g(x)` are used.
In the sections below, the finite field $\mathrm{GF}(7)$ and polynomials $f(x)$ and $g(x)$ are used.

.. ipython:: python
Expand Down Expand Up @@ -95,7 +95,7 @@ performed using Python operators. Expand any section for more details.
f * 4
f + f + f + f
In finite fields :math:`\mathrm{GF}(p^m)`, the characteristic :math:`p` is the smallest value when multiplied by
In finite fields $\mathrm{GF}(p^m)$, the characteristic $p$ is the smallest value when multiplied by
any non-zero field element that always results in 0.

.. ipython:: python
Expand Down Expand Up @@ -220,7 +220,7 @@ Polynomial objects may also be evaluated at scalars, arrays, or square matrices.
:collapsible:

Polynomials can also be evaluated at square matrices. Note, this is different than element-wise array evaluation. Here,
the square matrix indeterminate is exponentiated using matrix multiplication. So :math:`f(x) = x^3` evaluated
the square matrix indeterminate is exponentiated using matrix multiplication. So $f(x) = x^3$ evaluated
at the square matrix `X` equals `X @ X @ X`.

.. ipython:: python
Expand All @@ -234,7 +234,7 @@ Polynomial objects may also be evaluated at scalars, arrays, or square matrices.
.. example:: Composition: `f(g)`
:collapsible:

Polynomial composition :math:`f(g(x))` is easily performed using an overload to :func:`~galois.Poly.__call__`.
Polynomial composition $f(g(x))$ is easily performed using an overload to :func:`~galois.Poly.__call__`.

.. ipython:: python
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Create a :obj:`~galois.FieldArray` subclass
-------------------------------------------

Next, create a :obj:`~galois.FieldArray` subclass for the specific finite field you'd like to work in. This is created using
the :func:`~galois.GF` class factory. In this example, we are working in :math:`\mathrm{GF}(3^5)`.
the :func:`~galois.GF` class factory. In this example, we are working in $\mathrm{GF}(3^5)$.

.. ipython:: python
GF = galois.GF(3**5)
print(GF.properties)
The :obj:`~galois.FieldArray` subclass `GF` is a subclass of :obj:`~numpy.ndarray` that performs all arithmetic in the Galois field
:math:`\mathrm{GF}(3^5)`, not in :math:`\mathbb{R}`.
$\mathrm{GF}(3^5)$, not in $\mathbb{R}$.

.. ipython:: python
Expand Down Expand Up @@ -105,7 +105,7 @@ Standard element-wise array arithmetic -- addition, subtraction, multiplication,
x * y
x / y
More complicated arithmetic, like square root and logarithm base :math:`\alpha`, are also supported.
More complicated arithmetic, like square root and logarithm base $\alpha$, are also supported.

.. ipython:: python
Expand Down
Loading

0 comments on commit 26e2f50

Please sign in to comment.