Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8216ff8

Browse files
committedFeb 13, 2015
Various minor tutorial corrections, many suggested by Akiva.
1 parent 8ee0d4e commit 8216ff8

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed
 

‎tutorial/index.html

+26-13
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,21 @@ <h3>Multi-Dimensional and Uniform</h3>
160160
The shape of a <code>ParallelArray</code> is specified as
161161
an array of numbers in which the value of the <em>i</em>th
162162
element is the number of elements in the <em>i</em>th
163-
dimension of the <code>ParallelArray</code>. So, for
164-
instance, a 4x5 matrix of numbers can be represented as
165-
a <code>ParallelArray</code> object whose shape
163+
dimension of the <code>ParallelArray</code>. The number
164+
of dimensions of a <code>ParallelArray</code> is the
165+
number of elements in its shape array.
166+
</p>
167+
168+
<p>
169+
For instance, a 4x5 matrix of numbers can be represented
170+
as a <code>ParallelArray</code> object whose shape
166171
is <code>[4, 5]</code>. Similarly, a 2D image in which
167172
each pixel has an RGBA value can be represented as
168173
a <code>ParallelArray</code> object with shape <code>[h,
169-
w, 4]</code>. An empty <code>ParallelArray</code> has
174+
w, 4]</code>. (The <code>4</code> comes from the fact
175+
that an RGBA value is 4 bytes, one for each of the red,
176+
green, and blue channels and one for the alpha channel.)
177+
An empty <code>ParallelArray</code> has
170178
shape <code>[0]</code>, and a
171179
one-dimensional <code>ParallelArray</code> with three
172180
elements has shape <code>[3]</code>.
@@ -208,8 +216,8 @@ <h2><a name="constructors"></a>Constructors</h2>
208216
We can pass a regular JavaScript array to
209217
the <code>ParallelArray</code> constructor, as well.
210218
Here, we are creating a <code>ParallelArray</code> out of
211-
a nested JS array. The inner arrays are
212-
also <code>ParallelArray</code>s.
219+
a nested JS array. The inner arrays will also become
220+
<code>ParallelArray</code>s.
213221
</p>
214222

215223
<pre class="brush: js;">
@@ -338,7 +346,7 @@ <h3>Map</h3>
338346
<p>
339347
The first method we will discuss is <code>map</code>,
340348
probably the most prominent and well-known data-parallel
341-
skeleton. The <code>map</code> method expects a function
349+
construct. The <code>map</code> method expects a function
342350
as its first argument that, given a single value, produces
343351
a new value as its result. We call such
344352
functions <em>elemental functions</em>, since they are
@@ -540,7 +548,7 @@ <h3>Scan</h3>
540548
each position contains the sum of all elements of the
541549
source vector up to that position. To implement this
542550
parallel pattern, <code>ParallelArray</code>s support a
543-
<em>scan</em> method.
551+
<code>scan</code> method.
544552
</p>
545553

546554
<pre class="brush: js;">
@@ -551,8 +559,13 @@ <h3>Scan</h3>
551559
<p>
552560
Here, we again use the <code>plus</code> elemental
553561
function from the previous reduction example. However,
554-
when used with <em>scan</em>, it now produces the
555-
prefix-sum array of the <code>source</code> array.
562+
when used with <code>scan</code>, it now produces the
563+
prefix-sum array of the <code>source</code> array, which
564+
is the <code>ParallelArray</code> <code>[1, 3, 6, 10,
565+
15]</code>. If we were only interested in the last
566+
element, <code>15</code>, we could have just
567+
called <code>reduce</code>; by using <code>scan</code>, we
568+
also get all the intermediate results.
556569
</p>
557570

558571
<p>
@@ -575,7 +588,7 @@ <h3>Scatter</h3>
575588
specify or costly to compute. Instead, it is preferable to
576589
specify for a certain <em>source</em> index where it
577590
should be stored in the result array. This pattern is
578-
supported by the <em>scatter</em> method in River
591+
supported by the <code>scatter</code> method in River
579592
Trail. Here is an example:
580593
</p>
581594

@@ -586,8 +599,8 @@ <h3>Scatter</h3>
586599

587600
<p>
588601
We first compute our source array <code>source</code>. In
589-
a second step, we apply the <em>scatter</em> method with a
590-
single argument: the <em>scatter
602+
a second step, we apply the <code>scatter</code> method
603+
with a single argument: the <em>scatter
591604
vector</em> <code>[4,0,3,1,2]</code>. Thereby, we specify
592605
that the first element of <code>source</code> is to become
593606
the fifth element of the result (indexing starts with 0),

0 commit comments

Comments
 (0)
This repository has been archived.