8000 Auto-generated commit · stdlib-js/ndarray-base-bind2vind@42cc3c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 42cc3c2

Browse files
committed
Auto-generated commit
1 parent bd99c82 commit 42cc3c2

File tree

16 files changed

+729
-63
lines changed
  • lib
  • src
  • test
  • 16 files changed

    +729
    -63
    lines changed

    .editorconfig

    Lines changed: 0 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -148,11 +148,6 @@ indent_size = 2
    148148
    indent_style = space
    149149
    indent_size = 2
    150150

    151-
    # Set properties for `tslint.json` files:
    152-
    [tslint.json]
    153-
    indent_style = space
    154-
    indent_size = 2
    155-
    156151
    # Set properties for `tsconfig.json` files:
    157152
    [tsconfig.json]
    158153
    indent_style = space

    .github/.keepalive

    Lines changed: 0 additions & 1 deletion
    This file was deleted.

    .github/workflows/publish.yml

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -119,7 +119,7 @@ jobs:
    119119
    # For all dependencies, check in all *.js files if they are still used; if not, remove them:
    120120
    jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do
    121121
    dep=$(echo "$dep" | xargs)
    122-
    if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" includ 8000 e.gypi; then
    122+
    if ! find lib -name "*.js" -exec grep -q "$dep" {} + && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
    123123
    jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp
    124124
    mv ./package.json.tmp ./package.json
    125125
    fi
    @@ -129,7 +129,7 @@ jobs:
    129129
    continue
    130130
    fi
    131131
    dep=$(echo "$dep" | xargs)
    132-
    if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
    132+
    if ! find lib -name "*.js" -exec grep -q "$dep" {} + && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
    133133
    jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp
    134134
    mv ./package.json.tmp ./package.json
    135135
    fi

    CONTRIBUTORS

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -9,6 +9,7 @@ Brendan Graetz <bguiz@users.noreply.github.com>
    99
    Bruno Fenzl <brunofenzl@gmail.com>
    1010
    Christopher Dambamuromo <chridam@gmail.com>
    1111
    Dan Rose <danoftheroses@gmail.com>
    12+
    Daniel Killenberger <daniel.killenberger@gmail.com>
    1213
    Dominik Moritz <domoritz@gmail.com>
    1314
    Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
    1415
    Frank Kovacs <fran70kk@gmail.com>
    @@ -29,6 +30,7 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
    2930
    Philipp Burckhardt <pburckhardt@outlook.com>
    3031
    Pranav Goswami <goswami.4@iitj.ac.in>
    3132
    Ricky Reusser <rsreusser@gmail.com>
    33+
    Robert Gislason <gztown2216@yahoo.com>
    3234
    Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
    3335
    Ryan Seal <splrk@users.noreply.github.com>
    3436
    Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
    @@ -37,4 +39,3 @@ Stephannie Jiménez Gacha <steff456@hotmail.com>
    3739
    Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
    3840
    orimiles5 <97595296+orimiles5@users.noreply.github.com>
    3941
    rei2hu <reimu@reimu.ws>
    40-
    Robert Gislason <gztown2216@yahoo.com>

    README.md

    Lines changed: 5 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -85,11 +85,12 @@ var idx = bind2vind( shape, strides, offset, order, 7, 'throw' );
    8585
    // returns 1
    8686
    ```
    8787

    88-
    The function supports the following `modes`:
    88+
    The function supports the following modes:
    8989

    90-
    - `throw`: specifies that the function should throw an error when a linear index exceeds array dimensions.
    91-
    - `wrap`: specifies that the function should wrap around a linear index exceeding array dimensions using modulo arithmetic.
    92-
    - `clamp`: specifies that the function should set a linear index exceeding array dimensions to either `0` (minimum linear index) or the maximum linear index.
    90+
    - **throw**: specifies that the function should throw an error when a linear index exceeds array dimensions.
    91+
    - **normalize**: specifies that the function should normalize negative indices and should throw an error when a linear index exceeds array dimensions.
    92+
    - **wrap**: specifies that the function should wrap around a linear index exceeding array dimensions using modulo arithmetic.
    93+
    - **clamp**: specifies that the function should set a linear index exceeding array dimensions to either `0` (minimum linear index) or the maximum linear index.
    9394

    9495
    ```javascript
    9596
    var shape = [ 2, 2 ];

    benchmark/benchmark.js

    Lines changed: 130 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -422,3 +422,133 @@ bench( pkg+':mode=clamp,offset=0,order=column-major', function benchmark( b ) {
    422422
    b.pass( 'benchmark finished' );
    423423
    b.end();
    424424
    });
    425+
    426+
    bench( pkg+':mode=normalize,order=row-major', function benchmark( b ) {
    427+
    var strides;
    428+
    var offset;
    429+
    var shape;
    430+
    var order;
    431+
    var out;
    432+
    var len;
    433+
    var idx;
    434+
    var i;
    435+
    436+
    shape = [ 10, 10, 10 ];
    437+
    order = 'row-major';
    438+
    strides = shape2strides( shape, order );
    439+
    strides[ 1 ] *= -1;
    440+
    offset = strides2offset( shape, strides );
    441+
    len = numel( shape );
    442+
    443+
    b.tic();
    444+
    for ( i = 0; i < b.iterations; i++ ) {
    445+
    idx = floor( randu()*len*2.0 ) - len;
    446+
    out = bind2vind( shape, strides, offset, order, idx, 'normalize' );
    447+
    if ( out !== out ) {
    448+
    b.fail( 'should not return NaN' );
    449+
    }
    450+
    }
    451+
    b.toc();
    452+
    if ( !isInteger( out ) ) {
    453+
    b.fail( 'should return an integer' );
    454+
    }
    455+
    b.pass( 'benchmark finished' );
    456+
    b.end();
    457+
    });
    458+
    459+
    bench( pkg+':mode=normalize,order=column-major', function benchmark( b ) {
    460+
    var strides;
    461+
    var offset;
    462+
    var shape;
    463+
    var order;
    464+
    var out;
    465+
    var len;
    466+
    var idx;
    467+
    var i;
    468+
    469+
    shape = [ 10, 10, 10 ];
    470+
    order = 'column-major';
    471+
    strides = shape2strides( shape, order );
    472+
    strides[ 1 ] *= -1;
    473+
    offset = strides2offset( shape, strides );
    474+
    len = numel( shape );
    475+
    476+
    b.tic();
    477+
    for ( i = 0; i < b.iterations; i++ ) {
    478+
    idx = floor( randu()*len*2.0 ) - len;
    479+
    out = bind2vind( shape, strides, offset, order, idx, 'normalize' );
    480+
    if ( out !== out ) {
    481+
    b.fail( 'should not return NaN' );
    482+
    }
    483+
    }
    484+
    b.toc();
    485+
    if ( !isInteger( out ) ) {
    486+
    b.fail( 'should return an integer' );
    487+
    }
    488+
    b.pass( 'benchmark finished' );
    489+
    b.end();
    490+
    });
    491+
    492+
    bench( pkg+':mode=normalize,offset=0,order=row-major', function benchmark( b ) {
    493+
    var strides;
    494+
    var offset;
    495+
    var shape;
    496+
    var order;
    497+
    var out;
    498+
    var len;
    499+
    var idx;
    500+
    var i;
    501+
    502+
    shape = [ 10, 10, 10 ];
    503+
    order = 'row-major';
    504+
    strides = shape2strides( shape, order );
    505+
    offset = strides2offset( shape, strides );
    506+
    len = numel( shape );
    507+
    508+
    b.tic();
    509+
    for ( i = 0; i < b.iterations; i++ ) {
    510+
    idx = floor( randu()*len*2.0 ) - len;
    511+
    out = bind2vind( shape, strides, offset, order, idx, 'normalize' );
    512+
    if ( out !== out ) {
    513+
    b.fail( 'should not return NaN' );
    514+
    }
    515+
    }
    516+
    b.toc();
    517+
    if ( !isInteger( out ) ) {
    518+
    b.fail( 'should return an integer' );
    519+
    }
    520+
    b.pass( 'benchmark finished' );
    521+
    b.end();
    522+
    });
    523+
    524+
    bench( pkg+':mode=normalize,offset=0,order=column-major', function benchmark( b ) {
    525+
    var strides;
    526+
    var offset;
    527+
    var shape;
    528+
    var order;
    529+
    var out;
    530+
    var len;
    531+
    var idx;
    532+
    var i;
    533+
    534+
    shape = [ 10, 10, 10 ];
    535+
    order = 'column-major';
    536+
    strides = shape2strides( shape, order );
    537+
    offset = strides2offset( shape, strides );
    538+
    len = numel( shape );
    539+
    540+
    b.tic();
    541+
    for ( i = 0; i < b.iterations; i++ ) {
    542+
    idx = floor( randu()*len*2.0 ) - len;
    543+
    out = bind2vind( shape, strides, offset, order, idx, 'normalize' );
    544+
    if ( out !== out ) {
    545+
    b.fail( 'should not return NaN' );
    546+
    }
    547+
    }
    548+
    b.toc();
    549+
    if ( !isInteger( out ) ) {
    550+
    b.fail( 'should return an integer' );
    551+
    }
    552+
    b.pass( 'benchmark finished' );
    553+
    b.end();
    554+
    });

    0 commit comments

    Comments
     (0)
    0