time-to-botec/squiggle/node_modules/jstat/test/linearalgebra/norm-test.js
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

30 lines
720 B
JavaScript

var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('jStat');
require('../env.js');
suite.addBatch({
'linearalgebra': {
'topic': function() {
return jStat;
},
'p-norm works for vector defaults to p = 2': function(jStat) {
var A = jStat([[3, 4]]);
assert.equal(A.norm(), 5);
var B = jStat([[-3, 4]]);
assert.equal(B.norm(), 5);
},
'p norm works for vector with p = 1': function(jStat) {
var A = jStat([[1, 2, 3]]);
assert.equal(A.norm(1), 6);
},
'p norm works for a matrix with p = 2': function(jStat) {
var A = jStat([[3, 4], [1, 2]]);
assert.equal(A.norm(), 5);
}
}
});
suite.export(module);