/*
Copyright (C) 2013
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js
*/
"use strict";
// SIMD module.
var SIMD = {};
/**
* Construct a new instance of float32x4 number.
* @param {double} value used for x lane.
* @param {double} value used for y lane.
* @param {double} value used for z lane.
* @param {double} value used for w lane.
* @constructor
*/
SIMD.float32x4 = function(x, y, z, w) {
if (!(this instanceof SIMD.float32x4)) {
return new SIMD.float32x4(x, y, z, w);
}
this.storage_ = new Float32Array(4);
this.storage_[0] = x;
this.storage_[1] = y;
this.storage_[2] = z;
this.storage_[3] = w;
}
/**
* Construct a new instance of float32x4 number with 0.0 in all lanes.
* @constructor
*/
SIMD.float32x4.zero = function() {
return SIMD.float32x4(0.0, 0.0, 0.0, 0.0);
}
/**
* Construct a new instance of float32x4 number with the same value
* in all lanes.
* @param {double} value used for all lanes.
* @constructor
*/
SIMD.float32x4.splat = function(s) {
return SIMD.float32x4(s, s, s, s);
}
/**
* Construct a new instance of int32x4 number.
* @param {integer} 32-bit unsigned value used for x lane.
* @param {integer} 32-bit unsigned value used for y lane.
* @param {integer} 32-bit unsigned value used for z lane.
* @param {integer} 32-bit unsigned value used for w lane.
* @constructor
*/
SIMD.int32x4 = function(x, y, z, w) {
if (!(this instanceof SIMD.int32x4)) {
return new SIMD.int32x4(x, y, z, w);
}
this.storage_ = new Int32Array(4);
this.storage_[0] = x;
this.storage_[1] = y;
this.storage_[2] = z;
this.storage_[3] = w;
}
/**
* Construct a new instance of int32x4 number with 0 in all lanes.
* @constructor
*/
SIMD.int32x4.zero = function() {
return SIMD.int32x4(0, 0, 0, 0);
}
/**
* Construct a new instance of int32x4 number with 0xFFFFFFFF or 0x0 in each
* lane, depending on the truth value in x, y, z, and w.
* @param {boolean} flag used for x lane.
* @param {boolean} flag used for y lane.
* @param {boolean} flag used for z lane.
* @param {boolean} flag used for w lane.
* @constructor
*/