nv-mat-sparse

    0.0.2 • Public • Published

    nv-mat-sparse

    • nv-mat-sparse, small-sparse-mat

    install

    • npm install nv-mat-sparse

    usage

    example

    const mat_bsc = require('nv-mat-sparse')
    

    MM0

     const {MM0,load_mm0_from_json} = require("nv-mat-sparse")
    
     var m = new MM0()
     m.set_if_exist_else_add(0,0,'A')
     m.set_if_exist_else_add(10,0,'A')
     > m.locs_
     [ [ 0, 0 ], [ 10, 0 ] ]
     > m.get(0,0)
     'A'
     > m.get(10,0)
     'A'
     >
     > m.values_
     [ 'A', 'A' ]
    
     m.set_if_exist_else_add(2,3,'B')
    
     > Array.from(m)
     [ [ 0, 0, 'A' ], [ 10, 0, 'A' ], [ 2, 3, 'B' ] ]
     >
     > m.pop(2,2)
     Symbol(noexist)
     > m.pop(2,3)
     'B'
    
     > m
     [ [ 0, 0, 'A' ], [ 10, 0, 'A' ] ]
     >
     > load_mm0_from_json([ [ 0, 0, 'A' ], [ 10, 0, 'A' ] ])
     [ [ 0, 0, 'A' ], [ 10, 0, 'A' ] ]
     >
    
    m.map((src,dst,val)=>val+':'+src+':'+dst)
    > m.map((src,dst,val)=>val+':'+src+':'+dst)
    [ [ 0, 0, 'A:0:0' ], [ 10, 0, 'A:10:0' ] ]
    >
    > m
    [ [ 0, 0, 'A' ], [ 10, 0, 'A' ] ]
    >
    
    > m.map_inplace((src,dst,val)=>val+':'+src+':'+dst)
    [ [ 0, 0, 'A:0:0' ], [ 10, 0, 'A:10:0' ] ]
    > m
    [ [ 0, 0, 'A:0:0' ], [ 10, 0, 'A:10:0' ] ]
    >
    
    > m.filter((src,dst,val)=>src===10)
    [ [ 10, 0, 'A:10:0' ] ]
    >
    

    METHODS

    m.init_                  m.locs_                  m.mat_
    m.size_                  m.json 
    m.iter                   m.reduce
    m.map                    m.map_inplace            m.filter
    
    m.row
    m.has_row  
    
    m.init_row
    m.empty_row
    m.del_row
    
    m.has_loc
    m.add_loc
    
    m.add 
    m.del
    m.pop
    
    m.is_empty
    m.empty                                
    
    
    m.is_init
    m.init
    
    m.get
    m.has_val 
    m.get_locs 
    m.set
    m.set_if_exist_else_add
    m.values()
    

    LICENSE

    • ISC

    Keywords

    Install

    npm i nv-mat-sparse

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    ISC

    Unpacked Size

    8.92 kB

    Total Files

    3

    Last publish

    Collaborators

    • ihgazni2