Skip to content

Commit d571e4c

Browse files
committed
Merge branch 'develop'
2 parents 19279fb + 7a54c34 commit d571e4c

File tree

17 files changed

+901
-76
lines changed

17 files changed

+901
-76
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
import os
2+
import sys
3+
sys.path.insert(0, os.path.abspath('../..'))
4+
sys.path.insert(0, os.path.abspath('..'))
5+
sys.setrecursionlimit(1500)
6+
7+
# -- Project information -----------------------------------------------------
8+
9+
project = 'eMaTe'
10+
copyright = '2019, Bruno Messias; Thomas Peron'
11+
author = 'Bruno Messias; Thomas Peron'
12+
13+
# The short X.Y version
14+
version = ''
15+
# The full version, including alpha/beta/rc tags
16+
release = '1.0.3'
17+
18+
19+
# -- General configuration ---------------------------------------------------
20+
21+
# If your documentation needs a minimal Sphinx version, state it here.
22+
#
23+
# needs_sphinx = '1.0'
24+
25+
# Add any Sphinx extension module names here, as strings. They can be
26+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
27+
# ones.
28+
extensions = [
29+
'sphinx.ext.autodoc',
30+
# 'sphinx.ext.intersphinx',
31+
'sphinx.ext.todo',
32+
'sphinx.ext.mathjax',
33+
'sphinx.ext.ifconfig',
34+
'sphinx.ext.viewcode',
35+
'sphinx.ext.githubpages',
36+
'sphinxcontrib.napoleon',
37+
# 'sphinx.ext.napoleon',
38+
]
39+
napoleon_google_docstring = False
40+
41+
napoleon_numpy_docstring = True
42+
napoleon_include_init_with_doc = True
43+
napoleon_include_private_with_doc = False
44+
napoleon_include_special_with_doc = True
45+
napoleon_use_admonition_for_examples = True
46+
napoleon_use_admonition_for_notes = True
47+
napoleon_use_admonition_for_references = True
48+
napoleon_use_ivar = True
49+
napoleon_use_param = True
50+
napoleon_use_rtype = True
51+
52+
# Add any paths that contain templates here, relative to this directory.
53+
templates_path = ['_templates']
54+
55+
# The suffix(es) of source filenames.
56+
# You can specify multiple suffix as a list of string:
57+
#
58+
# source_suffix = ['.rst', '.md']
59+
source_suffix = '.rst'
60+
61+
# The master toctree document.
62+
master_doc = 'index'
63+
html_logo = "imgs/logo_100.png"
64+
html_favicon = "imgs/logo_36.ico"
65+
# The language for content autogenerated by Sphinx. Refer to documentation
66+
# for a list of supported languages.
67+
#
68+
# This is also used if you do content translation via gettext catalogs.
69+
# Usually you set "language" from the command line for these cases.
70+
language = None
71+
72+
# List of patterns, relative to source directory, that match files and
73+
# directories to ignore when looking for source files.
74+
# This pattern also affects html_static_path and html_extra_path.
75+
exclude_patterns = []
76+
77+
# The name of the Pygments (syntax highlighting) style to use.
78+
pygments_style = None
79+
80+
81+
# -- Options for HTML output -------------------------------------------------
82+
83+
# The theme to use for HTML and HTML Help pages. See the documentation for
84+
# a list of builtin themes.
85+
#
86+
87+
html_theme = 'sphinx_rtd_theme'
88+
89+
90+
# Theme options are theme-specific and customize the look and feel of a theme
91+
# further. For a list of options available for each theme, see the
92+
# documentation.
93+
#
94+
# html_theme_options = {}
95+
96+
# Add any paths that contain custom static files (such as style sheets) here,
97+
# relative to this directory. They are copied after the builtin static files,
98+
# so a file named "default.css" will overwrite the builtin "default.css".
99+
html_static_path = ['_static']
100+
101+
# Custom sidebar templates, must be a dictionary that maps document names
102+
# to template names.
103+
#
104+
# The default sidebars (for documents that don't match any pattern) are
105+
# defined by theme itself. Builtin themes are using these templates by
106+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
107+
# 'searchbox.html']``.
108+
#
109+
# html_sidebars = {}
110+
111+
112+
# -- Options for HTMLHelp output ---------------------------------------------
113+
114+
# Output file base name for HTML help builder.
115+
htmlhelp_basename = 'eMaTedoc'
116+
117+
118+
# -- Options for LaTeX output ------------------------------------------------
119+
120+
latex_elements = {
121+
# The paper size ('letterpaper' or 'a4paper').
122+
#
123+
# 'papersize': 'letterpaper',
124+
125+
# The font size ('10pt', '11pt' or '12pt').
126+
#
127+
# 'pointsize': '10pt',
128+
129+
# Additional stuff for the LaTeX preamble.
130+
#
131+
# 'preamble': '',
132+
133+
# Latex figure (float) alignment
134+
#
135+
# 'figure_align': 'htbp',
136+
}
137+
138+
# Grouping the document tree into LaTeX files. List of tuples
139+
# (source start file, target name, title,
140+
# author, documentclass [howto, manual, or own class]).
141+
latex_documents = [
142+
(master_doc, 'eMaTe.tex', 'eMaTe Documentation',
143+
'Bruno Messias; Thomas Peron', 'manual'),
144+
]
145+
146+
147+
# -- Options for manual page output ------------------------------------------
148+
149+
# One entry per manual page. List of tuples
150+
# (source start file, name, description, authors, manual section).
151+
man_pages = [
152+
(master_doc, 'emate', 'eMaTe Documentation',
153+
[author], 1)
154+
]
155+
156+
157+
# -- Options for Texinfo output ----------------------------------------------
158+
159+
# Grouping the document tree into Texinfo files. List of tuples
160+
# (source start file, target name, title, author,
161+
# dir menu entry, description, category)
162+
texinfo_documents = [
163+
(master_doc, 'eMaTe', 'eMaTe Documentation',
164+
author, 'eMaTe', 'One line description of project.',
165+
'Miscellaneous'),
166+
]
167+
168+
169+
# -- Options for Epub output -------------------------------------------------
170+
171+
# Bibliographic Dublin Core info.
172+
epub_title = project
173+
174+
# The unique identifier of the text. This can be a ISBN number
175+
# or the project homepage.
176+
#
177+
# epub_identifier = ''
178+
179+
# A unique identification for the text.
180+
#
181+
# epub_uid = ''
182+
183+
# A list of files that should not be packed into the epub file.
184+
epub_exclude_files = ['search.html']
185+
186+
187+
# -- Extension configuration -------------------------------------------------
188+
189+
# -- Options for intersphinx extension ---------------------------------------
190+
191+
# Example configuration for intersphinx: refer to the Python standard library.
192+
#intersphinx_mapping = {'https://docs.python.org/': None}
193+
194+
# -- Options for todo extension ----------------------------------------------
195+
196+
# If true, `todo` and `todoList` produce output, else they produce nothing.
197+
todo_include_todos = True

docs/source/examples.rst

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
========
2+
Examples
3+
========
4+
5+
Kernel Polynomial Method (Chebyshev Polynomial expansion)
6+
=========================================================
7+
8+
9+
The Kernel Polynomial Method can estimate the spectral density of large
10+
sparse Hermitan matrices with a low computational cost. This method
11+
combines three key ingredients: the Chebyshev expansion + the stochastic
12+
trace estimator + kernel smoothing.
13+
14+
15+
.. code-block:: python
16+
17+
import igraph as ig
18+
import numpy as np
19+
20+
N = 3000
21+
G = ig.Graph.Erdos_Renyi(N, 3/N)
22+
23+
W = np.array(G.get_adjacency().data, dtype=np.float64)
24+
vals = np.linalg.eigvalsh(W).real
25+
26+
.. code-block:: python
27+
28+
from emate.hermitian import pykpm
29+
from stdog.utils.misc import ig2sparse
30+
31+
W = ig2sparse(G)
32+
33+
num_moments = 300
34+
num_vecs = 200
35+
extra_points = 10
36+
ek, rho = pykpm(W, num_moments, num_vecs, extra_points)
37+
38+
.. code-block:: python
39+
40+
import matplotlib.pyplot as plt
41+
plt.hist(vals, density=True, bins=100, alpha=.9, color="steelblue")
42+
plt.scatter(ek, rho, c="tomato", zorder=999, alpha=0.9, marker="d")
43+
plt.ylim(0, 1)
44+
plt.show()
45+
46+
47+
.. image:: imgs/kpm.png
48+
49+
References
50+
----------
51+
52+
[1] Wang, L.W., 1994. Calculating the density of states and
53+
optical-absorption spectra of large quantum systems by the plane-wave moments
54+
method. Physical Review B, 49(15), p.10154.
55+
56+
[2] Hutchinson, M.F., 1990. A stochastic estimator of the trace of the
57+
influence matrix for laplacian smoothing splines. Communications in
58+
Statistics-Simulation and Computation, 19(2), pp.433-450.
59+
60+
61+
62+
Sthocastic Lanczos Quadrature
63+
=============================
64+
65+
Given a semi-positive definite matrix :math:`A \in \mathbb R^{|V|\times|V|}`,
66+
which has the set of eigenvalues given by :math:`\{\lambda_i\}` a trace of
67+
a matrix function is given by
68+
69+
.. math::
70+
71+
\mathrm{tr}(f(A)) = \sum\limits_{i=0}^{|V|} f(\lambda_i)
72+
73+
The methods for calculating such traces functions have a
74+
cubic computational complexity lower bound, :math:`O(|V|^3)`.
75+
Therefore, it is not feasible for  large networks. One way
76+
to overcome such computational complexity it is use stochastic approximations
77+
combined with a mryiad of another methods
78+
to get the results with enough accuracy and with a small computational cost.
79+
The methods available in this module uses the Sthocastic Lanczos Quadrature,
80+
a procedure proposed in the work made by Ubaru, S. et.al. [1] (you need to cite them).
81+
82+
83+
Estrada Index
84+
^^^^^^^^^^^^^^^^
85+
86+
.. code-block:: python
87+
88+
import scipy
89+
import scipy.sparse
90+
import igraph as ig
91+
import numpy as np
92+
93+
N = 3000
94+
G = ig.Graph.Erdos_Renyi(N, 3/N)
95+
96+
.. code-block:: python
97+
98+
from emate.symmetric.slq import pyslq
99+
import tensorflow as tf
100+
101+
def trace_function(eig_vals):
102+
return tf.exp(eig_vals)
103+
104+
num_vecs = 100
105+
num_steps = 50
106+
approximated_estrada_index, _ = pyslq(L_sparse, num_vecs, num_steps, trace_function)
107+
exact_estrada_index = np.sum(np.exp(vals_laplacian))
108+
approximated_estrada_index, exact_estrada_index
109+
110+
111+
The above code returns
112+
113+
.. code-block:: bash
114+
115+
(3058.012, 3063.16457163222)
116+
117+
References
118+
----------
119+
120+
1 - Ubaru, S., Chen, J., & Saad, Y. (2017). Fast Estimation of tr(f(A)) via Stochastic Lanczos Quadrature.
121+
SIAM Journal on Matrix Analysis and Applications, 38(4), 1075-1099.
122+
123+
2 - Hutchinson, M. F. (1990). A stochastic estimator of the trace of the
124+
influence matrix for laplacian smoothing splines. Communications in
125+
Statistics-Simulation and Computation, 19(2), 433-450.

docs/source/hermitian.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
==========
2+
Hermitian
3+
==========
4+
5+
.. automodule:: emate.hermitian.kpm
6+
:members:
7+
8+
9+

docs/source/imgs/emate.png

9.36 KB
Loading
File renamed without changes.

docs/source/imgs/logo_100.png

7.42 KB
Loading

docs/source/imgs/logo_36.ico

5.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)