Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix <details> sections in docs #424

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion docs/basic-usage/array-arithmetic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ This extensibility enables `NumPy broadcasting <https://numpy.org/doc/stable/use
Expand any section for more details.

.. details:: Addition: `x + y == np.add(x, y)`
:class: example
:open:

.. ipython:: python

x + y
np.add(x, y)

.. details:: Additive inverse: `-x == np.negative(x)`
:class: example

.. ipython:: python

Expand All @@ -42,20 +45,23 @@ Expand any section for more details.
x + np.negative(x)

.. details:: Subtraction: `x - y == np.subtract(x, y)`
:class: example

.. ipython:: python

x - y
np.subtract(x, y)

.. details:: Multiplication: `x * y == np.multiply(x, y)`
:class: example

.. ipython:: python

x * y
np.multiply(x, y)

.. details:: Scalar multiplication: `x * z == np.multiply(x, z)`
:class: example

Scalar multiplication is essentially *repeated addition*. It is the "multiplication" of finite field elements
and integers. The integer value indicates how many additions of the field element to sum.
Expand All @@ -75,6 +81,7 @@ Expand any section for more details.
x * p

.. details:: Multiplicative inverse: `y ** -1 == np.reciprocal(y)`
:class: example

.. ipython:: python

Expand All @@ -89,6 +96,7 @@ Expand any section for more details.
y * np.reciprocal(y)

.. details:: Division: `x / y == x // y == np.divide(x, y)`
:class: example

.. ipython:: python

Expand All @@ -97,17 +105,19 @@ Expand any section for more details.
np.divide(x, y)

.. details:: Remainder: `x % y == np.remainder(x, y)`
:class: example

.. ipython:: python

x % y
np.remainder(x, y)

.. details:: Divmod: `divmod(x, y) == np.divmod(x, y)`
:class: example

.. ipython:: python

x / y, x % y
x // y, x % y
divmod(x, y)
np.divmod(x, y)

Expand All @@ -117,6 +127,7 @@ Expand any section for more details.
q*y + r == x

.. details:: Exponentiation: `x ** z == np.power(x, z)`
:class: example

.. ipython:: python

Expand All @@ -125,6 +136,7 @@ Expand any section for more details.
x * x * x

.. details:: Square root: `np.sqrt(x)`
:class: example

.. ipython:: python

Expand All @@ -135,6 +147,7 @@ Expand any section for more details.
See also :func:`~galois.FieldArray.is_square`, :func:`~galois.FieldArray.squares`, and :func:`~galois.FieldArray.non_squares`.

.. details:: Logarithm: `np.log(x)` or `x.log()`
:class: example

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

Expand Down Expand Up @@ -162,6 +175,8 @@ a user to apply a NumPy ufunc in a unique way across the target array. All arith
Expand any section for more details.

.. details:: `reduce()`
:class: example
:open:

The :obj:`~numpy.ufunc.reduce` methods reduce the input array's dimension by one, applying the ufunc across one axis.

Expand All @@ -176,6 +191,7 @@ Expand any section for more details.
x[0] * x[1] * x[2] * x[3]

.. details:: `accumulate()`
:class: example

The :obj:`~numpy.ufunc.accumulate` methods accumulate the result of the ufunc across a specified axis.

Expand All @@ -190,6 +206,7 @@ Expand any section for more details.
GF([x[0], x[0] * x[1], x[0] * x[1] * x[2], x[0] * x[1] * x[2] * x[3]])

.. details:: `reduceat()`
:class: example

The :obj:`~numpy.ufunc.reduceat` methods reduces the input array's dimension by one, applying the ufunc across one axis
in-between certain indices.
Expand All @@ -205,6 +222,7 @@ Expand any section for more details.
GF([x[0] * x[1] * x[2], x[3]])

.. details:: `outer()`
:class: example

The :obj:`~numpy.ufunc.outer` methods applies the ufunc to each pair of inputs.

Expand All @@ -217,6 +235,7 @@ Expand any section for more details.
np.multiply.outer(x, y)

.. details:: `at()`
:class: example

The :obj:`~numpy.ufunc.at` methods performs the ufunc in-place at the specified indices.

Expand All @@ -233,12 +252,15 @@ Advanced arithmetic
-------------------

.. details:: Convolution: `np.convolve(x, y)`
:class: example
:open:

.. ipython:: python

np.convolve(x, y)

.. details:: FFT: `np.fft.fft(x)`
:class: example

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`.
Expand All @@ -256,6 +278,7 @@ Advanced arithmetic
See also :func:`~galois.ntt` and :obj:`~galois.FieldArray.primitive_root_of_unity`.

.. details:: Inverse FFT: `np.fft.ifft(X)`
:class: example

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`.
Expand All @@ -281,6 +304,8 @@ in :obj:`numpy.linalg` and additional linear algebra routines not included in Nu
Expand any section for more details.

.. details:: Dot product: `np.dot(a, b)`
:class: example
:open:

.. ipython:: python

Expand All @@ -290,6 +315,7 @@ Expand any section for more details.
np.dot(a, b)

.. details:: Vector dot product: `np.vdot(a, b)`
:class: example

.. ipython:: python

Expand All @@ -299,6 +325,7 @@ Expand any section for more details.
np.vdot(a, b)

.. details:: Inner product: `np.inner(a, b)`
:class: example

.. ipython:: python

Expand All @@ -308,6 +335,7 @@ Expand any section for more details.
np.inner(a, b)

.. details:: Outer product: `np.outer(a, b)`
:class: example

.. ipython:: python

Expand All @@ -317,6 +345,7 @@ Expand any section for more details.
np.outer(a, b)

.. details:: Matrix multiplication: `A @ B == np.matmul(A, B)`
:class: example

.. ipython:: python

Expand All @@ -327,6 +356,7 @@ Expand any section for more details.
np.matmul(A, B)

.. details:: Matrix exponentiation: `np.linalg.matrix_power(A, z)`
:class: example

.. ipython:: python

Expand All @@ -336,6 +366,7 @@ Expand any section for more details.
A @ A @ A

.. details:: Matrix determinant: `np.linalg.det(A)`
:class: example

.. ipython:: python

Expand All @@ -344,6 +375,7 @@ Expand any section for more details.
np.linalg.det(A)

.. details:: Matrix rank: `np.linalg.matrix_rank(A, z)`
:class: example

.. ipython:: python

Expand All @@ -353,6 +385,7 @@ Expand any section for more details.
A.row_reduce()

.. details:: Matrix trace: `np.trace(A)`
:class: example

.. ipython:: python

Expand All @@ -362,6 +395,7 @@ Expand any section for more details.
A[0,0] + A[1,1] + A[2,2] + A[3,3]

.. details:: Solve a system of equations: `np.linalg.solve(A, b)`
:class: example

.. ipython:: python

Expand All @@ -372,6 +406,7 @@ Expand any section for more details.
np.array_equal(A @ x, b)

.. details:: Matrix inverse: `np.linalg.inv(A)`
:class: example

.. ipython:: python

Expand All @@ -387,6 +422,8 @@ Below are additional linear algebra routines provided for :obj:`~galois.FieldArr
not included in NumPy.

.. details:: Row space: `A.row_space()`
:class: example
:open:

.. ipython:: python

Expand All @@ -397,6 +434,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.row_space` for more details.

.. details:: Column space: `A.column_space()`
:class: example

.. ipython:: python

Expand All @@ -407,6 +445,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.column_space` for more details.

.. details:: Left null space: `A.left_null_space()`
:class: example

.. ipython:: python

Expand All @@ -417,6 +456,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.left_null_space` for more details.

.. details:: Null space: `A.null_space()`
:class: example

.. ipython:: python

Expand All @@ -427,6 +467,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.null_space` for more details.

.. details:: Gaussian elimination: `A.row_reduce()`
:class: example

.. ipython:: python

Expand All @@ -437,6 +478,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.row_reduce` for more details.

.. details:: LU decomposition: `A.lu_decompose()`
:class: example

.. ipython:: python

Expand All @@ -450,6 +492,7 @@ not included in NumPy.
See :func:`~galois.FieldArray.lu_decompose` for more details.

.. details:: PLU decomposition: `A.plu_decompose()`
:class: example

.. ipython:: python

Expand Down
3 changes: 1 addition & 2 deletions docs/basic-usage/element-representation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ This is useful, however it can become cluttered for large arrays.
.. tip::

Use :func:`~galois.set_printoptions` to display the polynomial coefficients in degree-ascending order.

Use :func:`numpy.set_printoptions` to increase the line width to display large arrays more clearly. See :ref:`numpy-print-options`
for more details.

Expand All @@ -124,7 +123,7 @@ Power representation

The power display mode represents the elements as powers of the finite field's primitive element :math:`\alpha`.

.. warning::
.. danger::

To display elements in the power representation, :obj:`galois` must compute the discrete logarithm of each element displayed.
For large fields (or fields using :ref:`explicit calculation <explicit-calculation>`), this process can take a while. However, when
Expand Down
Loading