<commit_before>'use strict';

var cwise = require('cwise');

exports.swap = cwise({
  args: ['array', 'array'],
  body: function(a,b) {
    var tmp = a;
    a = b;
    b = tmp;
  }
});

exports.scal = cwise({
  args: ['scalar', 'array'],
  body: function(alpha,x) {
    x *= alpha;
  }
});

exports.copy = cwise({
  args: ['array', 'array'],
  body: function(x,y) {
    y = x;
  }
});

exports.axpy = cwise({
  args:['scalar', 'array', 'array'],
  body: function(alpha, x, y) {
    y += alpha * x;
  }
});

exports.dot = cwise({
  args:['array', 'array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a,b) {
    this.sum += a * b;
  },
  post: function() {
    return this.sum;
  }
});

exports.cpsc = cwise({
  args:['scalar', 'array', 'array'],
  body: function(alpha, x, y) {
    y = alpha * x;
  }
});

exports.nrm2 = cwise({
  args:['array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a) {
    this.sum += a * a;
  },
  post: function() {
    return Math.sqrt(this.sum);
  }
});

exports.asum = cwise({
  args:['array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a) {
    this.sum += Math.abs(a);
  },
  post: function() {
    return this.sum;
  }
});

exports.iamax = cwise({
  args:['array'],
  pre: function() {
    this.maxValue = Number.NEGATIVE_INFINITY;
    this.maxIndex = 0;
    this.index = 0;
  },
  body: function(a) {
    if (a > this.maxValue) {
        this.maxValue = a;
        this.maxIndex = this.index;
    }
    this.index++;
  },
  post: function() {
    return this.maxIndex;
  }
});<commit_msg>[FIX] index of first max absolute value<commit_after>'use strict';

var cwise = require('cwise');

exports.swap = cwise({
  args: ['array', 'array'],
  body: function(a,b) {
    var tmp = a;
    a = b;
    b = tmp;
  }
});

exports.scal = cwise({
  args: ['scalar', 'array'],
  body: function(alpha,x) {
    x *= alpha;
  }
});

exports.copy = cwise({
  args: ['array', 'array'],
  body: function(x,y) {
    y = x;
  }
});

exports.axpy = cwise({
  args:['scalar', 'array', 'array'],
  body: function(alpha, x, y) {
    y += alpha * x;
  }
});

exports.dot = cwise({
  args:['array', 'array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a,b) {
    this.sum += a * b;
  },
  post: function() {
    return this.sum;
  }
});

exports.cpsc = cwise({
  args:['scalar', 'array', 'array'],
  body: function(alpha, x, y) {
    y = alpha * x;
  }
});

exports.nrm2 = cwise({
  args:['array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a) {
    this.sum += a * a;
  },
  post: function() {
    return Math.sqrt(this.sum);
  }
});

exports.asum = cwise({
  args:['array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a) {
    this.sum += Math.abs(a);
  },
  post: function() {
    return this.sum;
  }
});

exports.iamax = cwise({
  args:['array'],
  pre: function() {
    this.maxValue = 0;
    this.maxIndex = 0;
    this.index = 0;
  },
  body: function(a) {
    if (Math.abs(a) > this.maxValue) {
        this.maxValue = a;
        this.maxIndex = this.index;
    }
    this.index++;
  },
  post: function() {
    return this.maxIndex;
  }
});
{'fraction_non_alphanumeric': 0.21385637456501108, 'fraction_numerical': 0.004112622587788674, 'mean_word_length': 2.5250836120401337, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1228707', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1264, 'n_words': 274}