Giter Club home page Giter Club logo

underscore-matrix's Introduction

underscore-matrix

Module which contains the standard operation of the square matrices.

Version

0.1.0

Installation

$ npm install underscore-matrix

Initialization

var _matrix = require("underscore-matrix");

Functions

  • Determinant

  • Summary

  • Scalar summary

  • Multiply

  • Scalar multiply

  • Matrix inversion

  • Minor

  • Identity matrix

  • Check is array square matrix

    ###Determinant

    _matrix.determinant(matrix);
    

    It will return object:

    {
        error:"Some error message",  //or false if no errors
        value:1.23                   //Float number - determinant of matrix (can be undefinde if error)
    }

    ###Summary

    _matrix.summary(matrixA,matrixB);
    //or
    _matrix.sum(matrixA,matrixB);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Result matrix with float numbers - summary of matrixA and matrixB (can be undefinde if error)
    }

    IMPORTANT! 'matrixA' and 'matrixB' must be square with the same size ###Scalar summary

    _matrix.sSummary(scalarNumber,matrix);
    //or
    _matrix.ssum(scalarNumber,matrix);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Result matrix with float numbers - summary of scalarNumber and matrix (can be undefinde if error)
    }

    Sample:

    var sum = _matrix.ssum(1,[
        [1,2,3],
        [4,5,6],
        [7,8,9]
    ]).value;
    
    //sum = [
    //          [2,3,4],
    //          [5,6,7],
    //          [8,9,10]
    //      ]

    ###Multiply

    _matrix.multiply(matrixA,matrixB);
    //or
    _matrix.mult(matrixA,matrixB);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Result matrix with float numbers - multiply of matrixA*matrixB (can be undefinde if error)
    }

    IMPORTANT! 'matrixA' and 'matrixB' must be square with the same size ###Scalar multiply

    _matrix.sMultiply(scalarNumber,matrix);
    //or
    _matrix.smul(scalarNumber,matrix);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Result matrix with float numbers - multiply of scalarNumber and matrix (can be undefinde if error)
    }

    Sample:

    var mul = _matrix.ssum(2,[
        [1,2,3],
        [4,5,6],
        [7,8,9]
    ]).value;
    
    //mul = [
    //          [2,4,6],
    //          [8,10,12],
    //          [14,16,18]
    //      ]

    ###Matrix inversion

    _matrix.inverse(matrix);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Inverse of a matrix (can be undefinde if error)
    }

    IMPORTANT! determinant of matrix can't be 0 ###Minor Return minor of matrix

    _matrix.minor(di,dj,matrix);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,1,1],[2,2,2],[3,3,3]]   //Minor matrix or undefinde if error
    }

    Sample:

    var minor = _matrix.minor(0,1,[
                                    [1,2,3],
                                    [11,12,13],
                                    [21,22,23]
                                ]).value;
    
    // minor = [ 
    //          [ 11, 13 ], 
    //          [ 21, 23 ] 
    //        ]

    ###Identity matrix

    _matrix.I(n);

    It will return object:

    {
        error:"Some error message",       //or false if no errors
        value:[[1,0,0],[0,1,0],[0,0,1]]   //n-size identity matrix (can be undefinde if error)
    }

    ###Check is array square matrix

    _matrix.isSquareMatrix(matrix);

    It will return object:

    {
        error:"Some error message",       //or false if matrix is square
        value:[[1,1,1],[2,2,2],[3,3,3]]   //matrix 
    }

    If some of matrix elements is numeric string, this function will convert them to float numbers and return matrix with only float type elements.

License

MIT

####Enjoy!

underscore-matrix's People

Contributors

voogryk avatar

Stargazers

Viacheslav Shabelnyk avatar

Watchers

Viacheslav Shabelnyk avatar

underscore-matrix's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.