Skip to content

Commit

Permalink
Minor update to tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Mar 22, 2021
1 parent 4aed791 commit ce3eec4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions docs/tutorials/constructing_fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Constructing finite field arrays
GF(2) field class
-----------------

The :math:`GF(2)` field is already constructed in `galois`. It can be accessed by `galois.GF2`.
The :math:`\mathrm{GF}(2)` field is already constructed in `galois`. It can be accessed by :obj:`galois.GF2`.

.. ipython:: python
Expand All @@ -25,8 +25,8 @@ The :math:`GF(2)` field is already constructed in `galois`. It can be accessed b
GF(p) field classes
-------------------

:math:`GF(p)` fields, where :math:`p` is prime, can be constructed using the class factory
`galois.GF_factory(p, 1)`.
:math:`\mathrm{GF}(p)` fields, where :math:`p` is prime, can be constructed using the class factory
:obj:`galois.GF_factory`.

.. ipython:: python
Expand All @@ -46,8 +46,8 @@ GF(p) field classes
GF(2^m) field classes
---------------------

:math:`GF(2^m)` fields, where :math:`m` is a positive integer, can be constructed using the class
factory `galois.GF_factory(2, m)`.
:math:`\mathrm{GF}(2^m)` fields, where :math:`m` is a positive integer, can be constructed using the class
factory :obj:`galois.GF_factory`.

.. ipython:: python
Expand All @@ -71,7 +71,7 @@ Array creation, explicit and view casting
-----------------------------------------

Galois field arrays can be constructed either explicitly or through `numpy` view casting. The method of array
creation is the same for all Galois fields, but :math:`GF(7)` is used as an example here.
creation is the same for all Galois fields, but :math:`\mathrm{GF}(7)` is used as an example here.

.. ipython:: python
Expand All @@ -86,7 +86,7 @@ creation is the same for all Galois fields, but :math:`GF(7)` is used as an exam
.. warning::

View casting creates a pointer to the original data and simply interprets it as a new `np.ndarray` subclass,
View casting creates a pointer to the original data and simply interprets it as a new :obj:`numpy.ndarray` subclass,
namely the Galois field classes. So, if the original array is modified so will the Galois field array.

.. ipython:: python
Expand All @@ -106,4 +106,16 @@ creation is the same for all Galois fields, but :math:`GF(7)` is used as an exam
Galois field array dtypes
-------------------------

Galois field arrays support all integer dtypes, presuming the data type.
Galois field arrays support all signed and unsigned integer dtypes, presuming the data type can store values
in :math:`[0, p^m)`.

.. ipython:: python
GF = galois.GF_factory(7, 1)
a = GF.Random(10); a
# Type cast an existing Galois field array to a different dtype
a.astype(np.uint8)
# Explicitly create a Galois field array with a specific dtype
b = GF.Random(10, dtype=np.uint8); b

0 comments on commit ce3eec4

Please sign in to comment.