aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/Makefile20
-rw-r--r--docs/conf.py31
-rw-r--r--docs/discussions.rst2
-rw-r--r--docs/howto.rst2
-rw-r--r--docs/index.rst19
-rw-r--r--docs/make.bat35
-rw-r--r--docs/reference.rst83
-rw-r--r--docs/tutorials.rst40
8 files changed, 232 insertions, 0 deletions
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..d4bb2cb
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,20 @@
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS ?=
+SPHINXBUILD ?= sphinx-build
+SOURCEDIR = .
+BUILDDIR = _build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..1cc81ba
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,31 @@
+# Configuration file for the Sphinx documentation builder.
+#
+# For the full list of built-in configuration values, see the documentation:
+# https://www.sphinx-doc.org/en/master/usage/configuration.html
+
+# -- Project information -----------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
+
+import os
+import sys
+sys.path.insert(0, os.path.abspath('..'))
+
+project = 'mdpoly'
+copyright = '2024, Naoki Sean Pross <np@0hm.ch>'
+author = 'Naoki Sean Pross <npross@ethz.ch>'
+release = '0.1.0'
+
+# -- General configuration ---------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
+
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary']
+autosummary_generate = True
+
+templates_path = ['_templates']
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# -- Options for HTML output -------------------------------------------------
+# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
+
+html_theme = 'alabaster'
+html_static_path = ['_static']
diff --git a/docs/discussions.rst b/docs/discussions.rst
new file mode 100644
index 0000000..87c895a
--- /dev/null
+++ b/docs/discussions.rst
@@ -0,0 +1,2 @@
+Discussions
+===========
diff --git a/docs/howto.rst b/docs/howto.rst
new file mode 100644
index 0000000..e7452d2
--- /dev/null
+++ b/docs/howto.rst
@@ -0,0 +1,2 @@
+How-To Guides
+=============
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..71bf8c6
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,19 @@
+
+Multidimensional Polynomials
+============================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+ tutorials
+ howto
+ discussions
+ reference
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 0000000..32bb245
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,35 @@
+@ECHO OFF
+
+pushd %~dp0
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+ set SPHINXBUILD=sphinx-build
+)
+set SOURCEDIR=.
+set BUILDDIR=_build
+
+%SPHINXBUILD% >NUL 2>NUL
+if errorlevel 9009 (
+ echo.
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+ echo.installed, then set the SPHINXBUILD environment variable to point
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
+ echo.may add the Sphinx directory to PATH.
+ echo.
+ echo.If you don't have Sphinx installed, grab it from
+ echo.https://www.sphinx-doc.org/
+ exit /b 1
+)
+
+if "%1" == "" goto help
+
+%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+goto end
+
+:help
+%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
+
+:end
+popd
diff --git a/docs/reference.rst b/docs/reference.rst
new file mode 100644
index 0000000..89f5bfb
--- /dev/null
+++ b/docs/reference.rst
@@ -0,0 +1,83 @@
+Package Reference
+=================
+
+Module contents
+---------------
+
+.. automodule:: mdpoly
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+
+mdpoly.abc
+----------
+
+.. automodule:: mdpoly.abc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.algebra
+--------------
+
+.. automodule:: mdpoly.algebra
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.constants
+----------------
+
+.. automodule:: mdpoly.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.errors
+-------------
+
+.. automodule:: mdpoly.errors
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.leaves
+-------------
+
+.. automodule:: mdpoly.leaves
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.representations
+----------------------
+
+.. automodule:: mdpoly.representations
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.state
+------------
+
+.. automodule:: mdpoly.state
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.types
+------------
+
+.. automodule:: mdpoly.types
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+mdpoly.util
+-----------
+
+.. automodule:: mdpoly.util
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/tutorials.rst b/docs/tutorials.rst
new file mode 100644
index 0000000..a2e1b20
--- /dev/null
+++ b/docs/tutorials.rst
@@ -0,0 +1,40 @@
+Tutorials
+=========
+
+Quickstart
+----------
+
+For the impatient, here is a very quick overview.
+
+.. code:: py
+
+ from mdpoly import State, Variable, Parameter
+ from mdpoly.representations import SparseRepr
+
+ # Construct an expression
+ x, y = Variable.from_names("x, y") # or just Variable("x")
+ k = Parameter("k")
+
+ p = (x + 2 * y) ** 3 + y ** 2 + k
+ print(f"{p = }")
+
+ # Make a concrete representation
+ state = State(parameters={k: 3.14}) # try to replace with empty dict
+ sparse, state = p.to_repr(SparseRepr, state)
+
+ # Look inside the representation
+ for entry in sparse.entries():
+ print(f"at (row, col) = {entry.row, entry.col} there is a polynomial:")
+ for term in sparse.terms(entry):
+ monomial_str = ""
+ for idx in term:
+ var = state.from_index(idx.var_idx)
+ monomial_str += f"{var.name}^{idx.power} "
+
+ # Get the coefficient
+ coeff = sparse.at(entry, term)
+ print(" - the monomial", monomial_str, "has coefficient", coeff)
+
+ # You can also simply iterate over it
+ for entry, term, coeff in sparse:
+ print(entry, term, coeff)