@stdlib/blas-ext-base-gfill-by 0.2.0 → 0.2.2
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 +1 -1
- package/README.md +21 -38
- package/dist/index.js +7 -7
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +13 -13
- package/lib/accessors.js +7 -7
- package/lib/main.js +6 -27
- package/lib/ndarray.js +7 -7
- package/package.json +7 -31
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -53,9 +53,9 @@ npm install @stdlib/blas-ext-base-gfill-by
|
|
|
53
53
|
var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
#### gfillBy( N, x,
|
|
56
|
+
#### gfillBy( N, x, strideX, clbk\[, thisArg] )
|
|
57
57
|
|
|
58
|
-
Fills a strided array
|
|
58
|
+
Fills a strided array according to a provided callback function.
|
|
59
59
|
|
|
60
60
|
```javascript
|
|
61
61
|
function fill( v, i ) {
|
|
@@ -71,17 +71,17 @@ gfillBy( x.length, x, 1, fill );
|
|
|
71
71
|
The function has the following parameters:
|
|
72
72
|
|
|
73
73
|
- **N**: number of indexed elements.
|
|
74
|
-
- **x**: input array.
|
|
75
|
-
- **
|
|
74
|
+
- **x**: input array.
|
|
75
|
+
- **strideX**: stride length.
|
|
76
76
|
- **clbk**: callback function.
|
|
77
77
|
- **thisArg**: execution context (_optional_).
|
|
78
78
|
|
|
79
|
-
The
|
|
79
|
+
The callback function is provided the following arguments:
|
|
80
80
|
|
|
81
|
-
- **value**: array element.
|
|
81
|
+
- **value**: current array element.
|
|
82
82
|
- **aidx**: array index.
|
|
83
83
|
- **sidx**: strided index (`offset + aidx*stride`).
|
|
84
|
-
- **array**: input array
|
|
84
|
+
- **array**: the input array.
|
|
85
85
|
|
|
86
86
|
To set the callback execution context, provide a `thisArg`.
|
|
87
87
|
|
|
@@ -104,19 +104,16 @@ var cnt = context.count;
|
|
|
104
104
|
// returns 8
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
The `N` and
|
|
107
|
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to fill every other element:
|
|
108
108
|
|
|
109
109
|
```javascript
|
|
110
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
111
|
-
|
|
112
110
|
function fill( v, i ) {
|
|
113
111
|
return v * i;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
|
|
117
|
-
var N = floor( x.length / 2 );
|
|
118
115
|
|
|
119
|
-
gfillBy(
|
|
116
|
+
gfillBy( 4, x, 2, fill );
|
|
120
117
|
// x => [ 0.0, 1.0, 3.0, -5.0, 8.0, 0.0, -3.0, -3.0 ]
|
|
121
118
|
```
|
|
122
119
|
|
|
@@ -124,7 +121,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
|
|
|
124
121
|
|
|
125
122
|
```javascript
|
|
126
123
|
var Float64Array = require( '@stdlib/array-float64' );
|
|
127
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
128
124
|
|
|
129
125
|
function fill( v, i ) {
|
|
130
126
|
return v * i;
|
|
@@ -135,16 +131,15 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
|
|
|
135
131
|
|
|
136
132
|
// Create an offset view...
|
|
137
133
|
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
|
|
138
|
-
var N = floor( x0.length/2 );
|
|
139
134
|
|
|
140
135
|
// Fill every other element...
|
|
141
|
-
gfillBy(
|
|
136
|
+
gfillBy( 3, x1, 2, fill );
|
|
142
137
|
// x0 => <Float64Array>[ 1.0, 0.0, 3.0, -4.0, 5.0, -12.0 ]
|
|
143
138
|
```
|
|
144
139
|
|
|
145
|
-
#### gfillBy.ndarray( N, x,
|
|
140
|
+
#### gfillBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
|
|
146
141
|
|
|
147
|
-
Fills a strided array
|
|
142
|
+
Fills a strided array according to a provided callback function and using alternative indexing semantics.
|
|
148
143
|
|
|
149
144
|
```javascript
|
|
150
145
|
function fill( v, i ) {
|
|
@@ -159,9 +154,9 @@ gfillBy.ndarray( x.length, x, 1, 0, fill );
|
|
|
159
154
|
|
|
160
155
|
The function has the following additional parameters:
|
|
161
156
|
|
|
162
|
-
- **
|
|
157
|
+
- **offsetX**: starting index.
|
|
163
158
|
|
|
164
|
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying
|
|
159
|
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements:
|
|
165
160
|
|
|
166
161
|
```javascript
|
|
167
162
|
function fill( v, i ) {
|
|
@@ -197,26 +192,14 @@ gfillBy.ndarray( 3, x, 1, x.length-3, fill );
|
|
|
197
192
|
<!-- eslint no-undef: "error" -->
|
|
198
193
|
|
|
199
194
|
```javascript
|
|
200
|
-
var
|
|
201
|
-
var randu = require( '@stdlib/random-base-randu' );
|
|
195
|
+
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
|
|
202
196
|
var Float64Array = require( '@stdlib/array-float64' );
|
|
203
197
|
var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );
|
|
204
198
|
|
|
205
|
-
function fill() {
|
|
206
|
-
var rand = round( randu()*100.0 );
|
|
207
|
-
var sign = randu();
|
|
208
|
-
if ( sign < 0.5 ) {
|
|
209
|
-
sign = -1.0;
|
|
210
|
-
} else {
|
|
211
|
-
sign = 1.0;
|
|
212
|
-
}
|
|
213
|
-
return sign * rand;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
199
|
var x = new Float64Array( 10 );
|
|
217
200
|
console.log( x );
|
|
218
201
|
|
|
219
|
-
gfillBy( x.length, x, 1,
|
|
202
|
+
gfillBy( x.length, x, 1, discreteUniform( -100, 100 ) );
|
|
220
203
|
console.log( x );
|
|
221
204
|
```
|
|
222
205
|
|
|
@@ -264,7 +247,7 @@ See [LICENSE][stdlib-license].
|
|
|
264
247
|
|
|
265
248
|
## Copyright
|
|
266
249
|
|
|
267
|
-
Copyright © 2016-
|
|
250
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
268
251
|
|
|
269
252
|
</section>
|
|
270
253
|
|
|
@@ -277,8 +260,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
277
260
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-gfill-by.svg
|
|
278
261
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-gfill-by
|
|
279
262
|
|
|
280
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-gfill-by/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
281
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-gfill-by/actions/workflows/test.yml?query=branch:v0.2.
|
|
263
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-gfill-by/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
264
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-gfill-by/actions/workflows/test.yml?query=branch:v0.2.2
|
|
282
265
|
|
|
283
266
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-gfill-by/main.svg
|
|
284
267
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-gfill-by?branch=main
|
|
@@ -290,8 +273,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
290
273
|
|
|
291
274
|
-->
|
|
292
275
|
|
|
293
|
-
[chat-image]: https://img.shields.io/
|
|
294
|
-
[chat-url]: https://
|
|
276
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
277
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
295
278
|
|
|
296
279
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
297
280
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var l=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var
|
|
2
|
-
function
|
|
3
|
-
});var
|
|
4
|
-
var
|
|
5
|
-
});var
|
|
6
|
-
var
|
|
7
|
-
});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g
|
|
1
|
+
"use strict";var l=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=l(function(D,y){
|
|
2
|
+
function b(e,r,t,u,c,n){var a,i,s,o,v;for(a=r.data,s=r.accessors[0],i=r.accessors[1],o=u,v=0;v<e;v++)i(a,o,c.call(n,s(a,o),v,o,r)),o+=t;return r}y.exports=b
|
|
3
|
+
});var f=l(function(E,d){
|
|
4
|
+
var j=require('@stdlib/array-base-arraylike2object/dist'),m=q();function O(e,r,t,u,c,n){var a,i,s;if(e<=0)return r;if(i=j(r),i.accessorProtocol)return m(e,i,t,u,c,n),i.data;for(a=u,s=0;s<e;s++)r[a]=c.call(n,r[a],s,a,r),a+=t;return r}d.exports=O
|
|
5
|
+
});var g=l(function(F,p){
|
|
6
|
+
var P=require('@stdlib/strided-base-stride2offset/dist'),R=f();function k(e,r,t,u,c){return R(e,r,t,P(e,t),u,c)}p.exports=k
|
|
7
|
+
});var w=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),B=g(),z=f();w(B,"ndarray",z);module.exports=B;
|
|
8
8
|
/** @license Apache-2.0 */
|
|
9
9
|
/** @license Apache-2.0 */
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../lib/accessors.js", "../lib/
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Fills a strided array according to a provided callback function.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array<Function>} x.accessors - array element accessors\n* @param {integer}
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiEA,SAASC,EAASC,EAAGC,EAAGC,
|
|
6
|
-
"names": ["require_accessors", "__commonJSMin", "exports", "module", "gfillBy", "N", "x", "
|
|
3
|
+
"sources": ["../lib/accessors.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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* Fills a strided array according to a provided callback function.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array<Function>} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - execution context\n* @returns {Object} input array object\n*\n* @example\n* var Complex64Array = require( '@stdlib/array-complex64' );\n* var Complex64 = require( '@stdlib/complex-float32-ctor' );\n* var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ getter, setter ]\n* };\n*\n* function clbk() {\n* return new Complex64( 5.0, 5.0 );\n* }\n*\n* gfillBy( data.length, x, 1, 0, clbk, void 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // view => <Float32Array>[ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar xbuf;\n\tvar set;\n\tvar get;\n\tvar ix;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( xbuf, ix, clbk.call( thisArg, get( xbuf, ix ), i, ix, x ) );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gfillBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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 arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar accessors = require( './accessors.js' );\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( 3, x, 1, x.length-3, fill );\n* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar ix;\n\tvar o;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, o, strideX, offsetX, clbk, thisArg );\n\t\treturn o.data;\n\t}\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tx[ ix ] = clbk.call( thisArg, x[ ix ], i, ix, x );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = gfillBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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 stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, clbk, thisArg ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = gfillBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 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* Fill a strided array according to a provided callback function.\n*\n* @module @stdlib/blas-ext-base-gfill-by\n*\n* @example\n* var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*\n* @example\n* var gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy.ndarray( x.length, x, 1, 0, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiEA,SAASC,EAASC,EAAGC,EAAGC,EAASC,EAASC,EAAMC,EAAU,CACzD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAUJ,IAPAJ,EAAOL,EAAE,KAGTO,EAAMP,EAAE,UAAW,CAAE,EACrBM,EAAMN,EAAE,UAAW,CAAE,EAErBQ,EAAKN,EACCO,EAAI,EAAGA,EAAIV,EAAGU,IACnBH,EAAKD,EAAMG,EAAIL,EAAK,KAAMC,EAASG,EAAKF,EAAMG,CAAG,EAAGC,EAAGD,EAAIR,CAAE,CAAE,EAC/DQ,GAAMP,EAEP,OAAOD,CACR,CAKAH,EAAO,QAAUC,IC1FjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAY,IA0BhB,SAASC,EAASC,EAAGC,EAAGC,EAASC,EAASC,EAAMC,EAAU,CACzD,IAAIC,EACAC,EACAC,EAEJ,GAAKR,GAAK,EACT,OAAOC,EAGR,GADAM,EAAIV,EAAkBI,CAAE,EACnBM,EAAE,iBACN,OAAAT,EAAWE,EAAGO,EAAGL,EAASC,EAASC,EAAMC,CAAQ,EAC1CE,EAAE,KAGV,IADAD,EAAKH,EACCK,EAAI,EAAGA,EAAIR,EAAGQ,IACnBP,EAAGK,CAAG,EAAIF,EAAK,KAAMC,EAASJ,EAAGK,CAAG,EAAGE,EAAGF,EAAIL,CAAE,EAChDK,GAAMJ,EAEP,OAAOD,CACR,CAKAL,EAAO,QAAUG,ICzEjB,IAAAU,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAyBd,SAASC,EAASC,EAAGC,EAAGC,EAASC,EAAMC,EAAU,CAChD,OAAON,EAASE,EAAGC,EAAGC,EAASL,EAAeG,EAAGE,CAAQ,EAAGC,EAAMC,CAAQ,CAC3E,CAKAR,EAAO,QAAUG,ICHjB,IAAIM,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_accessors", "__commonJSMin", "exports", "module", "gfillBy", "N", "x", "strideX", "offsetX", "clbk", "thisArg", "xbuf", "set", "get", "ix", "i", "require_ndarray", "__commonJSMin", "exports", "module", "arraylike2object", "accessors", "gfillBy", "N", "x", "strideX", "offsetX", "clbk", "thisArg", "ix", "o", "i", "require_main", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "gfillBy", "N", "x", "strideX", "clbk", "thisArg", "setReadOnly", "main", "ndarray"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -98,8 +98,8 @@ interface Routine {
|
|
|
98
98
|
*
|
|
99
99
|
* @param N - number of indexed elements
|
|
100
100
|
* @param x - input array
|
|
101
|
-
* @param
|
|
102
|
-
* @param clbk - callback
|
|
101
|
+
* @param strideX - stride length
|
|
102
|
+
* @param clbk - callback function
|
|
103
103
|
* @param thisArg - execution context
|
|
104
104
|
* @returns `x`
|
|
105
105
|
*
|
|
@@ -111,9 +111,9 @@ interface Routine {
|
|
|
111
111
|
* }
|
|
112
112
|
*
|
|
113
113
|
* gfillBy( x.length, x, 1, fill );
|
|
114
|
-
* // x => [ 5.0, 5.0, 5.0,
|
|
114
|
+
* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
115
115
|
*/
|
|
116
|
-
<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<V>,
|
|
116
|
+
<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<V>, strideX: number, clbk: Callback<T, U, V, W>, thisArg?: ThisParameterType<Callback<T, U, V, W>> ): Collection<U | V>;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Fills a strided array according to a provided callback function and using alternative indexing semantics.
|
|
@@ -131,9 +131,9 @@ interface Routine {
|
|
|
131
131
|
*
|
|
132
132
|
* @param N - number of indexed elements
|
|
133
133
|
* @param x - input array
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @param clbk - callback
|
|
134
|
+
* @param strideX - stride length
|
|
135
|
+
* @param offsetX - starting index
|
|
136
|
+
* @param clbk - callback function
|
|
137
137
|
* @param thisArg - execution context
|
|
138
138
|
* @returns `x`
|
|
139
139
|
*
|
|
@@ -145,9 +145,9 @@ interface Routine {
|
|
|
145
145
|
* }
|
|
146
146
|
*
|
|
147
147
|
* gfillBy.ndarray( x.length, x, 1, 0, fill );
|
|
148
|
-
* // x => [ 5.0, 5.0, 5.0,
|
|
148
|
+
* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
149
149
|
*/
|
|
150
|
-
ndarray<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<V>,
|
|
150
|
+
ndarray<T = unknown, U = unknown, V = unknown, W = unknown>( N: number, x: Collection<V>, strideX: number, offsetX: number, clbk: Callback<T, U, V, W>, thisArg?: ThisParameterType<Callback<T, U, V, W>> ): Collection<U | V>;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
@@ -166,8 +166,8 @@ interface Routine {
|
|
|
166
166
|
*
|
|
167
167
|
* @param N - number of indexed elements
|
|
168
168
|
* @param x - input array
|
|
169
|
-
* @param
|
|
170
|
-
* @param clbk - callback
|
|
169
|
+
* @param strideX - stride length
|
|
170
|
+
* @param clbk - callback function
|
|
171
171
|
* @param thisArg - execution context
|
|
172
172
|
* @returns `x`
|
|
173
173
|
*
|
|
@@ -179,7 +179,7 @@ interface Routine {
|
|
|
179
179
|
* }
|
|
180
180
|
*
|
|
181
181
|
* gfillBy( x.length, x, 1, fill );
|
|
182
|
-
* // x => [ 5.0, 5.0, 5.0,
|
|
182
|
+
* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
183
183
|
*
|
|
184
184
|
* @example
|
|
185
185
|
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
|
|
@@ -189,7 +189,7 @@ interface Routine {
|
|
|
189
189
|
* }
|
|
190
190
|
*
|
|
191
191
|
* gfillBy.ndarray( x.length, x, 1, 0, fill );
|
|
192
|
-
* // x => [ 5.0, 5.0, 5.0,
|
|
192
|
+
* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
193
193
|
*/
|
|
194
194
|
declare var gfillBy: Routine;
|
|
195
195
|
|
package/lib/accessors.js
CHANGED
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
* @param {Object} x - input array object
|
|
29
29
|
* @param {Collection} x.data - input array data
|
|
30
30
|
* @param {Array<Function>} x.accessors - array element accessors
|
|
31
|
-
* @param {integer}
|
|
32
|
-
* @param {NonNegativeInteger}
|
|
33
|
-
* @param {Callback} clbk - callback
|
|
31
|
+
* @param {integer} strideX - stride length
|
|
32
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
33
|
+
* @param {Callback} clbk - callback function
|
|
34
34
|
* @param {*} thisArg - execution context
|
|
35
35
|
* @returns {Object} input array object
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
39
|
-
* var Complex64 = require( '@stdlib/complex-float32' );
|
|
39
|
+
* var Complex64 = require( '@stdlib/complex-float32-ctor' );
|
|
40
40
|
* var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
41
41
|
*
|
|
42
42
|
* function setter( data, idx, value ) {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* var view = reinterpret64( x.data, 0 );
|
|
64
64
|
* // view => <Float32Array>[ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
65
65
|
*/
|
|
66
|
-
function gfillBy( N, x,
|
|
66
|
+
function gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {
|
|
67
67
|
var xbuf;
|
|
68
68
|
var set;
|
|
69
69
|
var get;
|
|
@@ -77,10 +77,10 @@ function gfillBy( N, x, stride, offset, clbk, thisArg ) {
|
|
|
77
77
|
get = x.accessors[ 0 ];
|
|
78
78
|
set = x.accessors[ 1 ];
|
|
79
79
|
|
|
80
|
-
ix =
|
|
80
|
+
ix = offsetX;
|
|
81
81
|
for ( i = 0; i < N; i++ ) {
|
|
82
82
|
set( xbuf, ix, clbk.call( thisArg, get( xbuf, ix ), i, ix, x ) );
|
|
83
|
-
ix +=
|
|
83
|
+
ix += strideX;
|
|
84
84
|
}
|
|
85
85
|
return x;
|
|
86
86
|
}
|
package/lib/main.js
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
24
|
-
var
|
|
23
|
+
var stride2offset = require( '@stdlib/strided-base-stride2offset' );
|
|
24
|
+
var ndarray = require( './ndarray.js' );
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
// MAIN //
|
|
@@ -31,8 +31,8 @@ var accessors = require( './accessors.js' );
|
|
|
31
31
|
*
|
|
32
32
|
* @param {PositiveInteger} N - number of indexed elements
|
|
33
33
|
* @param {Collection} x - input array
|
|
34
|
-
* @param {integer}
|
|
35
|
-
* @param {Callback} clbk - callback
|
|
34
|
+
* @param {integer} strideX - stride length
|
|
35
|
+
* @param {Callback} clbk - callback function
|
|
36
36
|
* @param {*} [thisArg] - execution context
|
|
37
37
|
* @returns {Collection} input array
|
|
38
38
|
*
|
|
@@ -46,29 +46,8 @@ var accessors = require( './accessors.js' );
|
|
|
46
46
|
* gfillBy( x.length, x, 1, fill );
|
|
47
47
|
* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
|
|
48
48
|
*/
|
|
49
|
-
function gfillBy( N, x,
|
|
50
|
-
|
|
51
|
-
var o;
|
|
52
|
-
var i;
|
|
53
|
-
|
|
54
|
-
if ( N <= 0 ) {
|
|
55
|
-
return x;
|
|
56
|
-
}
|
|
57
|
-
if ( stride < 0 ) {
|
|
58
|
-
ix = (1-N) * stride;
|
|
59
|
-
} else {
|
|
60
|
-
ix = 0;
|
|
61
|
-
}
|
|
62
|
-
o = arraylike2object( x );
|
|
63
|
-
if ( o.accessorProtocol ) {
|
|
64
|
-
accessors( N, o, stride, ix, clbk, thisArg );
|
|
65
|
-
return o.data;
|
|
66
|
-
}
|
|
67
|
-
for ( i = 0; i < N; i++ ) {
|
|
68
|
-
x[ ix ] = clbk.call( thisArg, x[ ix ], i, ix, x );
|
|
69
|
-
ix += stride;
|
|
70
|
-
}
|
|
71
|
-
return x;
|
|
49
|
+
function gfillBy( N, x, strideX, clbk, thisArg ) {
|
|
50
|
+
return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
|
|
72
51
|
}
|
|
73
52
|
|
|
74
53
|
|
package/lib/ndarray.js
CHANGED
|
@@ -31,9 +31,9 @@ var accessors = require( './accessors.js' );
|
|
|
31
31
|
*
|
|
32
32
|
* @param {PositiveInteger} N - number of indexed elements
|
|
33
33
|
* @param {Collection} x - input array
|
|
34
|
-
* @param {integer}
|
|
35
|
-
* @param {NonNegativeInteger}
|
|
36
|
-
* @param {Callback} clbk - callback
|
|
34
|
+
* @param {integer} strideX - stride length
|
|
35
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
36
|
+
* @param {Callback} clbk - callback function
|
|
37
37
|
* @param {*} [thisArg] - execution context
|
|
38
38
|
* @returns {Collection} input array
|
|
39
39
|
*
|
|
@@ -47,7 +47,7 @@ var accessors = require( './accessors.js' );
|
|
|
47
47
|
* gfillBy( 3, x, 1, x.length-3, fill );
|
|
48
48
|
* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]
|
|
49
49
|
*/
|
|
50
|
-
function gfillBy( N, x,
|
|
50
|
+
function gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {
|
|
51
51
|
var ix;
|
|
52
52
|
var o;
|
|
53
53
|
var i;
|
|
@@ -57,13 +57,13 @@ function gfillBy( N, x, stride, offset, clbk, thisArg ) {
|
|
|
57
57
|
}
|
|
58
58
|
o = arraylike2object( x );
|
|
59
59
|
if ( o.accessorProtocol ) {
|
|
60
|
-
accessors( N, o,
|
|
60
|
+
accessors( N, o, strideX, offsetX, clbk, thisArg );
|
|
61
61
|
return o.data;
|
|
62
62
|
}
|
|
63
|
-
ix =
|
|
63
|
+
ix = offsetX;
|
|
64
64
|
for ( i = 0; i < N; i++ ) {
|
|
65
65
|
x[ ix ] = clbk.call( thisArg, x[ ix ], i, ix, x );
|
|
66
|
-
ix +=
|
|
66
|
+
ix += strideX;
|
|
67
67
|
}
|
|
68
68
|
return x;
|
|
69
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-ext-base-gfill-by",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Fill a strided array according to a provided callback function.",
|
|
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
|
-
"
|
|
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,27 +30,11 @@
|
|
|
37
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
31
|
},
|
|
39
32
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-base-arraylike2object": "^0.2.
|
|
41
|
-
"@stdlib/
|
|
42
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@stdlib/array-base-filled-by": "^0.1.0",
|
|
46
|
-
"@stdlib/array-complex128": "^0.1.0",
|
|
47
|
-
"@stdlib/array-float64": "^0.2.0",
|
|
48
|
-
"@stdlib/complex-float64": "^0.2.0",
|
|
49
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.0",
|
|
50
|
-
"@stdlib/math-base-special-pow": "^0.2.0",
|
|
51
|
-
"@stdlib/math-base-special-round": "^0.2.0",
|
|
52
|
-
"@stdlib/random-base-randu": "^0.1.0",
|
|
53
|
-
"@stdlib/random-base-uniform": "^0.1.0",
|
|
54
|
-
"@stdlib/strided-base-reinterpret-complex128": "^0.2.0",
|
|
55
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
56
|
-
"istanbul": "^0.4.1",
|
|
57
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
58
|
-
"@stdlib/bench-harness": "^0.2.0",
|
|
59
|
-
"@stdlib/bench": "^0.3.1"
|
|
33
|
+
"@stdlib/array-base-arraylike2object": "^0.2.1",
|
|
34
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
35
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2"
|
|
60
36
|
},
|
|
37
|
+
"devDependencies": {},
|
|
61
38
|
"engines": {
|
|
62
39
|
"node": ">=0.10.0",
|
|
63
40
|
"npm": ">2.7.0"
|
|
@@ -91,7 +68,6 @@
|
|
|
91
68
|
"array",
|
|
92
69
|
"ndarray"
|
|
93
70
|
],
|
|
94
|
-
"__stdlib__": {},
|
|
95
71
|
"funding": {
|
|
96
72
|
"type": "opencollective",
|
|
97
73
|
"url": "https://opencollective.com/stdlib"
|