<commit_before>/**
 * Created by grizet_j on 9/21/2015.
 */
module.exports = Vector4;

var vector_math = require('./common.js');
var SIMD = require("simd");

/**
 * @class Vector4
 * @param x {Number}
 * @param y {Number}
 * @param z {Number}
 * @param w {Number}
 * @constructor
 */
function Vector4(x, y, z, w){
    /**
     * @property storage
     * @type {Float32Array}
     */
    this.storage = new Float32Array([x, y, z, w]);
    /**
     * @property simd_storage
     * @type {null|Float32x4}
     */
    this.simd_storage = null;
}

/**
 * @static
 * SIMD specialization
 */
Vector4.simd = {};
/**
 * @static
 * Scalar specialization
 */
Vector4.scalar = {};

/**
 * @static
 * Load SIMD.Float32x4 into vector.simd_storage
 * @param vector {Vector4}
 */
Vector4.simd.load = function(vector) {
    vector.simd_storage = SIMD.Float32x4.load(vector.storage, 0);
};

/**
 * @static
 * Store SIMD.Float32x4 at vector.simd_storage into vector.storage
 * @param vector {Vector4}
 */
Vector4.simd.store = function(vector) {
    SIMD.Float32x4.store(vector.storage, 0, vector.simd_storage);
};

/**
 * @property x
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("x", function() {
    return this.storage[0];
});
Vector4.prototype.__defineSetter__("x", function(value) {
    this.storage[0] = value;
});

/**
 * @property y
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("y", function() {
    return this.storage[1];
});
Vector4.prototype.__defineSetter__("y", function(value) {
    this.storage[1] = value;
});

/**
 * @property z
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("z", function() {
    return this.storage[2];
});
Vector4.prototype.__defineSetter__("z", function(value) {
    this.storage[2] = value;
});

/**
 * @property w
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("w", function() {
    return this.storage[3];
});
Vector4.prototype.__defineSetter__("w", function(value) {
    this.storage[3] = value;
});

/**
 * @property length
 * @type {number}
 */
Vector4.prototype.__defineGetter__("length", function() {
    return Math.sqrt(this.length2());
});
Vector4.prototype.__defineSetter__("length", function(value) {
    if (vector_math.USE_SIMD()) {
        Vector4.simd._setter_length(this, value);
    }
    else {
        Vector4.scalar._setter_length(this, value);
    }
});

/**
 * @static
 * Scalar version of set length
 * @param vector {Vector3}
 * @param value {Number}
 * @private
 */
Vector4.scalar._setter_length = function(vector, value) {
    if (value == 0.0) {
        vector.setZero();
    }
    else {
        var l = this.length;
        if (l == 0.0) {
            return;
        }
        l = value / l;
        vector.storage[0] *= l;
        vector.storage[1] *= l;
        vector.storage[2] *= l;
        vector.storage[3] *= l;
    }
};

Vector4.simd._setter_length = function(vector, value) {
    if (value == 0.0) {<commit_msg>(Vector4) : Fix one data type on length comment<commit_after>/**
 * Created by grizet_j on 9/21/2015.
 */
module.exports = Vector4;

var vector_math = require('./common.js');
var SIMD = require("simd");

/**
 * @class Vector4
 * @param x {Number}
 * @param y {Number}
 * @param z {Number}
 * @param w {Number}
 * @constructor
 */
function Vector4(x, y, z, w){
    /**
     * @property storage
     * @type {Float32Array}
     */
    this.storage = new Float32Array([x, y, z, w]);
    /**
     * @property simd_storage
     * @type {null|Float32x4}
     */
    this.simd_storage = null;
}

/**
 * @static
 * SIMD specialization
 */
Vector4.simd = {};
/**
 * @static
 * Scalar specialization
 */
Vector4.scalar = {};

/**
 * @static
 * Load SIMD.Float32x4 into vector.simd_storage
 * @param vector {Vector4}
 */
Vector4.simd.load = function(vector) {
    vector.simd_storage = SIMD.Float32x4.load(vector.storage, 0);
};

/**
 * @static
 * Store SIMD.Float32x4 at vector.simd_storage into vector.storage
 * @param vector {Vector4}
 */
Vector4.simd.store = function(vector) {
    SIMD.Float32x4.store(vector.storage, 0, vector.simd_storage);
};

/**
 * @property x
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("x", function() {
    return this.storage[0];
});
Vector4.prototype.__defineSetter__("x", function(value) {
    this.storage[0] = value;
});

/**
 * @property y
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("y", function() {
    return this.storage[1];
});
Vector4.prototype.__defineSetter__("y", function(value) {
    this.storage[1] = value;
});

/**
 * @property z
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("z", function() {
    return this.storage[2];
});
Vector4.prototype.__defineSetter__("z", function(value) {
    this.storage[2] = value;
});

/**
 * @property w
 * @type {Number}
 */
Vector4.prototype.__defineGetter__("w", function() {
    return this.storage[3];
});
Vector4.prototype.__defineSetter__("w", function(value) {
    this.storage[3] = value;
});

/**
 * @property length
 * @type {number}
 */
Vector4.prototype.__defineGetter__("length", function() {
    return Math.sqrt(this.length2());
});
Vector4.prototype.__defineSetter__("length", function(value) {
    if (vector_math.USE_SIMD()) {
        Vector4.simd._setter_length(this, value);
    }
    else {
        Vector4.scalar._setter_length(this, value);
    }
});

/**
 * @static
 * Scalar version of set length
 * @param vector {Vector4}
 * @param value {Number}
 * @private
 */
Vector4.scalar._setter_length = function(vector, value) {
    if (value == 0.0) {
        vector.setZero();
    }
    else {
        var l = this.length;
        if (l == 0.0) {
            return;
        }
        l = value / l;
        vector.storage[0] *= l;
        vector.storage[1] *= l;
        vector.storage[2] *= l;
        vector.storage[3] *= l;
    }
};

Vector4.simd._setter_length = function(vector, value) {
    if (value == 0.0) {
{'fraction_non_alphanumeric': 0.17678145243777701, 'fraction_numerical': 0.02437777020115922, 'mean_word_length': 3.094207955338451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4575540', 'n_tokens_mistral': 2087, 'n_tokens_neox': 2034, 'n_words': 399}