Skip to content

Commit 112fe2a

Browse files
committed
Fixed math.css inclusion (#16)
1 parent 993b8de commit 112fe2a

File tree

5 files changed

+367
-87
lines changed

5 files changed

+367
-87
lines changed

01-preface.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ If you want to rebuild the html output, from the top directory, type:
4242
4343
$ rst2html.py --link-stylesheet --cloak-email-addresses \
4444
--toc-top-backlinks --stylesheet=book.css \
45-
book.rst book.html
45+
--stylesheet-dirs=. book.rst book.html
4646
4747
The sources are available from https://github.com/rougier/from-python-to-numpy.
4848

02-introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ function as:
9090
walk = random_walk_faster(1000)
9191
9292
In fact, we've just *vectorized* our function. Instead of looping for picking
93-
sequential steps and add them to the current position, we fist generate all the
94-
steps at once and use the `accumulate
93+
sequential steps and add them to the current position, we first generated all the
94+
steps at once and used the `accumulate
9595
<https://docs.python.org/3.6/library/itertools.html#itertools.accumulate>`_
96-
function to compute all the positions. We get rid of the loop and this makes
96+
function to compute all the positions. We got rid of the loop and this makes
9797
things faster:
9898

9999
.. code:: pycon

05-problem-vectorization.rst

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -662,24 +662,25 @@ without any guarantee in quality. It's time to think out-of-the-box and luckily
662662
enough, Robert Bridson did that for us and proposed a simple yet efficient
663663
method:
664664

665-
**Step 0**. *Initialize an n-dimensional background grid for storing samples and
666-
accelerating spatial searches. We pick the cell size to be bounded by :math:`\frac{r}{\sqrt{n}}`, so
667-
that each grid cell will contain at most one sample, and thus the grid can be
668-
implemented as a simple n-dimensional array of integers: the default −1
669-
indicates no sample, a non-negative integer gives the index of the sample
670-
located in a cell.*
671-
672-
**Step 1**. *Select the initial sample, :math:`x_0`, randomly chosen uniformly from the
673-
domain. Insert it into the background grid, and initialize the “active list”
674-
(an array of sample indices) with this index (zero).*
675-
676-
**Step 2**. *While the active list is not empty, choose a random index from it
677-
(say :math:`i`). Generate up to :math:`k` points chosen uniformly from the spherical annulus
678-
between radius :math:`r` and :math:`2r` around :math:`x_i`. For each point in turn, check if it is
679-
within distance :math:`r` of existing samples (using the background grid to only test
680-
nearby samples). If a point is adequately far from existing samples, emit it
681-
as the next sample and add it to the active list. If after :math:`k` attempts no such
682-
point is found, instead remove :math:`i` from the active list.*
665+
**Step 0**. Initialize an n-dimensional background grid for storing samples and
666+
accelerating spatial searches. We pick the cell size to be bounded by
667+
:math:`\frac{r}{\sqrt{n}}`, so that each grid cell will contain at most one
668+
sample, and thus the grid can be implemented as a simple n-dimensional array of
669+
integers: the default −1 indicates no sample, a non-negative integer gives the
670+
index of the sample located in a cell.
671+
672+
**Step 1**. Select the initial sample, :math:`x_0`, randomly chosen uniformly from the
673+
domain. Insert it into the background grid, and initialize the “active list”
674+
(an array of sample indices) with this index (zero).
675+
676+
**Step 2**. While the active list is not empty, choose a random index from
677+
it (say :math:`i`). Generate up to :math:`k` points chosen uniformly from the
678+
spherical annulus between radius :math:`r` and :math:`2r` around
679+
:math:`x_i`. For each point in turn, check if it is within distance :math:`r`
680+
of existing samples (using the background grid to only test nearby
681+
samples). If a point is adequately far from existing samples, emit it as the
682+
next sample and add it to the active list. If after :math:`k` attempts no
683+
such point is found, instead remove :math:`i` from the active list.
683684

684685

685686
Implementation poses no real problem and is left as an exercise for the

0 commit comments

Comments
 (0)