How to use the qminer.la.Matrix function in qminer

To help you get started, we’ve selected a few qminer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 24", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a matrix
	 var mat = new la.Matrix([[1, -3, 2], [9, 2, -4],  [-2, 3, 3]]);
	 // create a vector
	 var vec = new la.Vector([-3, 2, 2]);
	 // set the first column of the matrix with the vector
	 // the changed matrix is now
	 // -3   -3    2
	 //  2    2   -4
	 //  2    3    3
	 mat.setCol(0, vec);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc_structures.js View on Github external
it("should make test number 24", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a matrix
	 var mat = new la.Matrix([[1, -3, 2], [9, 2, -4],  [-2, 3, 3]]);
	 // create a vector
	 var vec = new la.Vector([-3, 2, 2]);
	 // set the first column of the matrix with the vector
	 // the changed matrix is now
	 // -3   -3    2
	 //  2    2   -4
	 //  2    3    3
	 mat.setCol(0, vec);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc_structures.js View on Github external
it("should make test number 10", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create two matrices
	 var mat = new la.Matrix([[1, 2], [-1, 5]]);
	 var mat2 = new la.Matrix([[1, -1], [3, 2]]);
	 // substract the matrices
	 // the return matrix is
	 //  0   3
	 // -4   3
	 var diff = mat.minus(mat2);
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 64", function () {

     // import la module
     var la = require('qminer').la;
     // create four matrices and concatenate (2 block columns, 2 block rows)
     var la = require('qminer').la;
     var A = new la.Matrix([[1,2], [3,4]]);
     var B = new la.Matrix([[5,6], [7,8]]);
     var C = new la.Matrix([[9,10], [11,12]]);
     var D = new la.Matrix([[13,14], [15,16]]);
     var mat = la.cat([[A,B], [C,D]]);
     // returns the matrix:
     // 1  2  5  6
     // 3  4  7  8
     // 9  10 13 14
     // 11 12 15 16
    
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 6", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a new matrix
	 var mat = new la.Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
	 var arg = new la.Matrix([[10, 11], [12, 13]]);
	 mat.put(0, 1, arg);
	 // updates the matrix to
     // 1  10  11
     // 4  12  13
     // 7   8   9   
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 20", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create the matrix
	 var mat = new la.Matrix([[1, 2], [3, 1], [-4, 5]]);
	 // get the number of cols
	 var colsN = mat.cols; // returns 2
	
});
});
github qminer / qminer / test / nodejs / exampleladoc_structures.js View on Github external
it("should make test number 27", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a new matrix
	 var mat = new la.Matrix([[1, -1, 0], [15, 8, 3], [0, 1, 0]]);
	 // call diag function
	 var vec = mat.diag(); // returns a vector [1, 8, 0]
	
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 67", function () {

     // import la module
     var la = require('qminer').la;
     // construct two input matrices
     var X1 = new la.Matrix([[1,2], [2,0]]);
     var X2 = new la.Matrix([[1,0.5,0],[0,-0.5,-1]]);
     la.pdist2(X1, X2)
     // returns the matrix:
     // 4 6.5 10
     // 1 2.5 5
    
});
});
github qminer / qminer / test / nodejs / exampleladoc.js View on Github external
it("should make test number 27", function () {

	 // import la module
	 var la = require('qminer').la;
	 // create a new matrix
	 var mat = new la.Matrix([[1, -1, 0], [15, 8, 3], [0, 1, 0]]);
	 // call diag function
	 var vec = mat.diag(); // returns a vector [1, 8, 0]
	
});
});
github qminer / qminer / test / nodejs / pca.js View on Github external
it("should return a result using transform with vector", function () {
            var pca = new analytics.PCA();
            var matrix = new la.Matrix([[0, 1], [-1, 0]]);
            pca.fit(matrix);
            var vec = new la.Vector([0, -1]);
            var tran = pca.transform(vec);
            assert.eqtol(tran.at(0, 0), -0.707106781186547, 1e-6);
            assert.eqtol(tran.at(1, 0), 0, 1e-6);
        });
        it("should throw and exception because matrix dimensions don't match", function () {