@stdlib/stats-base-cumin 0.2.1 → 0.3.0

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-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -75,11 +75,11 @@ The function has the following parameters:
75
75
 
76
76
  - **N**: number of indexed elements.
77
77
  - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
78
- - **strideX**: index increment for `x`.
78
+ - **strideX**: stride length for `x`.
79
79
  - **y**: output [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
80
- - **strideY**: index increment for `y`.
80
+ - **strideY**: stride length for `y`.
81
81
 
82
- The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative minimum of every other element in `x`,
82
+ The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative minimum of every other element in `x`,
83
83
 
84
84
  ```javascript
85
85
  var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
@@ -125,7 +125,7 @@ The function has the following additional parameters:
125
125
  - **offsetX**: starting index for `x`.
126
126
  - **offsetY**: starting index for `y`.
127
127
 
128
- While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element
128
+ While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element
129
129
 
130
130
  ```javascript
131
131
  var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
@@ -144,7 +144,8 @@ cumin.ndarray( 4, x, 2, 1, y, -1, y.length-1 );
144
144
  ## Notes
145
145
 
146
146
  - If `N <= 0`, both functions return `y` unchanged.
147
- - Depending on the environment, the typed versions ([`dcumin`][@stdlib/stats/base/dcumin], [`scumin`][@stdlib/stats/base/scumin], etc.) are likely to be significantly more performant.
147
+ - Depending on the environment, the typed versions ([`dcumin`][@stdlib/stats/strided/dcumin], [`scumin`][@stdlib/stats/strided/scumin], etc.) are likely to be significantly more performant.
148
+ - Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-base/accessor`][@stdlib/array/base/accessor]).
148
149
 
149
150
  </section>
150
151
 
@@ -157,20 +158,14 @@ cumin.ndarray( 4, x, 2, 1, y, -1, y.length-1 );
157
158
  <!-- eslint no-undef: "error" -->
158
159
 
159
160
  ```javascript
160
- var randu = require( '@stdlib/random-base-randu' );
161
- var round = require( '@stdlib/math-base-special-round' );
162
161
  var Float64Array = require( '@stdlib/array-float64' );
162
+ var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
163
163
  var cumin = require( '@stdlib/stats-base-cumin' );
164
164
 
165
- var y;
166
- var x;
167
- var i;
168
-
169
- x = new Float64Array( 10 );
170
- y = new Float64Array( x.length );
171
- for ( i = 0; i < x.length; i++ ) {
172
- x[ i ] = round( randu()*100.0 );
173
- }
165
+ var x = discreteUniform( 10, 0, 100, {
166
+ 'dtype': 'float64'
167
+ });
168
+ var y = new Float64Array( x.length );
174
169
  console.log( x );
175
170
  console.log( y );
176
171
 
@@ -197,8 +192,8 @@ console.log( y );
197
192
  ## See Also
198
193
 
199
194
  - <span class="package-name">[`@stdlib/stats-base/cumax`][@stdlib/stats/base/cumax]</span><span class="delimiter">: </span><span class="description">calculate the cumulative maximum of a strided array.</span>
200
- - <span class="package-name">[`@stdlib/stats-base/dcumin`][@stdlib/stats/base/dcumin]</span><span class="delimiter">: </span><span class="description">calculate the cumulative minimum of double-precision floating-point strided array elements.</span>
201
- - <span class="package-name">[`@stdlib/stats-base/scumin`][@stdlib/stats/base/scumin]</span><span class="delimiter">: </span><span class="description">calculate the cumulative minimum of single-precision floating-point strided array elements.</span>
195
+ - <span class="package-name">[`@stdlib/stats-strided/dcumin`][@stdlib/stats/strided/dcumin]</span><span class="delimiter">: </span><span class="description">calculate the cumulative minimum of double-precision floating-point strided array elements.</span>
196
+ - <span class="package-name">[`@stdlib/stats-strided/scumin`][@stdlib/stats/strided/scumin]</span><span class="delimiter">: </span><span class="description">calculate the cumulative minimum of single-precision floating-point strided array elements.</span>
202
197
 
203
198
  </section>
204
199
 
@@ -230,7 +225,7 @@ See [LICENSE][stdlib-license].
230
225
 
231
226
  ## Copyright
232
227
 
233
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
228
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
234
229
 
235
230
  </section>
236
231
 
@@ -243,8 +238,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
243
238
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-cumin.svg
244
239
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-cumin
245
240
 
246
- [test-image]: https://github.com/stdlib-js/stats-base-cumin/actions/workflows/test.yml/badge.svg?branch=v0.2.1
247
- [test-url]: https://github.com/stdlib-js/stats-base-cumin/actions/workflows/test.yml?query=branch:v0.2.1
241
+ [test-image]: https://github.com/stdlib-js/stats-base-cumin/actions/workflows/test.yml/badge.svg?branch=v0.3.0
242
+ [test-url]: https://github.com/stdlib-js/stats-base-cumin/actions/workflows/test.yml?query=branch:v0.3.0
248
243
 
249
244
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-cumin/main.svg
250
245
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-cumin?branch=main
@@ -256,8 +251,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
256
251
 
257
252
  -->
258
253
 
259
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
260
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
254
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
255
+ [chat-url]: https://stdlib.zulipchat.com
261
256
 
262
257
  [stdlib]: https://github.com/stdlib-js/stdlib
263
258
 
@@ -278,15 +273,17 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
278
273
 
279
274
  [mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
280
275
 
276
+ [@stdlib/array/base/accessor]: https://www.npmjs.com/package/@stdlib/array-base-accessor
277
+
281
278
  [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
282
279
 
283
280
  <!-- <related-links> -->
284
281
 
285
282
  [@stdlib/stats/base/cumax]: https://www.npmjs.com/package/@stdlib/stats-base-cumax
286
283
 
287
- [@stdlib/stats/base/dcumin]: https://www.npmjs.com/package/@stdlib/stats-base-dcumin
284
+ [@stdlib/stats/strided/dcumin]: https://www.npmjs.com/package/@stdlib/stats-strided-dcumin
288
285
 
289
- [@stdlib/stats/base/scumin]: https://www.npmjs.com/package/@stdlib/stats-base-scumin
286
+ [@stdlib/stats/strided/scumin]: https://www.npmjs.com/package/@stdlib/stats-strided-scumin
290
287
 
291
288
  <!-- </related-links> -->
292
289
 
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
- "use strict";var q=function(v,u){return function(){return u||v((u={exports:{}}).exports,u),u.exports}};var x=q(function(D,p){
2
- var m=require('@stdlib/math-base-assert-is-nan/dist'),R=require('@stdlib/math-base-assert-is-negative-zero/dist');function h(v,u,c,f,n){var i,s,r,a,e;if(v<=0)return f;if(c<0?s=(1-v)*c:s=0,n<0?r=(1-v)*n:r=0,i=u[s],f[r]=i,r+=n,e=1,m(i)===!1)for(e;e<v;e++){if(s+=c,a=u[s],m(a)){i=a;break}(a<i||a===i&&R(a))&&(i=a),f[r]=i,r+=n}if(m(i))for(e;e<v;e++)f[r]=i,r+=n;return f}p.exports=h
3
- });var g=q(function(E,b){
4
- var l=require('@stdlib/math-base-assert-is-nan/dist'),j=require('@stdlib/math-base-assert-is-negative-zero/dist');function w(v,u,c,f,n,i,s){var r,a,e,t,o;if(v<=0)return n;if(a=f,e=s,r=u[a],n[e]=r,e+=i,o=1,l(r)===!1)for(o;o<v;o++){if(a+=c,t=u[a],l(t)){r=t;break}(t<r||t===r&&j(t))&&(r=t),n[e]=r,e+=i}if(l(r))for(o;o<v;o++)n[e]=r,e+=i;return n}b.exports=w
5
- });var O=q(function(F,Z){
6
- var z=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),k=x(),A=g();z(k,"ndarray",A);Z.exports=k
7
- });var B=O();module.exports=B;
1
+ "use strict";var b=function(v,u){return function(){return u||v((u={exports:{}}).exports,u),u.exports}};var P=b(function(J,y){
2
+ var p=require('@stdlib/math-base-assert-is-nan/dist'),z=require('@stdlib/math-base-assert-is-negative-zero/dist');function A(v,u,f,l,a,s,m){var e,c,n,t,i,o,r,q,x;if(e=u.data,c=a.data,n=u.accessors[0],t=a.accessors[1],o=l,r=m,i=n(e,o),t(c,r,i),r+=s,x=1,p(i)===!1)for(x;x<v;x++){if(o+=f,q=n(e,o),p(q)){i=q;break}(q<i||q===i&&z(q))&&(i=q),t(c,r,i),r+=s}if(p(i))for(x;x<v;x++)t(c,r,i),r+=s;return a}y.exports=A
3
+ });var k=b(function(K,j){
4
+ var g=require('@stdlib/math-base-assert-is-nan/dist'),B=require('@stdlib/math-base-assert-is-negative-zero/dist'),Z=require('@stdlib/array-base-arraylike2object/dist'),C=P();function D(v,u,f,l,a,s,m){var e,c,n,t,i,o,r;if(v<=0)return a;if(t=Z(u),i=Z(a),t.accessorProtocol||i.accessorProtocol)return C(v,t,f,l,i,s,m),a;if(c=l,n=m,e=u[c],a[n]=e,n+=s,r=1,g(e)===!1)for(r;r<v;r++){if(c+=f,o=u[c],g(o)){e=o;break}(o<e||o===e&&B(o))&&(e=o),a[n]=e,n+=s}if(g(e))for(r;r<v;r++)a[n]=e,n+=s;return a}j.exports=D
5
+ });var h=b(function(L,R){
6
+ var O=require('@stdlib/strided-base-stride2offset/dist'),E=k();function F(v,u,f,l,a){var s=O(v,f),m=O(v,a);return E(v,u,f,s,l,a,m)}R.exports=F
7
+ });var G=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),w=h(),H=k();G(w,"ndarray",H);module.exports=w;
8
+ /** @license Apache-2.0 */
8
9
  /** @license Apache-2.0 */
9
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../lib/cumin.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\n\n\n// MAIN //\n\n/**\n* Computes the cumulative minimum of a strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NumericArray} y - output array\n* @param {integer} strideY - `y` stride length\n* @returns {NumericArray} output array\n*\n* @example\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n* var N = x.length;\n*\n* var v = cumin( N, x, 1, y, 1 );\n* // returns [ 1.0, -2.0, -2.0 ]\n*/\nfunction cumin( N, x, strideX, y, strideY ) {\n\tvar min;\n\tvar ix;\n\tvar iy;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\tmin = x[ ix ];\n\ty[ iy ] = min;\n\n\tiy += strideY;\n\ti = 1;\n\tif ( isnan( min ) === false ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tix += strideX;\n\t\t\tv = x[ ix ];\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tmin = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\tmin = v;\n\t\t\t}\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\tif ( isnan( min ) ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\n\n\n// MAIN //\n\n/**\n* Computes the cumulative minimum of a strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting index for `x`\n* @param {NumericArray} y - output array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting index for `y`\n* @returns {NumericArray} output array\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n* var N = floor( x.length / 2 );\n*\n* var v = cumin( N, x, 2, 1, y, 1, 0 );\n* // returns [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction cumin( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar min;\n\tvar ix;\n\tvar iy;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\tmin = x[ ix ];\n\ty[ iy ] = min;\n\n\tiy += strideY;\n\ti = 1;\n\tif ( isnan( min ) === false ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tix += strideX;\n\t\t\tv = x[ ix ];\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tmin = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\tmin = v;\n\t\t\t}\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\tif ( isnan( min ) ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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 setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar cumin = require( './cumin.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( cumin, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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* Compute the cumulative minimum of a strided array.\n*\n* @module @stdlib/stats-base-cumin\n*\n* @example\n* var cumin = require( '@stdlib/stats-base-cumin' );\n*\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n* var N = x.length;\n*\n* cumin( N, x, 1, y, 1 );\n* // y => [ 1.0, -2.0, -2.0 ]\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var cumin = require( '@stdlib/stats-base-cumin' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n* var N = floor( x.length / 2 );\n*\n* cumin.ndarray( N, x, 2, 1, y, 1, 0 );\n* // y => [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"ndarray\": \"main.ndarray\" }\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAiB,QAAS,2CAA4C,EAuB1E,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAAGC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKT,GAAK,EACT,OAAOG,EAiBR,GAfKD,EAAU,EACdI,GAAM,EAAEN,GAAKE,EAEbI,EAAK,EAEDF,EAAU,EACdG,GAAM,EAAEP,GAAKI,EAEbG,EAAK,EAENF,EAAMJ,EAAGK,CAAG,EACZH,EAAGI,CAAG,EAAIF,EAEVE,GAAMH,EACNK,EAAI,EACCZ,EAAOQ,CAAI,IAAM,GACrB,IAAMI,EAAGA,EAAIT,EAAGS,IAAM,CAGrB,GAFAH,GAAMJ,EACNM,EAAIP,EAAGK,CAAG,EACLT,EAAOW,CAAE,EAAI,CACjBH,EAAMG,EACN,KACD,EACKA,EAAIH,GAASG,IAAMH,GAAOP,EAAgBU,CAAE,KAChDH,EAAMG,GAEPL,EAAGI,CAAG,EAAIF,EACVE,GAAMH,CACP,CAED,GAAKP,EAAOQ,CAAI,EACf,IAAMI,EAAGA,EAAIT,EAAGS,IACfN,EAAGI,CAAG,EAAIF,EACVE,GAAMH,EAGR,OAAOD,CACR,CAKAP,EAAO,QAAUG,IClGjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAiB,QAAS,2CAA4C,EA2B1E,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKX,GAAK,EACT,OAAOI,EAUR,GARAI,EAAKL,EACLM,EAAKH,EAELC,EAAMN,EAAGO,CAAG,EACZJ,EAAGK,CAAG,EAAIF,EAEVE,GAAMJ,EACNM,EAAI,EACCd,EAAOU,CAAI,IAAM,GACrB,IAAMI,EAAGA,EAAIX,EAAGW,IAAM,CAGrB,GAFAH,GAAMN,EACNQ,EAAIT,EAAGO,CAAG,EACLX,EAAOa,CAAE,EAAI,CACjBH,EAAMG,EACN,KACD,EACKA,EAAIH,GAASG,IAAMH,GAAOT,EAAgBY,CAAE,KAChDH,EAAMG,GAEPN,EAAGK,CAAG,EAAIF,EACVE,GAAMJ,CACP,CAED,GAAKR,EAAOU,CAAI,EACf,IAAMI,EAAGA,EAAIX,EAAGW,IACfP,EAAGK,CAAG,EAAIF,EACVE,GAAMJ,EAGR,OAAOD,CACR,CAKAR,EAAO,QAAUG,IC/FjB,IAAAa,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAQ,IACRC,EAAU,IAKdF,EAAaC,EAAO,UAAWC,CAAQ,EAKvCH,EAAO,QAAUE,ICejB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_cumin", "__commonJSMin", "exports", "module", "isnan", "isNegativeZero", "cumin", "N", "x", "strideX", "y", "strideY", "min", "ix", "iy", "v", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "isNegativeZero", "cumin", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "min", "ix", "iy", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "cumin", "ndarray", "main"]
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) 2025 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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\n\n\n// MAIN //\n\n/**\n* Computes the cumulative minimum of a strided array.\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 for `x`\n* @param {NonNegativeInteger} offsetX - starting index for `x`\n* @param {Object} y - output array object\n* @param {Collection} y.data - output array data\n* @param {Array<Function>} y.accessors - array element accessors\n* @param {integer} strideY - stride length for `y`\n* @param {NonNegativeInteger} offsetY - starting index for `y`\n* @returns {Object} output array object\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* cumin( 4, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 );\n* // y => [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ];\n*/\nfunction cumin( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar xbuf;\n\tvar ybuf;\n\tvar xget;\n\tvar yset;\n\tvar min;\n\tvar ix;\n\tvar iy;\n\tvar v;\n\tvar i;\n\n\t// Cache references to array data:\n\txbuf = x.data;\n\tybuf = y.data;\n\n\t// Cache references to element accessors:\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tix = offsetX;\n\tiy = offsetY;\n\n\tmin = xget( xbuf, ix );\n\tyset( ybuf, iy, min );\n\n\tiy += strideY;\n\ti = 1;\n\tif ( isnan( min ) === false ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tix += strideX;\n\t\t\tv = xget( xbuf, ix );\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tmin = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\tmin = v;\n\t\t\t}\n\t\t\tyset( ybuf, iy, min );\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\tif ( isnan( min ) ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tyset( ybuf, iy, min );\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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 isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar accessors = require( './accessors.js' );\n\n\n// MAIN //\n\n/**\n* Computes the cumulative minimum of a strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length for `x`\n* @param {NonNegativeInteger} offsetX - starting index for `x`\n* @param {NumericArray} y - output array\n* @param {integer} strideY - stride length for `y`\n* @param {NonNegativeInteger} offsetY - starting index for `y`\n* @returns {NumericArray} output array\n*\n* @example\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* var v = cumin( 4, x, 2, 1, y, 1, 0 );\n* // returns [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction cumin( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar min;\n\tvar ix;\n\tvar iy;\n\tvar ox;\n\tvar oy;\n\tvar v;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tox = arraylike2object( x );\n\toy = arraylike2object( y );\n\tif ( ox.accessorProtocol || oy.accessorProtocol ) {\n\t\taccessors( N, ox, strideX, offsetX, oy, strideY, offsetY );\n\t\treturn y;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\tmin = x[ ix ];\n\ty[ iy ] = min;\n\n\tiy += strideY;\n\ti = 1;\n\tif ( isnan( min ) === false ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\tix += strideX;\n\t\t\tv = x[ ix ];\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tmin = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\tmin = v;\n\t\t\t}\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\tif ( isnan( min ) ) {\n\t\tfor ( i; i < N; i++ ) {\n\t\t\ty[ iy ] = min;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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* Computes the cumulative minimum of a strided array.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NumericArray} y - output array\n* @param {integer} strideY - `y` stride length\n* @returns {NumericArray} output array\n*\n* @example\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n* var N = x.length;\n*\n* var v = cumin( N, x, 1, y, 1 );\n* // returns [ 1.0, -2.0, -2.0 ]\n*/\nfunction cumin( N, x, strideX, y, strideY ) {\n\tvar ix = stride2offset( N, strideX );\n\tvar iy = stride2offset( N, strideY );\n\treturn ndarray( N, x, strideX, ix, y, strideY, iy );\n}\n\n\n// EXPORTS //\n\nmodule.exports = cumin;\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* Compute the cumulative minimum of a strided array.\n*\n* @module @stdlib/stats-base-cumin\n*\n* @example\n* var cumin = require( '@stdlib/stats-base-cumin' );\n*\n* var x = [ 1.0, -2.0, 2.0 ];\n* var y = [ 0.0, 0.0, 0.0 ];\n* var N = x.length;\n*\n* cumin( N, x, 1, y, 1 );\n* // y => [ 1.0, -2.0, -2.0 ]\n*\n* @example\n* var floor = require( '@stdlib/math-base-special-floor' );\n* var cumin = require( '@stdlib/stats-base-cumin' );\n*\n* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];\n* var N = floor( x.length / 2 );\n*\n* cumin.ndarray( N, x, 2, 1, y, 1, 0 );\n* // y => [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.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\n// exports: { \"ndarray\": \"main.ndarray\" }\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAiB,QAAS,2CAA4C,EAgC1E,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAkBJ,GAfAR,EAAON,EAAE,KACTO,EAAOJ,EAAE,KAGTK,EAAOR,EAAE,UAAW,CAAE,EACtBS,EAAON,EAAE,UAAW,CAAE,EAEtBQ,EAAKT,EACLU,EAAKP,EAELK,EAAMF,EAAMF,EAAMK,CAAG,EACrBF,EAAMF,EAAMK,EAAIF,CAAI,EAEpBE,GAAMR,EACNU,EAAI,EACClB,EAAOc,CAAI,IAAM,GACrB,IAAMI,EAAGA,EAAIf,EAAGe,IAAM,CAGrB,GAFAH,GAAMV,EACNY,EAAIL,EAAMF,EAAMK,CAAG,EACdf,EAAOiB,CAAE,EAAI,CACjBH,EAAMG,EACN,KACD,EACKA,EAAIH,GAASG,IAAMH,GAAOb,EAAgBgB,CAAE,KAChDH,EAAMG,GAEPJ,EAAMF,EAAMK,EAAIF,CAAI,EACpBE,GAAMR,CACP,CAED,GAAKR,EAAOc,CAAI,EACf,IAAMI,EAAGA,EAAIf,EAAGe,IACfL,EAAMF,EAAMK,EAAIF,CAAI,EACpBE,GAAMR,EAGR,OAAOD,CACR,CAKAR,EAAO,QAAUG,IC7GjB,IAAAiB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAiB,QAAS,2CAA4C,EACtEC,EAAmB,QAAS,qCAAsC,EAClEC,EAAY,IAwBhB,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAAU,CAC7D,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,GAAK,EACT,OAAOI,EAIR,GAFAM,EAAKb,EAAkBI,CAAE,EACzBU,EAAKd,EAAkBO,CAAE,EACpBM,EAAG,kBAAoBC,EAAG,iBAC9B,OAAAb,EAAWE,EAAGU,EAAIR,EAASC,EAASQ,EAAIN,EAASC,CAAQ,EAClDF,EAUR,GARAI,EAAKL,EACLM,EAAKH,EAELC,EAAMN,EAAGO,CAAG,EACZJ,EAAGK,CAAG,EAAIF,EAEVE,GAAMJ,EACNQ,EAAI,EACClB,EAAOY,CAAI,IAAM,GACrB,IAAMM,EAAGA,EAAIb,EAAGa,IAAM,CAGrB,GAFAL,GAAMN,EACNU,EAAIX,EAAGO,CAAG,EACLb,EAAOiB,CAAE,EAAI,CACjBL,EAAMK,EACN,KACD,EACKA,EAAIL,GAASK,IAAML,GAAOX,EAAgBgB,CAAE,KAChDL,EAAMK,GAEPR,EAAGK,CAAG,EAAIF,EACVE,GAAMJ,CACP,CAED,GAAKV,EAAOY,CAAI,EACf,IAAMM,EAAGA,EAAIb,EAAGa,IACfT,EAAGK,CAAG,EAAIF,EACVE,GAAMJ,EAGR,OAAOD,CACR,CAKAV,EAAO,QAAUK,ICtGjB,IAAAe,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAuBd,SAASC,EAAOC,EAAGC,EAAGC,EAASC,EAAGC,EAAU,CAC3C,IAAIC,EAAKR,EAAeG,EAAGE,CAAQ,EAC/BI,EAAKT,EAAeG,EAAGI,CAAQ,EACnC,OAAON,EAASE,EAAGC,EAAGC,EAASG,EAAIF,EAAGC,EAASE,CAAG,CACnD,CAKAV,EAAO,QAAUG,ICNjB,IAAIQ,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_accessors", "__commonJSMin", "exports", "module", "isnan", "isNegativeZero", "cumin", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "xbuf", "ybuf", "xget", "yset", "min", "ix", "iy", "v", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isnan", "isNegativeZero", "arraylike2object", "accessors", "cumin", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "min", "ix", "iy", "ox", "oy", "v", "i", "require_main", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "cumin", "N", "x", "strideX", "y", "strideY", "ix", "iy", "setReadOnly", "main", "ndarray"]
7
7
  }
@@ -20,7 +20,17 @@
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { NumericArray } from '@stdlib/types/array';
23
+ import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
24
+
25
+ /**
26
+ * Input array.
27
+ */
28
+ type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
29
+
30
+ /**
31
+ * Output array.
32
+ */
33
+ type OutputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
24
34
 
25
35
  /**
26
36
  * Interface describing `cumin`.
@@ -31,9 +41,9 @@ interface Routine {
31
41
  *
32
42
  * @param N - number of indexed elements
33
43
  * @param x - input array
34
- * @param strideX - `x` stride length
44
+ * @param strideX - stride length for `x`
35
45
  * @param y - output array
36
- * @param strideY - `y` stride length
46
+ * @param strideY - stride length for `y`
37
47
  * @returns output array
38
48
  *
39
49
  * @example
@@ -41,19 +51,19 @@ interface Routine {
41
51
  * var y = [ 0.0, 0.0, 0.0 ];
42
52
  *
43
53
  * cumin( x.length, x, 1, y, 1 );
44
- * // y => [ 1.0, 1.0, 2.0 ]
54
+ * // y => [ 1.0, -2.0, -2.0 ]
45
55
  */
46
- ( N: number, x: NumericArray, strideX: number, y: NumericArray, strideY: number ): NumericArray;
56
+ <T extends OutputArray>( N: number, x: InputArray, strideX: number, y: T, strideY: number ): T;
47
57
 
48
58
  /**
49
59
  * Computes the cumulative minimum of a strided array using alternative indexing semantics.
50
60
  *
51
61
  * @param N - number of indexed elements
52
62
  * @param x - input array
53
- * @param strideX - `x` stride length
63
+ * @param strideX - stride length for `x`
54
64
  * @param offsetX - starting index for `x`
55
65
  * @param y - output array
56
- * @param strideY - `y` stride length
66
+ * @param strideY - stride length for `y`
57
67
  * @param offsetY - starting index for `y`
58
68
  * @returns output array
59
69
  *
@@ -62,9 +72,9 @@ interface Routine {
62
72
  * var y = [ 0.0, 0.0, 0.0 ];
63
73
  *
64
74
  * cumin.ndarray( x.length, x, 1, 0, y, 1, 0 );
65
- * // y => [ 1.0, 1.0, 2.0 ]
75
+ * // y => [ 1.0, -2.0, -2.0 ]
66
76
  */
67
- ndarray( N: number, x: NumericArray, strideX: number, offsetX: number, y: NumericArray, strideY: number, offsetY: number ): NumericArray;
77
+ ndarray<T extends OutputArray>( N: number, x: InputArray, strideX: number, offsetX: number, y: T, strideY: number, offsetY: number ): T;
68
78
  }
69
79
 
70
80
  /**
@@ -72,9 +82,9 @@ interface Routine {
72
82
  *
73
83
  * @param N - number of indexed elements
74
84
  * @param x - input array
75
- * @param strideX - `x` stride length
85
+ * @param strideX - stride length for `x`
76
86
  * @param y - output array
77
- * @param strideY - `y` stride length
87
+ * @param strideY - stride length for `y`
78
88
  * @returns output array
79
89
  *
80
90
  * @example
@@ -82,14 +92,14 @@ interface Routine {
82
92
  * var y = [ 0.0, 0.0, 0.0 ];
83
93
  *
84
94
  * cumin( x.length, x, 1, y, 1 );
85
- * // y => [ 1.0, 1.0, 2.0 ]
95
+ * // y => [ 1.0, -2.0, -2.0 ]
86
96
  *
87
97
  * @example
88
- * var x = [ 1.0, -2.0, 2.0 ] );
98
+ * var x = [ 1.0, -2.0, 2.0 ];
89
99
  * var y = [ 0.0, 0.0, 0.0 ];
90
100
  *
91
101
  * cumin.ndarray( x.length, x, 1, 0, y, 1, 0 );
92
- * // y => [ 1.0, 1.0, 2.0 ]
102
+ * // y => [ 1.0, -2.0, -2.0 ]
93
103
  */
94
104
  declare var cumin: Routine;
95
105
 
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var isnan = require( '@stdlib/math-base-assert-is-nan' );
24
+ var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Computes the cumulative minimum of a strided array.
31
+ *
32
+ * @private
33
+ * @param {PositiveInteger} N - number of indexed elements
34
+ * @param {Object} x - input array object
35
+ * @param {Collection} x.data - input array data
36
+ * @param {Array<Function>} x.accessors - array element accessors
37
+ * @param {integer} strideX - stride length for `x`
38
+ * @param {NonNegativeInteger} offsetX - starting index for `x`
39
+ * @param {Object} y - output array object
40
+ * @param {Collection} y.data - output array data
41
+ * @param {Array<Function>} y.accessors - array element accessors
42
+ * @param {integer} strideY - stride length for `y`
43
+ * @param {NonNegativeInteger} offsetY - starting index for `y`
44
+ * @returns {Object} output array object
45
+ *
46
+ * @example
47
+ * var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );
48
+ * var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
49
+ *
50
+ * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
51
+ * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
52
+ *
53
+ * cumin( 4, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 );
54
+ * // y => [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ];
55
+ */
56
+ function cumin( N, x, strideX, offsetX, y, strideY, offsetY ) {
57
+ var xbuf;
58
+ var ybuf;
59
+ var xget;
60
+ var yset;
61
+ var min;
62
+ var ix;
63
+ var iy;
64
+ var v;
65
+ var i;
66
+
67
+ // Cache references to array data:
68
+ xbuf = x.data;
69
+ ybuf = y.data;
70
+
71
+ // Cache references to element accessors:
72
+ xget = x.accessors[ 0 ];
73
+ yset = y.accessors[ 1 ];
74
+
75
+ ix = offsetX;
76
+ iy = offsetY;
77
+
78
+ min = xget( xbuf, ix );
79
+ yset( ybuf, iy, min );
80
+
81
+ iy += strideY;
82
+ i = 1;
83
+ if ( isnan( min ) === false ) {
84
+ for ( i; i < N; i++ ) {
85
+ ix += strideX;
86
+ v = xget( xbuf, ix );
87
+ if ( isnan( v ) ) {
88
+ min = v;
89
+ break;
90
+ }
91
+ if ( v < min || ( v === min && isNegativeZero( v ) ) ) {
92
+ min = v;
93
+ }
94
+ yset( ybuf, iy, min );
95
+ iy += strideY;
96
+ }
97
+ }
98
+ if ( isnan( min ) ) {
99
+ for ( i; i < N; i++ ) {
100
+ yset( ybuf, iy, min );
101
+ iy += strideY;
102
+ }
103
+ }
104
+ return y;
105
+ }
106
+
107
+
108
+ // EXPORTS //
109
+
110
+ module.exports = cumin;
package/lib/index.js CHANGED
@@ -47,7 +47,14 @@
47
47
 
48
48
  // MODULES //
49
49
 
50
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
50
51
  var main = require( './main.js' );
52
+ var ndarray = require( './ndarray.js' );
53
+
54
+
55
+ // MAIN //
56
+
57
+ setReadOnly( main, 'ndarray', ndarray );
51
58
 
52
59
 
53
60
  // EXPORTS //
package/lib/main.js CHANGED
@@ -20,14 +20,35 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
24
- var cumin = require( './cumin.js' );
23
+ var stride2offset = require( '@stdlib/strided-base-stride2offset' );
25
24
  var ndarray = require( './ndarray.js' );
26
25
 
27
26
 
28
27
  // MAIN //
29
28
 
30
- setReadOnly( cumin, 'ndarray', ndarray );
29
+ /**
30
+ * Computes the cumulative minimum of a strided array.
31
+ *
32
+ * @param {PositiveInteger} N - number of indexed elements
33
+ * @param {NumericArray} x - input array
34
+ * @param {integer} strideX - `x` stride length
35
+ * @param {NumericArray} y - output array
36
+ * @param {integer} strideY - `y` stride length
37
+ * @returns {NumericArray} output array
38
+ *
39
+ * @example
40
+ * var x = [ 1.0, -2.0, 2.0 ];
41
+ * var y = [ 0.0, 0.0, 0.0 ];
42
+ * var N = x.length;
43
+ *
44
+ * var v = cumin( N, x, 1, y, 1 );
45
+ * // returns [ 1.0, -2.0, -2.0 ]
46
+ */
47
+ function cumin( N, x, strideX, y, strideY ) {
48
+ var ix = stride2offset( N, strideX );
49
+ var iy = stride2offset( N, strideY );
50
+ return ndarray( N, x, strideX, ix, y, strideY, iy );
51
+ }
31
52
 
32
53
 
33
54
  // EXPORTS //
package/lib/ndarray.js CHANGED
@@ -22,6 +22,8 @@
22
22
 
23
23
  var isnan = require( '@stdlib/math-base-assert-is-nan' );
24
24
  var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );
25
+ var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
26
+ var accessors = require( './accessors.js' );
25
27
 
26
28
 
27
29
  // MAIN //
@@ -31,33 +33,38 @@ var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );
31
33
  *
32
34
  * @param {PositiveInteger} N - number of indexed elements
33
35
  * @param {NumericArray} x - input array
34
- * @param {integer} strideX - `x` stride length
36
+ * @param {integer} strideX - stride length for `x`
35
37
  * @param {NonNegativeInteger} offsetX - starting index for `x`
36
38
  * @param {NumericArray} y - output array
37
- * @param {integer} strideY - `y` stride length
39
+ * @param {integer} strideY - stride length for `y`
38
40
  * @param {NonNegativeInteger} offsetY - starting index for `y`
39
41
  * @returns {NumericArray} output array
40
42
  *
41
43
  * @example
42
- * var floor = require( '@stdlib/math-base-special-floor' );
43
- *
44
44
  * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
45
45
  * var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
46
- * var N = floor( x.length / 2 );
47
46
  *
48
- * var v = cumin( N, x, 2, 1, y, 1, 0 );
47
+ * var v = cumin( 4, x, 2, 1, y, 1, 0 );
49
48
  * // returns [ 1.0, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0 ]
50
49
  */
51
50
  function cumin( N, x, strideX, offsetX, y, strideY, offsetY ) {
52
51
  var min;
53
52
  var ix;
54
53
  var iy;
54
+ var ox;
55
+ var oy;
55
56
  var v;
56
57
  var i;
57
58
 
58
59
  if ( N <= 0 ) {
59
60
  return y;
60
61
  }
62
+ ox = arraylike2object( x );
63
+ oy = arraylike2object( y );
64
+ if ( ox.accessorProtocol || oy.accessorProtocol ) {
65
+ accessors( N, ox, strideX, offsetX, oy, strideY, offsetY );
66
+ return y;
67
+ }
61
68
  ix = offsetX;
62
69
  iy = offsetY;
63
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-cumin",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Calculate the cumulative minimum of a strided array.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,9 +30,11 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/math-base-assert-is-nan": "^0.2.1",
34
- "@stdlib/math-base-assert-is-negative-zero": "^0.2.1",
35
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1"
33
+ "@stdlib/array-base-arraylike2object": "^0.2.1",
34
+ "@stdlib/math-base-assert-is-nan": "^0.2.2",
35
+ "@stdlib/math-base-assert-is-negative-zero": "^0.2.2",
36
+ "@stdlib/strided-base-stride2offset": "^0.1.0",
37
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2"
36
38
  },
37
39
  "devDependencies": {},
38
40
  "engines": {
@@ -69,7 +71,6 @@
69
71
  "strided array",
70
72
  "array"
71
73
  ],
72
- "__stdlib__": {},
73
74
  "funding": {
74
75
  "type": "opencollective",
75
76
  "url": "https://opencollective.com/stdlib"
package/lib/cumin.js DELETED
@@ -1,99 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- 'use strict';
20
-
21
- // MODULES //
22
-
23
- var isnan = require( '@stdlib/math-base-assert-is-nan' );
24
- var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );
25
-
26
-
27
- // MAIN //
28
-
29
- /**
30
- * Computes the cumulative minimum of a strided array.
31
- *
32
- * @param {PositiveInteger} N - number of indexed elements
33
- * @param {NumericArray} x - input array
34
- * @param {integer} strideX - `x` stride length
35
- * @param {NumericArray} y - output array
36
- * @param {integer} strideY - `y` stride length
37
- * @returns {NumericArray} output array
38
- *
39
- * @example
40
- * var x = [ 1.0, -2.0, 2.0 ];
41
- * var y = [ 0.0, 0.0, 0.0 ];
42
- * var N = x.length;
43
- *
44
- * var v = cumin( N, x, 1, y, 1 );
45
- * // returns [ 1.0, -2.0, -2.0 ]
46
- */
47
- function cumin( N, x, strideX, y, strideY ) {
48
- var min;
49
- var ix;
50
- var iy;
51
- var v;
52
- var i;
53
-
54
- if ( N <= 0 ) {
55
- return y;
56
- }
57
- if ( strideX < 0 ) {
58
- ix = (1-N) * strideX;
59
- } else {
60
- ix = 0;
61
- }
62
- if ( strideY < 0 ) {
63
- iy = (1-N) * strideY;
64
- } else {
65
- iy = 0;
66
- }
67
- min = x[ ix ];
68
- y[ iy ] = min;
69
-
70
- iy += strideY;
71
- i = 1;
72
- if ( isnan( min ) === false ) {
73
- for ( i; i < N; i++ ) {
74
- ix += strideX;
75
- v = x[ ix ];
76
- if ( isnan( v ) ) {
77
- min = v;
78
- break;
79
- }
80
- if ( v < min || ( v === min && isNegativeZero( v ) ) ) {
81
- min = v;
82
- }
83
- y[ iy ] = min;
84
- iy += strideY;
85
- }
86
- }
87
- if ( isnan( min ) ) {
88
- for ( i; i < N; i++ ) {
89
- y[ iy ] = min;
90
- iy += strideY;
91
- }
92
- }
93
- return y;
94
- }
95
-
96
-
97
- // EXPORTS //
98
-
99
- module.exports = cumin;