Skip to content

Commit

Permalink
cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bunions1 committed Feb 16, 2010
1 parent 7b10c67 commit 18dc860
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 9 deletions.
14 changes: 11 additions & 3 deletions static/sylvester.js
Expand Up @@ -505,6 +505,8 @@ var fragShader = Matrix.gl.createShader(Matrix.gl.FRAGMENT_SHADER);
return shaderProgram;

};



function slice(pixels, begin, end){
var slice = [];
Expand Down Expand Up @@ -743,9 +745,15 @@ Matrix.prototype = {
for(var k = 0; k < width; ++k){
var begin = (i * width * bytesPerValue) + (k * bytesPerValue);
var end = (i * width * bytesPerValue) + (k * bytesPerValue) + bytesPerValue;
if(!( end <= pixels.length))
throw "dimensions wrong in unpackTexture";
row.push(unpack(slice(pixels, begin, end)));
if("length" in pixels){
if(!( end <= pixels.length))
throw "dimensions wrong in unpackTexture";
row.push(unpack(slice(pixels, begin, end)));
}else{
if(!( end <= pixels.data.length))
throw "dimensions wrong in unpackTexture";
row.push(unpack(slice(pixels.data, begin, end)));
}
}
elements.push(row);
}
Expand Down
29 changes: 26 additions & 3 deletions sylvesterTest.html
Expand Up @@ -24,23 +24,46 @@
return arrayMatrix;
}

$(document).read(function(){
$(document).ready(function(){
$("#execute").click(function(){
alert('hi');
var startDate = new Date();
one = $M(createArrayMatrix(1024, 1024, 1, 2));
other = $M(createArrayMatrix(1024, 1024, 1));
two = one.multiply(other);
alert((new Date() - startDate) / 1000.0);
});


$("#executeSample").click(function(){
var one = $M([[1,2], [1, 2 ]]);
var two= $M([[1,2], [1, 2 ]]);
var result = one.multiply(two)
alert(result.elements);
});

});

</script>
</head>
<body>
<div style="padding: 5px; border: 1px solid black; position:relative; width:500px">
This page include the sylvester library, modified to use the gpu for matrix multiply, the api is exactly the same as the orignal sylvester. Hit execute to benchmark a multiply of two 1024x1024 matrices<br/>
<input id="execute" type="button" value="execute">
</div>
<input id="execute" type="button" value="execute"><br/><br/>
Open up firebug or the console to test it out <br/>
example code:
<pre>
<code>
var one = $M([[1,2], [1, 2 ]]);
var two= $M([[1,2], [1, 2 ]]);
var result = one.multiply(two)
alert(result.elements);
</code>
</pre>
<input id="executeSample" type="button" value="execute"><br/><br/>


<span><a href="sylvesterTest.html">gpu sylvester</a>&nbsp;&nbsp;&nbsp;<a href="sylvesterTestOriginal.html">original sylvester</a></span>
</body>
</html>

30 changes: 27 additions & 3 deletions sylvesterTestOriginal.html
Expand Up @@ -24,21 +24,45 @@
return arrayMatrix;
}


$(document).ready(function(){
$("#execute").click(function(){
var startDate = new Date();
one = $M(createArrayMatrix(1024, 1024, 1, 2));
other = $M(createArrayMatrix(1024, 1024, 1));
two = one.multiply(other);
alert((new Date() - startDate) / 1000.0);
});

$("#executeSample").click(function(){
var one = $M([[1,2], [1, 2 ]]);
var two= $M([[1,2], [1, 2 ]]);
var result = one.multiply(two)
alert(result.elements);
});

});
</script>
</head>
<body>
This page include the original sylvester library. Hit execute to benchmark a multiply of two 1024x1024 matrices<br/>
<input id="execute" type="button" value="execute">

<div style="padding: 5px; border: 1px solid black; position:relative; width:500px;">
This page include the original sylvester library. Hit execute to benchmark a multiply of two 1024x1024 matrices. (You will have to hit continue when it asks if you want to stop the long running script.)<br/>
</div>
<input id="execute" type="button" value="execute"><br/><br/>
Open up firebug or the console to test it out <br/>
example code:
<pre>
<code>
var one = $M([[1,2], [1, 2 ]]);
var two= $M([[1,2], [1, 2 ]]);
var result = one.multiply(two)
alert(result.elements);
</code>
</pre>
<input id="executeSample" type="button" value="execute"><br/><br/>


<span><a href="sylvesterTest.html">gpu sylvester</a>&nbsp;&nbsp;&nbsp;<a href="sylvesterTestOriginal.html">original sylvester</a></span>
</body>
</html>

0 comments on commit 18dc860

Please sign in to comment.