kalman icon indicating copy to clipboard operation
kalman copied to clipboard

Converting to bower component

Open FreakTheMighty opened this issue 10 years ago • 2 comments

I've made your library into a bower component so that its easier for other people to install and would like to make a merge request. At the moment, though, your test isn't passing.

https://github.com/htmlfusion/kalman

Despite adding the same version of sylvester (0.1.3) as is used in your test, there appears to be a slight different between them. The difference lies in the determinant function.

The version installed in your test directory looks like so:

  // Returns the determinant for square matrices
  determinant: function() {
    if (this.elements.length === 0) { return 1; }
    if (!this.isSquare()) { return null; }
    var M = this.toRightTriangular();
    var det = M.elements[0][0], n = M.elements.length;
    for (var i = 1; i < n; i++) {
      det = det * M.elements[i][i];
    }
    return det;
  },

While the version installed by bower looks like:

  // Returns the determinant for square matrices
  determinant: function() {
    if (!this.isSquare()) { return null; }
    var M = this.toRightTriangular();
    var det = M.elements[0][0], n = M.elements.length - 1, k = n, i;
    do { i = k - n + 1;
      det = det * M.elements[i][i];
    } while (--n);
    return det;
  },

This is the only difference between the two files and results in the following error.

 Uncaught TypeError: Cannot read property '1' of undefined
sylvester.src.js:586
Matrix.determinantsylvester.src.js:595 
Matrix.isSingularsylvester.src.js:643
Matrix.inversekalman.js:49
KalmanModel.updatetest.html:23 (anonymous function)

FreakTheMighty avatar Feb 19 '15 04:02 FreakTheMighty

Yes. The problem in the new sylvester code is that it seems to crash for a 1x1 matrix. So basically it seems like there is a bug in their new code...

itamarwe avatar Feb 19 '15 07:02 itamarwe

I see, perhaps the fix was made in a later version. If not I'll just leave the one you've packaged.

FreakTheMighty avatar Feb 19 '15 16:02 FreakTheMighty