Sha256: 082a93055e49e26dcf0640d7d089eb5ad377c9c41df843d54218ca63d89b66fa

Contents?: true

Size: 1.41 KB

Versions: 19

Compression:

Stored size: 1.41 KB

Contents

(function() {
  Math.gaussianElimination = function(_A, v) {
    var A, a, c, i, index, j, k, l, len, m, maxEl, maxRow, n, o, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, s, tmp, value, x;
    A = (function() {
      var l, len, results;
      results = [];
      for (l = 0, len = _A.length; l < len; l++) {
        a = _A[l];
        results.push(a.slice(0));
      }
      return results;
    })();
    if (v != null) {
      for (index = l = 0, len = v.length; l < len; index = ++l) {
        value = v[index];
        A[index].push(value);
      }
    }
    n = A.length;
    for (k = m = 0, ref = n; m < ref; k = m += 1) {
      maxEl = Math.abs(A[k][k]);
      maxRow = k;
      for (i = o = ref1 = k + 1, ref2 = n; o < ref2; i = o += 1) {
        if (Math.abs(A[k][i]) > maxEl) {
          maxEl = Math.abs(A[k][i]);
          maxRow = i;
        }
      }
      tmp = A[k];
      A[k] = A[maxRow];
      A[maxRow] = tmp;
      for (i = p = ref3 = k + 1, ref4 = n; p < ref4; i = p += 1) {
        c = -A[i][k] / A[k][k];
        A[i][k] = 0;
        for (j = q = ref5 = k + 1, ref6 = n; q <= ref6; j = q += 1) {
          A[i][j] += c * A[k][j];
        }
      }
    }
    x = new Array(n);
    for (k = r = ref7 = n - 1; r >= 0; k = r += -1) {
      x[k] = A[k][n] / A[k][k];
      for (i = s = ref8 = k - 1; s >= 0; i = s += -1) {
        A[i][n] -= A[i][k] * x[k];
      }
    }
    return x;
  };

}).call(this);

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 dist/app_js/vendor/gaussianElimination.js
ela-4.1.5 dist/app_js/vendor/gaussianElimination.js
ela-4.1.4 dist/app_js/vendor/gaussianElimination.js
ela-4.1.3 dist/app_js/vendor/gaussianElimination.js
ela-4.1.2 dist/app_js/vendor/gaussianElimination.js
ela-4.1.1 dist/app_js/vendor/gaussianElimination.js
ela-4.1.0 dist/app_js/vendor/gaussianElimination.js
ela-4.0.0 dist/app_js/vendor/gaussianElimination.js
ela-3.4.3 dist/app_js/vendor/gaussianElimination.js
ela-3.4.2 dist/app_js/vendor/gaussianElimination.js
ela-3.4.0 dist/app_js/vendor/gaussianElimination.js
ela-3.3.1 dist/app_js/vendor/gaussianElimination.js
ela-3.3.0 dist/app_js/vendor/gaussianElimination.js
ela-3.2.0 dist/app_js/vendor/gaussianElimination.js
ela-3.1.1 dist/app_js/vendor/gaussianElimination.js
ela-3.1.0 dist/app_js/vendor/gaussianElimination.js
ela-3.0.0 dist/app_js/vendor/gaussianElimination.js
ela-2.0.0 dist/app_js/vendor/gaussianElimination.js
ela-1.1.0 dist/app_js/vendor/gaussianElimination.js