time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

norm-test.js (720B)


      1 var vows = require('vows');
      2 var assert = require('assert');
      3 var suite = vows.describe('jStat');
      4 
      5 require('../env.js');
      6 
      7 suite.addBatch({
      8   'linearalgebra': {
      9     'topic': function() {
     10       return jStat;
     11     },
     12     'p-norm works for vector defaults to p = 2': function(jStat) {
     13       var A = jStat([[3, 4]]);
     14       assert.equal(A.norm(), 5);
     15       var B = jStat([[-3, 4]]);
     16       assert.equal(B.norm(), 5);
     17     },
     18     'p norm works for vector with p = 1': function(jStat) {
     19       var A = jStat([[1, 2, 3]]);
     20       assert.equal(A.norm(1), 6);
     21     },
     22     'p norm works for a matrix with p = 2': function(jStat) {
     23       var A = jStat([[3, 4], [1, 2]]);
     24       assert.equal(A.norm(), 5);
     25     }
     26   }
     27 });
     28 
     29 suite.export(module);