# Comparison Matrix and Vector library

## JavaScript performance comparison

Revision 9 of this test case created by

## Preparation code

``````<script src="https://glmatrix.googlecode.com/files/glMatrix-0.9.5.min.js"></script>
<script src="https://raw.github.com/mrdoob/three.js/master/build/three.js">
</script>
<script src="https://raw.github.com/1Pupik1989/N3D/master/source/N3D.min.js">
</script>
<script>
N3D.require("Math.Matrix4", "Math.Vector4");

if(!dest) { dest = quat; }

dest[0] = quat[0] + quat2[0];
dest[1] = quat[1] + quat2[1];
dest[2] = quat[2] + quat2[2];
dest[3] = quat[3] + quat2[3];

return dest;
};
</script>
<script src="https://raw.github.com/sloisel/numeric/master/src/numeric.js">
</script>
<script src="https://raw.github.com/vexator/TSM/master/TSM/tsm-0.6.min.js"></script>

<script>
Benchmark.prototype.setup = function() {
var n3dm = new \$M4(
1, 2, 3, 4, 0, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0, 10);
var n3dv = new \$V4( 1, 2, 3, 4 );
var threem = new THREE.Matrix4(
1, 2, 3, 4, 0, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0, 10);
var threev = new THREE.Vector4(1, 2, 3, 1);
var nv = [1, 2, 3, 1];
var nm = [
[1, 2, 3, 4],
[0, 5, 6, 7],
[0, 0, 8, 9],
[0, 0, 0, 10]
];
var tsv = new TSM.vec4([1,2,3,1]);
var tsm = new TSM.mat4([
1, 2, 3, 4,
0, 5, 6, 7,
0, 0, 8, 9,
0, 0, 0, 10
]);
var glv = quat4.create([1,2,3,1]);
var glm = mat4.create([
1, 2, 3, 4,
0, 5, 6, 7,
0, 0, 8, 9,
0, 0, 0, 10
]);

};

</script>
``````

## Preparation code output

<script src="https://raw.github.com/mrdoob/three.js/master/build/three.js"> </script> <script src="https://raw.github.com/1Pupik1989/N3D/master/source/N3D.min.js"> </script> <script> N3D.require("Math.Matrix4", "Math.Vector4"); quat4.add = function(quat,quat2,dest){ if(!dest) { dest = quat; } dest[0] = quat[0] + quat2[0]; dest[1] = quat[1] + quat2[1]; dest[2] = quat[2] + quat2[2]; dest[3] = quat[3] + quat2[3]; return dest; }; </script> <script src="https://raw.github.com/sloisel/numeric/master/src/numeric.js"> </script> <script src="https://raw.github.com/vexator/TSM/master/TSM/tsm-0.6.min.js"></script>

## Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
glMatrix
``````mat4.inverse(glm);
mat4.multiply(glm,glm);
mat4.multiplyVec4(glm,glv);``````
pending…
TSM
``````tsm.inverse();
tsm.multiply(tsm);
tsm.multiplyVec4(tsv);``````
pending…
numericjs
``````nm = numeric.inv(nm);
nm = numeric.mul(nm, nm);
nm = numeric.mul(nv);``````
pending…
Three.js
``````threem.getInverse(threem);
threem.multiplyMatrices(threem, threem);
threev.applyMatrix4(threem);``````
pending…
N3D
``````n3dm.inverse();
n3dm.multiply(n3dm);
You can edit these tests or add even more tests to this page by appending `/edit` to the URL.