Gathering detailed insights and metrics for @stdlib/ndarray-base-bind2vind
Gathering detailed insights and metrics for @stdlib/ndarray-base-bind2vind
Gathering detailed insights and metrics for @stdlib/ndarray-base-bind2vind
Gathering detailed insights and metrics for @stdlib/ndarray-base-bind2vind
Convert a linear index in an underlying data buffer to a linear index in an array view.
npm install @stdlib/ndarray-base-bind2vind
Typescript
Module System
Min. Node Version
Node Version
NPM Version
65.7
Supply Chain
81.1
Quality
81.5
Maintenance
100
Vulnerability
87.6
License
C (52.57%)
JavaScript (47.43%)
Total Downloads
4,689
Last Day
11
Last Week
35
Last Month
100
Last Year
813
Apache-2.0 License
1 Stars
64 Commits
3 Watchers
5 Branches
14 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
0.2.2
Package Id
@stdlib/ndarray-base-bind2vind@0.2.2
Unpacked Size
40.01 kB
Size
10.67 kB
File Count
14
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 28, 2024
Cumulative downloads
Total Downloads
Last Day
1,000%
11
Compared to previous day
Last Week
337.5%
35
Compared to previous week
Last Month
3.1%
100
Compared to previous month
Last Year
-35.3%
813
Compared to previous year
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Convert a linear index in an underlying data buffer to a linear index in an array view.
1npm install @stdlib/ndarray-base-bind2vind
1var bind2vind = require( '@stdlib/ndarray-base-bind2vind' );
Converts a linear index in an underlying data buffer to a linear index in an array view.
1var shape = [ 3, 3 ]; 2var order = 'row-major'; 3var strides = [ -3, 1 ]; 4var offset = 6; 5 6var idx = bind2vind( shape, strides, offset, order, 7, 'throw' ); 7// returns 1
The function supports the following modes:
0
(minimum linear index) or the maximum linear index.1var shape = [ 2, 2 ]; 2var order = 'row-major'; 3var strides = [ -2, 1 ]; 4var offset = 2; 5 6var idx = bind2vind( shape, strides, offset, order, -2, 'wrap' ); 7// returns 0 8 9idx = bind2vind( shape, strides, offset, order, 10, 'clamp' ); 10// returns 1
The order
parameter specifies whether an array is row-major
(C-style) or column-major
(Fortran-style).
1var shape = [ 2, 2 ]; 2var order = 'column-major'; 3var strides = [ 1, -2 ]; 4var offset = 2; 5 6var idx = bind2vind( shape, strides, offset, order, 2, 'throw' ); 7// returns 0
1var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); 2var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); 3var numel = require( '@stdlib/ndarray-base-numel' ); 4var randu = require( '@stdlib/random-base-randu' ); 5var bind2vind = require( '@stdlib/ndarray-base-bind2vind' ); 6 7// Specify array meta data: 8var shape = [ 3, 3, 3 ]; 9var order = 'row-major'; 10 11// Compute array meta data: 12var len = numel( shape ); 13var strides = shape2strides( shape, order ); 14 15// Randomly flip the sign of strides... 16var i; 17for ( i = 0; i < shape.length; i++ ) { 18 if ( randu() < 0.5 ) { 19 strides[ i ] *= -1; 20 } 21} 22 23// Compute the underlying data buffer index offset: 24var offset = strides2offset( shape, strides ); 25 26// Print array info: 27console.log( 'Dims: %s', shape.join( 'x' ) ); 28console.log( 'Strides: %s', strides.join( ',' ) ); 29console.log( 'Offset: %d', offset ); 30 31// For each underlying data buffer index, determine the corresponding index into an array view... 32var ind; 33for ( i = 0; i < len; i++ ) { 34 ind = bind2vind( shape, strides, offset, order, i, 'throw' ); 35 console.log( 'buffer[%d] => view[%d]', i, ind ); 36}
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More