@stdlib/array-base-strided2array3d 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2023 The Stdlib Authors.
1
+ Copyright (c) 2016-2024 The Stdlib Authors.
package/README.md CHANGED
@@ -156,7 +156,7 @@ See [LICENSE][stdlib-license].
156
156
 
157
157
  ## Copyright
158
158
 
159
- Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
159
+ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
160
160
 
161
161
  </section>
162
162
 
@@ -169,8 +169,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
169
169
  [npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-strided2array3d.svg
170
170
  [npm-url]: https://npmjs.org/package/@stdlib/array-base-strided2array3d
171
171
 
172
- [test-image]: https://github.com/stdlib-js/array-base-strided2array3d/actions/workflows/test.yml/badge.svg?branch=v0.1.0
173
- [test-url]: https://github.com/stdlib-js/array-base-strided2array3d/actions/workflows/test.yml?query=branch:v0.1.0
172
+ [test-image]: https://github.com/stdlib-js/array-base-strided2array3d/actions/workflows/test.yml/badge.svg?branch=v0.2.1
173
+ [test-url]: https://github.com/stdlib-js/array-base-strided2array3d/actions/workflows/test.yml?query=branch:v0.2.1
174
174
 
175
175
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-strided2array3d/main.svg
176
176
  [coverage-url]: https://codecov.io/github/stdlib-js/array-base-strided2array3d?branch=main
@@ -193,8 +193,11 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
193
193
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
194
194
 
195
195
  [deno-url]: https://github.com/stdlib-js/array-base-strided2array3d/tree/deno
196
+ [deno-readme]: https://github.com/stdlib-js/array-base-strided2array3d/blob/deno/README.md
196
197
  [umd-url]: https://github.com/stdlib-js/array-base-strided2array3d/tree/umd
198
+ [umd-readme]: https://github.com/stdlib-js/array-base-strided2array3d/blob/umd/README.md
197
199
  [esm-url]: https://github.com/stdlib-js/array-base-strided2array3d/tree/esm
200
+ [esm-readme]: https://github.com/stdlib-js/array-base-strided2array3d/blob/esm/README.md
198
201
  [branches-url]: https://github.com/stdlib-js/array-base-strided2array3d/blob/main/branches.md
199
202
 
200
203
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-strided2array3d/main/LICENSE
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var b=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var q=b(function(l,m){
2
- function g(t,r,i,y){var u,f,n,s,c,o,p,S,h,x,a,v,d,e;for(h=r[0],S=r[1],p=r[2],s=i[0],n=i[1],f=i[2],u=[],v=0;v<h;v++){for(d=[],c=y+s*v,a=0;a<S;a++){for(e=[],o=c+n*a,x=0;x<p;x++)e.push(t[o]),o+=f;d.push(e)}u.push(d)}return u}m.exports=g
3
- });var j=q();module.exports=j;
1
+ "use strict";var y=function(a,r){return function(){return r||a((r={exports:{}}).exports,r),r.exports}};var l=y(function(w,h){
2
+ var G=require('@stdlib/array-base-resolve-getter/dist');function b(a,r,e,m){var d,i,f,n,c,p,u,S,q,g,o,v,t,x,s;for(d=G(a),g=r[0],q=r[1],S=r[2],c=e[0],n=e[1],f=e[2],i=[],t=0;t<g;t++){for(x=[],p=m+c*t,v=0;v<q;v++){for(s=[],u=p+n*v,o=0;o<S;o++)s.push(d(a,u)),u+=f;x.push(s)}i.push(x)}return i}h.exports=b
3
+ });var j=l();module.exports=j;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a strided array to a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array<Array<Array>>} three-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\nfunction strided2array3d( x, shape, strides, offset ) {\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar t2;\n\tvar t1;\n\n\tS2 = shape[ 0 ];\n\tS1 = shape[ 1 ];\n\tS0 = shape[ 2 ];\n\n\tdx2 = strides[ 0 ];\n\tdx1 = strides[ 1 ];\n\tdx0 = strides[ 2 ];\n\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tt2 = [];\n\t\tix1 = offset + ( dx2*i2 );\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tt1 = [];\n\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tt1.push( x[ ix0 ] );\n\t\t\t\tix0 += dx0;\n\t\t\t}\n\t\t\tt2.push( t1 );\n\t\t}\n\t\tout.push( t2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = strided2array3d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert a strided array to a three-dimensional nested array.\n*\n* @module @stdlib/array-base-strided2array3d\n*\n* @example\n* var strided2array3d = require( '@stdlib/array-base-strided2array3d' );\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+CA,SAASC,EAAiBC,EAAGC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAWJ,IATAL,EAAKX,EAAO,CAAE,EACdU,EAAKV,EAAO,CAAE,EACdS,EAAKT,EAAO,CAAE,EAEdM,EAAML,EAAS,CAAE,EACjBI,EAAMJ,EAAS,CAAE,EACjBG,EAAMH,EAAS,CAAE,EAEjBE,EAAM,CAAC,EACDW,EAAK,EAAGA,EAAKH,EAAIG,IAAO,CAG7B,IAFAC,EAAK,CAAC,EACNR,EAAML,EAAWI,EAAIQ,EACfD,EAAK,EAAGA,EAAKH,EAAIG,IAAO,CAG7B,IAFAG,EAAK,CAAC,EACNR,EAAMD,EAAQF,EAAIQ,EACZD,EAAK,EAAGA,EAAKH,EAAIG,IACtBI,EAAG,KAAMjB,EAAGS,CAAI,CAAE,EAClBA,GAAOJ,EAERW,EAAG,KAAMC,CAAG,CACb,CACAb,EAAI,KAAMY,CAAG,CACd,CACA,OAAOZ,CACR,CAKAN,EAAO,QAAUC,ICrDjB,IAAImB,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "strided2array3d", "x", "shape", "strides", "offset", "out", "dx0", "dx1", "dx2", "ix1", "ix0", "S0", "S1", "S2", "i0", "i1", "i2", "t2", "t1", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveGetter = require( '@stdlib/array-base-resolve-getter' );\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array<Array<Array>>} three-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\nfunction strided2array3d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS2 = shape[ 0 ];\n\tS1 = shape[ 1 ];\n\tS0 = shape[ 2 ];\n\n\tdx2 = strides[ 0 ];\n\tdx1 = strides[ 1 ];\n\tdx0 = strides[ 2 ];\n\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tt2 = [];\n\t\tix1 = offset + ( dx2*i2 );\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tt1 = [];\n\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\tix0 += dx0;\n\t\t\t}\n\t\t\tt2.push( t1 );\n\t\t}\n\t\tout.push( t2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = strided2array3d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert a strided array to a three-dimensional nested array.\n*\n* @module @stdlib/array-base-strided2array3d\n*\n* @example\n* var strided2array3d = require( '@stdlib/array-base-strided2array3d' );\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EA8BjE,SAASC,EAAiBC,EAAGC,EAAOC,EAASC,EAAS,CACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAaJ,IAXAd,EAAMN,EAAeE,CAAE,EAEvBa,EAAKZ,EAAO,CAAE,EACdW,EAAKX,EAAO,CAAE,EACdU,EAAKV,EAAO,CAAE,EAEdO,EAAMN,EAAS,CAAE,EACjBK,EAAML,EAAS,CAAE,EACjBI,EAAMJ,EAAS,CAAE,EAEjBG,EAAM,CAAC,EACDW,EAAK,EAAGA,EAAKH,EAAIG,IAAO,CAG7B,IAFAC,EAAK,CAAC,EACNR,EAAMN,EAAWK,EAAIQ,EACfD,EAAK,EAAGA,EAAKH,EAAIG,IAAO,CAG7B,IAFAG,EAAK,CAAC,EACNR,EAAMD,EAAQF,EAAIQ,EACZD,EAAK,EAAGA,EAAKH,EAAIG,IACtBI,EAAG,KAAMd,EAAKJ,EAAGU,CAAI,CAAE,EACvBA,GAAOJ,EAERW,EAAG,KAAMC,CAAG,CACb,CACAb,EAAI,KAAMY,CAAG,CACd,CACA,OAAOZ,CACR,CAKAR,EAAO,QAAUE,IC7DjB,IAAIoB,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "strided2array3d", "x", "shape", "strides", "offset", "get", "out", "dx0", "dx1", "dx2", "ix1", "ix0", "S0", "S1", "S2", "i0", "i1", "i2", "t2", "t1", "main"]
7
7
  }
package/lib/main.js CHANGED
@@ -18,6 +18,11 @@
18
18
 
19
19
  'use strict';
20
20
 
21
+ // MODULES //
22
+
23
+ var resolveGetter = require( '@stdlib/array-base-resolve-getter' );
24
+
25
+
21
26
  // MAIN //
22
27
 
23
28
  /**
@@ -46,6 +51,7 @@
46
51
  * // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]
47
52
  */
48
53
  function strided2array3d( x, shape, strides, offset ) {
54
+ var get;
49
55
  var out;
50
56
  var dx0;
51
57
  var dx1;
@@ -61,6 +67,8 @@ function strided2array3d( x, shape, strides, offset ) {
61
67
  var t2;
62
68
  var t1;
63
69
 
70
+ get = resolveGetter( x );
71
+
64
72
  S2 = shape[ 0 ];
65
73
  S1 = shape[ 1 ];
66
74
  S0 = shape[ 2 ];
@@ -77,7 +85,7 @@ function strided2array3d( x, shape, strides, offset ) {
77
85
  t1 = [];
78
86
  ix0 = ix1 + ( dx1*i1 );
79
87
  for ( i0 = 0; i0 < S0; i0++ ) {
80
- t1.push( x[ ix0 ] );
88
+ t1.push( get( x, ix0 ) );
81
89
  ix0 += dx0;
82
90
  }
83
91
  t2.push( t1 );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-base-strided2array3d",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Convert a strided array to a three-dimensional nested array.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -15,19 +15,12 @@
15
15
  ],
16
16
  "main": "./lib",
17
17
  "directories": {
18
- "benchmark": "./benchmark",
19
18
  "doc": "./docs",
20
- "example": "./examples",
21
19
  "lib": "./lib",
22
- "test": "./test"
20
+ "dist": "./dist"
23
21
  },
24
22
  "types": "./docs/types",
25
- "scripts": {
26
- "test": "make test",
27
- "test-cov": "make test-cov",
28
- "examples": "make examples",
29
- "benchmark": "make benchmark"
30
- },
23
+ "scripts": {},
31
24
  "homepage": "https://stdlib.io",
32
25
  "repository": {
33
26
  "type": "git",
@@ -37,21 +30,9 @@
37
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
31
  },
39
32
  "dependencies": {
40
- "@stdlib/types": "^0.2.0"
41
- },
42
- "devDependencies": {
43
- "@stdlib/array-base-zero-to": "^0.1.0",
44
- "@stdlib/bench": "^0.2.0",
45
- "@stdlib/math-base-assert-is-nan": "^0.1.1",
46
- "@stdlib/math-base-special-floor": "^0.1.1",
47
- "@stdlib/math-base-special-pow": "^0.1.0",
48
- "@stdlib/ndarray-base-numel": "^0.1.1",
49
- "@stdlib/ndarray-base-shape2strides": "^0.1.1",
50
- "@stdlib/ndarray-orders": "^0.1.1",
51
- "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
52
- "istanbul": "^0.4.1",
53
- "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
33
+ "@stdlib/array-base-resolve-getter": "^0.2.0"
54
34
  },
35
+ "devDependencies": {},
55
36
  "engines": {
56
37
  "node": ">=0.10.0",
57
38
  "npm": ">2.7.0"
package/CITATION.cff DELETED
@@ -1,30 +0,0 @@
1
- cff-version: 1.2.0
2
- title: stdlib
3
- message: >-
4
- If you use this software, please cite it using the
5
- metadata from this file.
6
-
7
- type: software
8
-
9
- authors:
10
- - name: The Stdlib Authors
11
- url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
-
13
- repository-code: https://github.com/stdlib-js/stdlib
14
- url: https://stdlib.io
15
-
16
- abstract: |
17
- Standard library for JavaScript and Node.js.
18
-
19
- keywords:
20
- - JavaScript
21
- - Node.js
22
- - TypeScript
23
- - standard library
24
- - scientific computing
25
- - numerical computing
26
- - statistical computing
27
-
28
- license: Apache-2.0 AND BSL-1.0
29
-
30
- date-released: 2016