Created
August 8, 2012 23:31
-
-
Save jsreeram/3299719 to your computer and use it in GitHub Desktop.
Parallel Array Constructors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an empty Parallel Array | |
var pa0 = new ParallelArray(); | |
// pa0 = <> | |
// Create a ParallelArray out of a nested JS array. | |
// Note that the inner arrays are also ParallelArrays | |
var pa1 = new ParallelArray([ [0,1], [2,3], [4,5] ]); | |
// pa1 = <<0,1>, <2,3>, <4.5>> | |
// Create a ParallelArray from another ParallelArray | |
var pa2 = new ParallelArray(pa1); | |
// pa2 = <<0,1>, <2,3>, <4.5>> | |
// Create a ParallelArray from several other ParallelArrays | |
var pa3 = new ParallelArray(<0,1>, <2,3>); | |
// pa3 = <<0,1>,<2,3>> | |
// Create a one-dimensional ParallelArray of length 3 using | |
// the "comprehension" constructor | |
var pa6 = new ParallelArray(3, | |
function(i){return [i, i+1];}); | |
// pa6 = <<0,1>, <1,2>, <2,3>> | |
// Create a two-dimensional ParallelArray with shape [3, 2] using | |
// the comprehension constructor | |
var pa7 = new ParallelArray([3, 2], | |
function(iv){return iv[0] * iv[1];}); | |
// pa7 = <<0,0>, <0,1>, <0,2>> | |
// Create a ParallelArray from canvas. | |
// This creates a PA with shape [w, h, 4], corresponding to the | |
// width and height of the canvas and the RGBA values for each pixel. | |
var pa8 = new ParallelArray(canvas); | |
// pa8 = CanvasPixelArray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment