Skip to content

Commit 1f20e06

Browse files
committed
Typo
1 parent 3d2a83c commit 1f20e06

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

05-problem-vectorization.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ compute it only once:
104104
result += X[i]*Ysum
105105
return result
106106
107-
Not so bad, we have the inner loop, meaning with transform a :math:`O(n^2)` complexity
108-
into :math:`O(n)` complexity. Using the same approach, we can now write:
107+
Not so bad, we have removed the inner loop, meaning with transform a
108+
:math:`O(n^2)` complexity into :math:`O(n)` complexity. Using the same
109+
approach, we can now write:
109110

110111
.. code:: python
111112
@@ -137,7 +138,7 @@ It is shorter, clearer and much, much faster:
137138
We have indeed reformulated our problem, taking advantage of the fact that
138139
:math:`\sum_{ij}{X_i}{Y_j} = \sum_{i}X_i \sum_{j}Y_j$` and we've learned in the
139140
meantime that there are two kinds of vectorization: code vectorization and
140-
the problem vectorization. The latter is the most difficult but the most
141+
problem vectorization. The latter is the most difficult but the most
141142
important because this is where you can expect huge gains in speed. In this
142143
simple example, we gain a factor of 150 with code vectorization but we gained a
143144
factor of 70,000 with problem vectorization, just by writing our problem

book.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,9 @@ <h2><a class="toc-backref" href="#id15">Introduction</a></h2>
14291429
<span class="name">result</span> <span class="operator">+=</span> <span class="name">X</span><span class="punctuation">[</span><span class="name">i</span><span class="punctuation">]</span><span class="operator">*</span><span class="name">Ysum</span>
14301430
<span class="keyword">return</span> <span class="name">result</span>
14311431
</pre>
1432-
<p>Not so bad, we have the inner loop, meaning with transform a <span class="formula"><i>O</i>(<i>n</i><sup>2</sup>)</span> complexity
1433-
into <span class="formula"><i>O</i>(<i>n</i>)</span> complexity. Using the same approach, we can now write:</p>
1432+
<p>Not so bad, we have removed the inner loop, meaning with transform a
1433+
<span class="formula"><i>O</i>(<i>n</i><sup>2</sup>)</span> complexity into <span class="formula"><i>O</i>(<i>n</i>)</span> complexity. Using the same
1434+
approach, we can now write:</p>
14341435
<pre class="code python literal-block">
14351436
<span class="keyword">def</span> <span class="name function">compute_numpy_better_3</span><span class="punctuation">(</span><span class="name">x</span><span class="punctuation">,</span> <span class="name">y</span><span class="punctuation">):</span>
14361437
<span class="name">Ysum</span> <span class="operator">=</span> <span class="operator">=</span> <span class="literal number integer">0</span>
@@ -1456,7 +1457,7 @@ <h2><a class="toc-backref" href="#id15">Introduction</a></h2>
14561457
<p>We have indeed reformulated our problem, taking advantage of the fact that
14571458
<span class="formula"><span class="limits"><span class="limit"><span class="symbol"></span></span></span><sub><i>ij</i></sub><i>X</i><sub><i>i</i></sub><i>Y</i><sub><i>j</i></sub> = <span class="limits"><span class="limit"><span class="symbol"></span></span></span><sub><i>i</i></sub><i>X</i><sub><i>i</i></sub><span class="limits"><span class="limit"><span class="symbol"></span></span></span><sub><i>j</i></sub><i>Y</i><sub><i>j</i></sub></span> and we've learned in the
14581459
meantime that there are two kinds of vectorization: code vectorization and
1459-
the problem vectorization. The latter is the most difficult but the most
1460+
problem vectorization. The latter is the most difficult but the most
14601461
important because this is where you can expect huge gains in speed. In this
14611462
simple example, we gain a factor of 150 with code vectorization but we gained a
14621463
factor of 70,000 with problem vectorization, just by writing our problem

0 commit comments

Comments
 (0)