@stdlib/ndarray-zeros-like 0.0.1 → 0.1.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/CITATION.cff +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +25 -10
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +92 -8
- package/lib/main.js +38 -21
- package/package.json +35 -33
- package/docs/repl.txt +0 -53
- package/docs/types/test.ts +0 -167
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
package/LICENSE
CHANGED
|
@@ -175,307 +175,3 @@
|
|
|
175
175
|
of your accepting any such warranty or additional liability.
|
|
176
176
|
|
|
177
177
|
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
182
|
-
|
|
183
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
184
|
-
obtaining a copy of the software and accompanying documentation covered by this
|
|
185
|
-
license (the "Software") to use, reproduce, display, distribute, execute, and
|
|
186
|
-
transmit the Software, and to prepare derivative works of the Software, and to
|
|
187
|
-
permit third-parties to whom the Software is furnished to do so, all subject to
|
|
188
|
-
the following:
|
|
189
|
-
|
|
190
|
-
The copyright notices in the Software and this entire statement, including the
|
|
191
|
-
above license grant, this restriction and the following disclaimer, must be
|
|
192
|
-
included in all copies of the Software, in whole or in part, and all derivative
|
|
193
|
-
works of the Software, unless such copies or derivative works are solely in the
|
|
194
|
-
form of machine-executable object code generated by a source language processor.
|
|
195
|
-
|
|
196
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
197
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
198
|
-
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
199
|
-
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
|
200
|
-
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
201
|
-
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
DEPENDENCIES
|
|
207
|
-
|
|
208
|
-
The library links against the following external libraries, which have their own
|
|
209
|
-
licenses:
|
|
210
|
-
|
|
211
|
-
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
|
212
|
-
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
|
213
|
-
|
|
214
|
-
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
215
|
-
All rights reserved.
|
|
216
|
-
|
|
217
|
-
Redistribution and use in source and binary forms, with or without
|
|
218
|
-
modification, are permitted provided that the following conditions are
|
|
219
|
-
met:
|
|
220
|
-
|
|
221
|
-
1. Redistributions of source code must retain the above copyright
|
|
222
|
-
notice, this list of conditions and the following disclaimer.
|
|
223
|
-
|
|
224
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
225
|
-
notice, this list of conditions and the following disclaimer in
|
|
226
|
-
the documentation and/or other materials provided with the
|
|
227
|
-
distribution.
|
|
228
|
-
|
|
229
|
-
3. Neither the name of the OpenBLAS project nor the names of
|
|
230
|
-
its contributors may be used to endorse or promote products
|
|
231
|
-
derived from this software without specific prior written
|
|
232
|
-
permission.
|
|
233
|
-
|
|
234
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
235
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
236
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
237
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
238
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
239
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
240
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
241
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
242
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
243
|
-
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* Electron <https://raw.githubusercontent.com/electron/electron/
|
|
247
|
-
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
|
248
|
-
|
|
249
|
-
Copyright (c) 2013-2017 GitHub Inc.
|
|
250
|
-
|
|
251
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
252
|
-
a copy of this software and associated documentation files (the
|
|
253
|
-
"Software"), to deal in the Software without restriction, including
|
|
254
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
255
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
256
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
257
|
-
the following conditions:
|
|
258
|
-
|
|
259
|
-
The above copyright notice and this permission notice shall be
|
|
260
|
-
included in all copies or substantial portions of the Software.
|
|
261
|
-
|
|
262
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
263
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
264
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
265
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
266
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
267
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
268
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
|
272
|
-
|
|
273
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
274
|
-
|
|
275
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
276
|
-
obtaining a copy of the software and accompanying documentation covered by
|
|
277
|
-
this license (the "Software") to use, reproduce, display, distribute,
|
|
278
|
-
execute, and transmit the Software, and to prepare derivative works of the
|
|
279
|
-
Software, and to permit third-parties to whom the Software is furnished to
|
|
280
|
-
do so, all subject to the following:
|
|
281
|
-
|
|
282
|
-
The copyright notices in the Software and this entire statement, including
|
|
283
|
-
the above license grant, this restriction and the following disclaimer,
|
|
284
|
-
must be included in all copies of the Software, in whole or in part, and
|
|
285
|
-
all derivative works of the Software, unless such copies or derivative
|
|
286
|
-
works are solely in the form of machine-executable object code generated by
|
|
287
|
-
a source language processor.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
290
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
291
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
292
|
-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
293
|
-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
294
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
295
|
-
DEALINGS IN THE SOFTWARE.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* Cephes <http://www.netlib.org/cephes/readme>
|
|
299
|
-
|
|
300
|
-
Copyright (c) 1984-2000 Stephen L. Moshier
|
|
301
|
-
|
|
302
|
-
Some software in this archive may be from the book _Methods and Programs for
|
|
303
|
-
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
|
304
|
-
or from the Cephes Mathematical Library, a commercial product. In either event,
|
|
305
|
-
it is copyrighted by the author. What you see here may be used freely but it
|
|
306
|
-
comes with no support or guarantee.
|
|
307
|
-
|
|
308
|
-
Stephen L. Moshier
|
|
309
|
-
moshier@na-net.ornl.gov
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ATTRIBUTION
|
|
314
|
-
|
|
315
|
-
The library contains implementations from the following external libraries,
|
|
316
|
-
which have their own licenses:
|
|
317
|
-
|
|
318
|
-
* FreeBSD <https://svnweb.freebsd.org/>
|
|
319
|
-
|
|
320
|
-
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
321
|
-
|
|
322
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
323
|
-
Permission to use, copy, modify, and distribute this
|
|
324
|
-
software is freely granted, provided that this notice
|
|
325
|
-
is preserved.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* FDLIBM <http://www.netlib.org/fdlibm/>
|
|
329
|
-
|
|
330
|
-
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
331
|
-
|
|
332
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
333
|
-
Permission to use, copy, modify, and distribute this
|
|
334
|
-
software is freely granted, provided that this notice
|
|
335
|
-
is preserved.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
|
339
|
-
|
|
340
|
-
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
341
|
-
|
|
342
|
-
Redistribution and use in source and binary forms, with or without
|
|
343
|
-
modification, are permitted provided that the following conditions are
|
|
344
|
-
met:
|
|
345
|
-
|
|
346
|
-
* Redistributions of source code must retain the above copyright
|
|
347
|
-
notice, this list of conditions and the following disclaimer.
|
|
348
|
-
* Redistributions in binary form must reproduce the above
|
|
349
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
350
|
-
in the documentation and/or other materials provided with the
|
|
351
|
-
distribution.
|
|
352
|
-
* Neither the name of Google Inc. nor the names of its
|
|
353
|
-
contributors may be used to endorse or promote products derived from
|
|
354
|
-
this software without specific prior written permission.
|
|
355
|
-
|
|
356
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
|
370
|
-
|
|
371
|
-
Public domain.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
|
375
|
-
|
|
376
|
-
Copyright JS Foundation and other contributors, https://js.foundation
|
|
377
|
-
|
|
378
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
379
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
380
|
-
in the Software without restriction, including without limitation the rights
|
|
381
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
382
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
383
|
-
furnished to do so, subject to the following conditions:
|
|
384
|
-
|
|
385
|
-
The above copyright notice and this permission notice shall be included in
|
|
386
|
-
all copies or substantial portions of the Software.
|
|
387
|
-
|
|
388
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
389
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
390
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
391
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
392
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
393
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
394
|
-
THE SOFTWARE.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
|
398
|
-
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
|
399
|
-
|
|
400
|
-
Copyright (c) 2015: Dahua Lin.
|
|
401
|
-
|
|
402
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
403
|
-
a copy of this software and associated documentation files (the
|
|
404
|
-
"Software"), to deal in the Software without restriction, including
|
|
405
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
406
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
407
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
408
|
-
the following conditions:
|
|
409
|
-
|
|
410
|
-
The above copyright notice and this permission notice shall be
|
|
411
|
-
included in all copies or substantial portions of the Software.
|
|
412
|
-
|
|
413
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
414
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
415
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
416
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
417
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
418
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
419
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
|
423
|
-
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
|
424
|
-
|
|
425
|
-
The MIT License (MIT)
|
|
426
|
-
|
|
427
|
-
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
|
428
|
-
|
|
429
|
-
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
|
430
|
-
|
|
431
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
432
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
433
|
-
in the Software without restriction, including without limitation the rights
|
|
434
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
435
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
436
|
-
furnished to do so, subject to the following conditions:
|
|
437
|
-
|
|
438
|
-
The above copyright notice and this permission notice shall be included in all
|
|
439
|
-
copies or substantial portions of the Software.
|
|
440
|
-
|
|
441
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
442
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
443
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
444
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
445
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
446
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
447
|
-
SOFTWARE.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
|
451
|
-
mt19937ar.c>
|
|
452
|
-
|
|
453
|
-
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
454
|
-
All rights reserved.
|
|
455
|
-
|
|
456
|
-
Redistribution and use in source and binary forms, with or without
|
|
457
|
-
modification, are permitted provided that the following conditions
|
|
458
|
-
are met:
|
|
459
|
-
|
|
460
|
-
1. Redistributions of source code must retain the above copyright
|
|
461
|
-
notice, this list of conditions and the following disclaimer.
|
|
462
|
-
|
|
463
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
464
|
-
notice, this list of conditions and the following disclaimer in the
|
|
465
|
-
documentation and/or other materials provided with the distribution.
|
|
466
|
-
|
|
467
|
-
3. The names of its contributors may not be used to endorse or promote
|
|
468
|
-
products derived from this software without specific prior written
|
|
469
|
-
permission.
|
|
470
|
-
|
|
471
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
472
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
473
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
474
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
475
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
476
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
477
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
478
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
479
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
480
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
481
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2023 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# zerosLike
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -77,6 +88,9 @@ The function supports the following `options`:
|
|
|
77
88
|
- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Overrides the input ndarray's inferred [data type][@stdlib/ndarray/dtypes].
|
|
78
89
|
- **shape**: output [ndarray][@stdlib/ndarray/ctor] shape. Overrides the input ndarray's inferred shape.
|
|
79
90
|
- **order**: specifies whether the output [ndarray][@stdlib/ndarray/ctor] should be `'row-major'` (C-style) or `'column-major'` (Fortran-style). Overrides the input ndarray's inferred order.
|
|
91
|
+
- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`.
|
|
92
|
+
- **submode**: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). If provided fewer modes than dimensions, the constructor recycles modes using modulo arithmetic. Default: `[ options.mode ]`.
|
|
93
|
+
- **readonly**: `boolean` indicating whether an array should be **read-only**. Default: `false`.
|
|
80
94
|
|
|
81
95
|
To override either the `dtype`, `shape`, or `order`, specify the corresponding option. For example, to override the inferred [data type][@stdlib/ndarray/dtypes],
|
|
82
96
|
|
|
@@ -188,7 +202,7 @@ See [LICENSE][stdlib-license].
|
|
|
188
202
|
|
|
189
203
|
## Copyright
|
|
190
204
|
|
|
191
|
-
Copyright © 2016-
|
|
205
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
192
206
|
|
|
193
207
|
</section>
|
|
194
208
|
|
|
@@ -201,8 +215,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
201
215
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-zeros-like.svg
|
|
202
216
|
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-zeros-like
|
|
203
217
|
|
|
204
|
-
[test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg
|
|
205
|
-
[test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml
|
|
218
|
+
[test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
219
|
+
[test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.1.0
|
|
206
220
|
|
|
207
221
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-zeros-like/main.svg
|
|
208
222
|
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-zeros-like?branch=main
|
|
@@ -214,19 +228,20 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
214
228
|
|
|
215
229
|
-->
|
|
216
230
|
|
|
231
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
232
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
233
|
+
|
|
234
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
235
|
+
|
|
236
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
237
|
+
|
|
217
238
|
[umd]: https://github.com/umdjs/umd
|
|
218
239
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
219
240
|
|
|
220
241
|
[deno-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/deno
|
|
221
242
|
[umd-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/umd
|
|
222
243
|
[esm-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm
|
|
223
|
-
|
|
224
|
-
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
225
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
226
|
-
|
|
227
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
228
|
-
|
|
229
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
244
|
+
[branches-url]: https://github.com/stdlib-js/ndarray-zeros-like/blob/main/branches.md
|
|
230
245
|
|
|
231
246
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros-like/main/LICENSE
|
|
232
247
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var f=l(function(k,m){
|
|
2
|
+
var y=require('@stdlib/assert-is-ndarray-like/dist'),g=require('@stdlib/assert-is-plain-object/dist'),h=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,t=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),w=require('@stdlib/ndarray-base-buffer/dist'),c=require('@stdlib/ndarray-base-numel/dist'),E=require('@stdlib/ndarray-ctor/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function O(a){var e,i,n,p,s,v,o,u,r;if(!y(a))throw new TypeError(d('0kH5t',a));if(s={},arguments.length>1){if(e=arguments[1],!g(e))throw new TypeError(d('0kH2V',e));if(t(e,"dtype")?i=e.dtype:i=a.dtype,t(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!h(r))throw new TypeError(d('0kHDs',"shape",r))}else r=a.shape;t(e,"order")?n=e.order:n=a.order,t(e,"mode")&&(s.mode=e.mode),t(e,"submode")&&(s.submode=e.submode),t(e,"readonly")&&(s.readonly=e.readonly)}else i=a.dtype,r=a.shape,n=a.order;if(p=r.length,p>0?(o=c(r),o<0&&(o=0),u=b(r,n)):(o=1,u=[0]),v=w(i,o),v===null)throw new TypeError(d('0kH5L',i));return new E(i,v,r,u,q(r,u),n,s)}m.exports=O
|
|
3
|
+
});var T=f();module.exports=T;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../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// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction zerosLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must have a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zerosLike;\n", "/**\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/**\n* Create a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-zeros-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var zerosLike = require( '@stdlib/ndarray-zeros-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\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,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACpB,EAAeW,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACX,EAAeW,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKT,EAAYS,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQF,EAAE,MAENR,EAAYS,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAAClB,EAA2BkB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKT,EAAE,MAEHR,EAAYS,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQH,EAAE,MAENR,EAAYS,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBT,EAAYS,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBT,EAAYS,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQF,EAAE,MACVS,EAAKT,EAAE,MACPG,EAAQH,EAAE,MAeX,GAbAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMX,EAAOa,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKf,EAAegB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMX,EAAQO,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,kFAAmFI,CAAM,CAAE,EAEzH,OAAO,IAAIL,EAASK,EAAOI,EAAKG,EAAID,EAAId,EAAgBe,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAjB,EAAO,QAAUW,ICvGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "format", "zerosLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -18,33 +18,48 @@
|
|
|
18
18
|
* limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
// TypeScript Version:
|
|
21
|
+
// TypeScript Version: 4.1
|
|
22
22
|
|
|
23
23
|
/// <reference types="@stdlib/types"/>
|
|
24
24
|
|
|
25
|
-
import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType } from '@stdlib/types/ndarray';
|
|
25
|
+
import { Shape, Order, ndarray, typedndarray, float64ndarray, float32ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, complex128ndarray, complex64ndarray, DataType, Mode } from '@stdlib/types/ndarray';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Interface describing function options.
|
|
29
29
|
*/
|
|
30
30
|
interface Options {
|
|
31
31
|
/**
|
|
32
|
-
* Array
|
|
32
|
+
* Array shape.
|
|
33
33
|
*
|
|
34
34
|
* ## Notes
|
|
35
35
|
*
|
|
36
|
-
* - If provided, this option overrides the input array's inferred
|
|
36
|
+
* - If provided, this option overrides the input array's inferred shape.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
shape?: Shape | number;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Array
|
|
41
|
+
* Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)).
|
|
42
42
|
*
|
|
43
43
|
* ## Notes
|
|
44
44
|
*
|
|
45
|
-
* - If provided, this option overrides the input array's inferred
|
|
45
|
+
* - If provided, this option overrides the input array's inferred order.
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
order?: Order;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Specifies how to handle a linear index which exceeds array dimensions (default: 'throw').
|
|
51
|
+
*/
|
|
52
|
+
mode?: Mode;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Specifies how to handle subscripts which exceed array dimensions on a per dimension basis (default: ['throw']).
|
|
56
|
+
*/
|
|
57
|
+
submode?: Array<Mode>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Boolean indicating whether an array should be read-only (default: false).
|
|
61
|
+
*/
|
|
62
|
+
readonly?: boolean;
|
|
48
63
|
}
|
|
49
64
|
|
|
50
65
|
/**
|
|
@@ -222,6 +237,9 @@ interface OptionsWithDType extends Options {
|
|
|
222
237
|
* @param options - options
|
|
223
238
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
224
239
|
* @param options.shape - output array shape
|
|
240
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
241
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
242
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
225
243
|
* @returns zero-filled array
|
|
226
244
|
*
|
|
227
245
|
* @example
|
|
@@ -256,6 +274,9 @@ declare function zerosLike( x: float64ndarray, options?: Options ): float64ndarr
|
|
|
256
274
|
* @param options - options
|
|
257
275
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
258
276
|
* @param options.shape - output array shape
|
|
277
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
278
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
279
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
259
280
|
* @returns zero-filled array
|
|
260
281
|
*
|
|
261
282
|
* @example
|
|
@@ -290,6 +311,9 @@ declare function zerosLike( x: float32ndarray, options?: Options ): float32ndarr
|
|
|
290
311
|
* @param options - options
|
|
291
312
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
292
313
|
* @param options.shape - output array shape
|
|
314
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
315
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
316
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
293
317
|
* @returns zero-filled array
|
|
294
318
|
*
|
|
295
319
|
* @example
|
|
@@ -324,6 +348,9 @@ declare function zerosLike( x: complex128ndarray, options?: Options ): complex12
|
|
|
324
348
|
* @param options - options
|
|
325
349
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
326
350
|
* @param options.shape - output array shape
|
|
351
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
352
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
353
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
327
354
|
* @returns zero-filled array
|
|
328
355
|
*
|
|
329
356
|
* @example
|
|
@@ -358,6 +385,9 @@ declare function zerosLike( x: complex64ndarray, options?: Options ): complex64n
|
|
|
358
385
|
* @param options - options
|
|
359
386
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
360
387
|
* @param options.shape - output array shape
|
|
388
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
389
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
390
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
361
391
|
* @returns zero-filled array
|
|
362
392
|
*
|
|
363
393
|
* @example
|
|
@@ -392,6 +422,9 @@ declare function zerosLike( x: int32ndarray, options?: Options ): int32ndarray;
|
|
|
392
422
|
* @param options - options
|
|
393
423
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
394
424
|
* @param options.shape - output array shape
|
|
425
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
426
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
427
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
395
428
|
* @returns zero-filled array
|
|
396
429
|
*
|
|
397
430
|
* @example
|
|
@@ -426,6 +459,9 @@ declare function zerosLike( x: int16ndarray, options?: Options ): int16ndarray;
|
|
|
426
459
|
* @param options - options
|
|
427
460
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
428
461
|
* @param options.shape - output array shape
|
|
462
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
463
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
464
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
429
465
|
* @returns zero-filled array
|
|
430
466
|
*
|
|
431
467
|
* @example
|
|
@@ -460,6 +496,9 @@ declare function zerosLike( x: int8ndarray, options?: Options ): int8ndarray;
|
|
|
460
496
|
* @param options - options
|
|
461
497
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
462
498
|
* @param options.shape - output array shape
|
|
499
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
500
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
501
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
463
502
|
* @returns zero-filled array
|
|
464
503
|
*
|
|
465
504
|
* @example
|
|
@@ -494,6 +533,9 @@ declare function zerosLike( x: uint32ndarray, options?: Options ): uint32ndarray
|
|
|
494
533
|
* @param options - options
|
|
495
534
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
496
535
|
* @param options.shape - output array shape
|
|
536
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
537
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
538
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
497
539
|
* @returns zero-filled array
|
|
498
540
|
*
|
|
499
541
|
* @example
|
|
@@ -528,6 +570,9 @@ declare function zerosLike( x: uint16ndarray, options?: Options ): uint16ndarray
|
|
|
528
570
|
* @param options - options
|
|
529
571
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
530
572
|
* @param options.shape - output array shape
|
|
573
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
574
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
575
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
531
576
|
* @returns zero-filled array
|
|
532
577
|
*
|
|
533
578
|
* @example
|
|
@@ -562,6 +607,9 @@ declare function zerosLike( x: uint8ndarray, options?: Options ): uint8ndarray;
|
|
|
562
607
|
* @param options - options
|
|
563
608
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
564
609
|
* @param options.shape - output array shape
|
|
610
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
611
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
612
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
565
613
|
* @returns zero-filled array
|
|
566
614
|
*
|
|
567
615
|
* @example
|
|
@@ -597,6 +645,9 @@ declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray
|
|
|
597
645
|
* @param options.dtype - output array data type
|
|
598
646
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
599
647
|
* @param options.shape - output array shape
|
|
648
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
649
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
650
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
600
651
|
* @returns zero-filled array
|
|
601
652
|
*
|
|
602
653
|
* @example
|
|
@@ -634,6 +685,9 @@ declare function zerosLike( x: ndarray, options: Float64Options ): float64ndarra
|
|
|
634
685
|
* @param options.dtype - output array data type
|
|
635
686
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
636
687
|
* @param options.shape - output array shape
|
|
688
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
689
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
690
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
637
691
|
* @returns zero-filled array
|
|
638
692
|
*
|
|
639
693
|
* @example
|
|
@@ -671,6 +725,9 @@ declare function zerosLike( x: ndarray, options: Float32Options ): float32ndarra
|
|
|
671
725
|
* @param options.dtype - output array data type
|
|
672
726
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
673
727
|
* @param options.shape - output array shape
|
|
728
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
729
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
730
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
674
731
|
* @returns zero-filled array
|
|
675
732
|
*
|
|
676
733
|
* @example
|
|
@@ -708,6 +765,9 @@ declare function zerosLike( x: ndarray, options: Complex128Options ): complex128
|
|
|
708
765
|
* @param options.dtype - output array data type
|
|
709
766
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
710
767
|
* @param options.shape - output array shape
|
|
768
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
769
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
770
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
711
771
|
* @returns zero-filled array
|
|
712
772
|
*
|
|
713
773
|
* @example
|
|
@@ -745,6 +805,9 @@ declare function zerosLike( x: ndarray, options: Complex64Options ): complex64nd
|
|
|
745
805
|
* @param options.dtype - output array data type
|
|
746
806
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
747
807
|
* @param options.shape - output array shape
|
|
808
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
809
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
810
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
748
811
|
* @returns zero-filled array
|
|
749
812
|
*
|
|
750
813
|
* @example
|
|
@@ -782,6 +845,9 @@ declare function zerosLike( x: ndarray, options: Int32Options ): int32ndarray;
|
|
|
782
845
|
* @param options.dtype - output array data type
|
|
783
846
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
784
847
|
* @param options.shape - output array shape
|
|
848
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
849
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
850
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
785
851
|
* @returns zero-filled array
|
|
786
852
|
*
|
|
787
853
|
* @example
|
|
@@ -819,6 +885,9 @@ declare function zerosLike( x: ndarray, options: Int16Options ): int16ndarray;
|
|
|
819
885
|
* @param options.dtype - output array data type
|
|
820
886
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
821
887
|
* @param options.shape - output array shape
|
|
888
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
889
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
890
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
822
891
|
* @returns zero-filled array
|
|
823
892
|
*
|
|
824
893
|
* @example
|
|
@@ -856,6 +925,9 @@ declare function zerosLike( x: ndarray, options: Int8Options ): int8ndarray;
|
|
|
856
925
|
* @param options.dtype - output array data type
|
|
857
926
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
858
927
|
* @param options.shape - output array shape
|
|
928
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
929
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
930
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
859
931
|
* @returns zero-filled array
|
|
860
932
|
*
|
|
861
933
|
* @example
|
|
@@ -893,6 +965,9 @@ declare function zerosLike( x: ndarray, options: Uint32Options ): uint32ndarray;
|
|
|
893
965
|
* @param options.dtype - output array data type
|
|
894
966
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
895
967
|
* @param options.shape - output array shape
|
|
968
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
969
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
970
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
896
971
|
* @returns zero-filled array
|
|
897
972
|
*
|
|
898
973
|
* @example
|
|
@@ -930,6 +1005,9 @@ declare function zerosLike( x: ndarray, options: Uint16Options ): uint16ndarray;
|
|
|
930
1005
|
* @param options.dtype - output array data type
|
|
931
1006
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
932
1007
|
* @param options.shape - output array shape
|
|
1008
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
1009
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
1010
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
933
1011
|
* @returns zero-filled array
|
|
934
1012
|
*
|
|
935
1013
|
* @example
|
|
@@ -967,6 +1045,9 @@ declare function zerosLike( x: ndarray, options: Uint8Options ): uint8ndarray;
|
|
|
967
1045
|
* @param options.dtype - output array data type
|
|
968
1046
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
969
1047
|
* @param options.shape - output array shape
|
|
1048
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
1049
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
1050
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
970
1051
|
* @returns zero-filled array
|
|
971
1052
|
*
|
|
972
1053
|
* @example
|
|
@@ -1004,6 +1085,9 @@ declare function zerosLike( x: ndarray, options: Uint8COptions ): uint8cndarray;
|
|
|
1004
1085
|
* @param options.dtype - output array data type
|
|
1005
1086
|
* @param options.order - specifies whether the output array is 'row-major' (C-style) or 'column-major' (Fortran-style)
|
|
1006
1087
|
* @param options.shape - output array shape
|
|
1088
|
+
* @param options.mode - specifies how to handle a linear index which exceeds array dimensions
|
|
1089
|
+
* @param options.submode - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
1090
|
+
* @param options.readonly - boolean indicating whether an array should be read-only
|
|
1007
1091
|
* @returns zero-filled array
|
|
1008
1092
|
*
|
|
1009
1093
|
* @example
|
package/lib/main.js
CHANGED
|
@@ -29,6 +29,7 @@ var strides2offset = require( '@stdlib/ndarray-base-strides2offset' );
|
|
|
29
29
|
var buffer = require( '@stdlib/ndarray-base-buffer' );
|
|
30
30
|
var numel = require( '@stdlib/ndarray-base-numel' );
|
|
31
31
|
var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
32
|
+
var format = require( '@stdlib/string-format' );
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
// MAIN //
|
|
@@ -41,11 +42,15 @@ var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
|
41
42
|
* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)
|
|
42
43
|
* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)
|
|
43
44
|
* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)
|
|
45
|
+
* @param {string} [options.mode="throw"] - specifies how to handle indices which exceed array dimensions
|
|
46
|
+
* @param {StringArray} [options.submode=["throw"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis
|
|
47
|
+
* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only
|
|
44
48
|
* @throws {TypeError} first argument must have a recognized data type
|
|
45
49
|
* @throws {TypeError} options argument must be an object
|
|
46
50
|
* @throws {TypeError} `dtype` option must be a supported ndarray data type
|
|
47
51
|
* @throws {TypeError} `order` option must be a supported order
|
|
48
52
|
* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers
|
|
53
|
+
* @throws {TypeError} must provide valid options
|
|
49
54
|
* @returns {ndarray} ndarray
|
|
50
55
|
*
|
|
51
56
|
* @example
|
|
@@ -65,64 +70,76 @@ var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
|
65
70
|
*/
|
|
66
71
|
function zerosLike( x ) {
|
|
67
72
|
var options;
|
|
73
|
+
var dtype;
|
|
74
|
+
var order;
|
|
68
75
|
var ndims;
|
|
69
76
|
var opts;
|
|
70
77
|
var buf;
|
|
71
78
|
var len;
|
|
72
79
|
var st;
|
|
80
|
+
var sh;
|
|
73
81
|
|
|
74
82
|
if ( !isndarrayLike( x ) ) {
|
|
75
|
-
throw new TypeError( 'invalid argument. First argument must be an ndarray-like object. Value:
|
|
83
|
+
throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
|
|
76
84
|
}
|
|
77
85
|
opts = {};
|
|
78
86
|
if ( arguments.length > 1 ) {
|
|
79
87
|
options = arguments[ 1 ];
|
|
80
88
|
if ( !isPlainObject( options ) ) {
|
|
81
|
-
throw new TypeError( 'invalid argument. Options argument must be an object. Value:
|
|
89
|
+
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
|
|
82
90
|
}
|
|
83
91
|
if ( hasOwnProp( options, 'dtype' ) ) {
|
|
84
|
-
|
|
92
|
+
dtype = options.dtype;
|
|
85
93
|
} else {
|
|
86
|
-
|
|
94
|
+
dtype = x.dtype;
|
|
87
95
|
}
|
|
88
96
|
if ( hasOwnProp( options, 'shape' ) ) {
|
|
89
|
-
|
|
90
|
-
if ( typeof
|
|
91
|
-
|
|
97
|
+
sh = options.shape;
|
|
98
|
+
if ( typeof sh === 'number' ) {
|
|
99
|
+
sh = [ sh ];
|
|
92
100
|
}
|
|
93
|
-
if ( !isNonNegativeIntegerArray(
|
|
94
|
-
throw new TypeError( 'invalid option. `
|
|
101
|
+
if ( !isNonNegativeIntegerArray( sh ) ) {
|
|
102
|
+
throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );
|
|
95
103
|
}
|
|
96
104
|
} else {
|
|
97
|
-
|
|
105
|
+
sh = x.shape;
|
|
98
106
|
}
|
|
99
107
|
if ( hasOwnProp( options, 'order' ) ) {
|
|
100
|
-
|
|
108
|
+
order = options.order;
|
|
101
109
|
} else {
|
|
102
|
-
|
|
110
|
+
order = x.order;
|
|
111
|
+
}
|
|
112
|
+
if ( hasOwnProp( options, 'mode' ) ) {
|
|
113
|
+
opts.mode = options.mode;
|
|
114
|
+
}
|
|
115
|
+
if ( hasOwnProp( options, 'submode' ) ) {
|
|
116
|
+
opts.submode = options.submode;
|
|
117
|
+
}
|
|
118
|
+
if ( hasOwnProp( options, 'readonly' ) ) {
|
|
119
|
+
opts.readonly = options.readonly;
|
|
103
120
|
}
|
|
104
121
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
dtype = x.dtype;
|
|
123
|
+
sh = x.shape;
|
|
124
|
+
order = x.order;
|
|
108
125
|
}
|
|
109
|
-
ndims =
|
|
126
|
+
ndims = sh.length;
|
|
110
127
|
if ( ndims > 0 ) {
|
|
111
|
-
len = numel(
|
|
128
|
+
len = numel( sh );
|
|
112
129
|
if ( len < 0 ) {
|
|
113
130
|
len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)
|
|
114
131
|
}
|
|
115
|
-
st = shape2strides(
|
|
132
|
+
st = shape2strides( sh, order );
|
|
116
133
|
} else {
|
|
117
134
|
// For 0-dimensional arrays, the buffer should contain a single element...
|
|
118
135
|
len = 1;
|
|
119
136
|
st = [ 0 ];
|
|
120
137
|
}
|
|
121
|
-
buf = buffer(
|
|
138
|
+
buf = buffer( dtype, len );
|
|
122
139
|
if ( buf === null ) {
|
|
123
|
-
throw new TypeError( 'invalid argument. First argument must have a recognized data type. Value:
|
|
140
|
+
throw new TypeError( format( 'invalid argument. First argument must have a recognized data type. Value: `%s`.', dtype ) );
|
|
124
141
|
}
|
|
125
|
-
return new ndarray(
|
|
142
|
+
return new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/ndarray-zeros-like",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Create a zero-filled ndarray having the same shape and data type as a provided ndarray.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,40 +37,42 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.0
|
|
41
|
-
"@stdlib/assert-is-ndarray-like": "^0.0
|
|
42
|
-
"@stdlib/assert-is-nonnegative-integer-array": "^0.0
|
|
43
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
44
|
-
"@stdlib/ndarray-base-buffer": "^0.0
|
|
45
|
-
"@stdlib/ndarray-base-numel": "^0.0
|
|
46
|
-
"@stdlib/ndarray-base-shape2strides": "^0.0
|
|
47
|
-
"@stdlib/ndarray-base-strides2offset": "^0.0
|
|
48
|
-
"@stdlib/ndarray-ctor": "^0.0
|
|
49
|
-
"@stdlib/
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-ndarray-like": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-nonnegative-integer-array": "^0.1.0",
|
|
43
|
+
"@stdlib/assert-is-plain-object": "^0.1.0",
|
|
44
|
+
"@stdlib/ndarray-base-buffer": "^0.1.0",
|
|
45
|
+
"@stdlib/ndarray-base-numel": "^0.1.0",
|
|
46
|
+
"@stdlib/ndarray-base-shape2strides": "^0.1.0",
|
|
47
|
+
"@stdlib/ndarray-base-strides2offset": "^0.1.0",
|
|
48
|
+
"@stdlib/ndarray-ctor": "^0.1.0",
|
|
49
|
+
"@stdlib/string-format": "^0.1.0",
|
|
50
|
+
"@stdlib/types": "^0.1.0",
|
|
51
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@stdlib/array-complex128": "^0.0
|
|
53
|
-
"@stdlib/array-complex64": "^0.0
|
|
54
|
-
"@stdlib/array-float32": "^0.0
|
|
55
|
-
"@stdlib/array-float64": "^0.0
|
|
56
|
-
"@stdlib/array-int16": "^0.0
|
|
57
|
-
"@stdlib/array-int32": "^0.0
|
|
58
|
-
"@stdlib/array-int8": "^0.0
|
|
59
|
-
"@stdlib/array-uint16": "^0.0
|
|
60
|
-
"@stdlib/array-uint32": "^0.0
|
|
61
|
-
"@stdlib/array-uint8": "^0.0
|
|
62
|
-
"@stdlib/array-uint8c": "^0.0
|
|
63
|
-
"@stdlib/assert-instance-of": "^0.0
|
|
64
|
-
"@stdlib/bench": "^0.0
|
|
65
|
-
"@stdlib/math-base-special-pow": "^0.0
|
|
66
|
-
"@stdlib/ndarray-base-zeros": "^0.0
|
|
67
|
-
"@stdlib/ndarray-dtypes": "^0.0
|
|
68
|
-
"@stdlib/ndarray-zeros": "^0.0
|
|
69
|
-
"@stdlib/strided-base-reinterpret-complex128": "^0.0
|
|
70
|
-
"@stdlib/strided-base-reinterpret-complex64": "^0.0
|
|
54
|
+
"@stdlib/array-complex128": "^0.1.0",
|
|
55
|
+
"@stdlib/array-complex64": "^0.1.0",
|
|
56
|
+
"@stdlib/array-float32": "^0.1.0",
|
|
57
|
+
"@stdlib/array-float64": "^0.1.0",
|
|
58
|
+
"@stdlib/array-int16": "^0.1.0",
|
|
59
|
+
"@stdlib/array-int32": "^0.1.0",
|
|
60
|
+
"@stdlib/array-int8": "^0.1.0",
|
|
61
|
+
"@stdlib/array-uint16": "^0.1.0",
|
|
62
|
+
"@stdlib/array-uint32": "^0.1.0",
|
|
63
|
+
"@stdlib/array-uint8": "^0.1.0",
|
|
64
|
+
"@stdlib/array-uint8c": "^0.1.0",
|
|
65
|
+
"@stdlib/assert-instance-of": "^0.1.0",
|
|
66
|
+
"@stdlib/bench": "^0.1.0",
|
|
67
|
+
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
68
|
+
"@stdlib/ndarray-base-zeros": "^0.1.0",
|
|
69
|
+
"@stdlib/ndarray-dtypes": "^0.1.0",
|
|
70
|
+
"@stdlib/ndarray-zeros": "^0.1.0",
|
|
71
|
+
"@stdlib/strided-base-reinterpret-complex128": "^0.1.0",
|
|
72
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.1.0",
|
|
71
73
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
72
74
|
"istanbul": "^0.4.1",
|
|
73
|
-
"tap-
|
|
75
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
74
76
|
},
|
|
75
77
|
"engines": {
|
|
76
78
|
"node": ">=0.10.0",
|
|
@@ -101,7 +103,7 @@
|
|
|
101
103
|
"zeros"
|
|
102
104
|
],
|
|
103
105
|
"funding": {
|
|
104
|
-
"type": "
|
|
105
|
-
"url": "https://
|
|
106
|
+
"type": "opencollective",
|
|
107
|
+
"url": "https://opencollective.com/stdlib"
|
|
106
108
|
}
|
|
107
109
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( x[, options] )
|
|
3
|
-
Returns a zero-filled ndarray having the same shape and data type as a
|
|
4
|
-
provided input ndarray.
|
|
5
|
-
|
|
6
|
-
The function infers the following attributes from the input array:
|
|
7
|
-
|
|
8
|
-
- shape: array shape.
|
|
9
|
-
- dtype: underlying array data type.
|
|
10
|
-
- order: whether the array order is row-major (C-style) or column-major
|
|
11
|
-
(Fortran-style).
|
|
12
|
-
|
|
13
|
-
Parameters
|
|
14
|
-
----------
|
|
15
|
-
x: ndarray
|
|
16
|
-
Input array.
|
|
17
|
-
|
|
18
|
-
options: Object (optional)
|
|
19
|
-
Options.
|
|
20
|
-
|
|
21
|
-
options.shape: ArrayLikeObject<integer>|integer (optional)
|
|
22
|
-
Array shape. Overrides the input array's inferred shape.
|
|
23
|
-
|
|
24
|
-
options.dtype: string (optional)
|
|
25
|
-
Array data type. Overrides the input array's inferred data type.
|
|
26
|
-
|
|
27
|
-
options.order: string (optional)
|
|
28
|
-
Array order (either 'row-major' (C-style) or 'column-major' (Fortran-
|
|
29
|
-
style)). Overrides the input array's inferred order.
|
|
30
|
-
|
|
31
|
-
Returns
|
|
32
|
-
-------
|
|
33
|
-
out: ndarray
|
|
34
|
-
Output array.
|
|
35
|
-
|
|
36
|
-
Examples
|
|
37
|
-
--------
|
|
38
|
-
> var x = {{alias:@stdlib/ndarray/base/zeros}}( 'float64', [ 2, 2 ], 'row-major' )
|
|
39
|
-
<ndarray>
|
|
40
|
-
> var sh = x.shape
|
|
41
|
-
[ 2, 2 ]
|
|
42
|
-
> var dt = x.dtype
|
|
43
|
-
'float64'
|
|
44
|
-
> var y = {{alias}}( x )
|
|
45
|
-
<ndarray>
|
|
46
|
-
> sh = y.shape
|
|
47
|
-
[ 2, 2 ]
|
|
48
|
-
> dt = y.dtype
|
|
49
|
-
'float64'
|
|
50
|
-
|
|
51
|
-
See Also
|
|
52
|
-
--------
|
|
53
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2022 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
|
-
import zeros = require( '@stdlib/ndarray-base-zeros' );
|
|
20
|
-
import zerosLike = require( './index' );
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// TESTS //
|
|
24
|
-
|
|
25
|
-
// The function returns an ndarray...
|
|
26
|
-
{
|
|
27
|
-
const sh = [ 2, 2 ];
|
|
28
|
-
const ord = 'row-major';
|
|
29
|
-
|
|
30
|
-
zerosLike( zeros( 'float64', sh, ord ) ); // $ExpectType float64ndarray
|
|
31
|
-
zerosLike( zeros( 'float32', sh, ord ) ); // $ExpectType float32ndarray
|
|
32
|
-
zerosLike( zeros( 'complex128', sh, ord ) ); // $ExpectType complex128ndarray
|
|
33
|
-
zerosLike( zeros( 'complex64', sh, ord ) ); // $ExpectType complex64ndarray
|
|
34
|
-
zerosLike( zeros( 'int32', sh, ord ) ); // $ExpectType int32ndarray
|
|
35
|
-
zerosLike( zeros( 'int16', sh, ord ) ); // $ExpectType int16ndarray
|
|
36
|
-
zerosLike( zeros( 'int8', sh, ord ) ); // $ExpectType int8ndarray
|
|
37
|
-
zerosLike( zeros( 'uint32', sh, ord ) ); // $ExpectType uint32ndarray
|
|
38
|
-
zerosLike( zeros( 'uint16', sh, ord ) ); // $ExpectType uint16ndarray
|
|
39
|
-
zerosLike( zeros( 'uint8', sh, ord ) ); // $ExpectType uint8ndarray
|
|
40
|
-
zerosLike( zeros( 'uint8c', sh, ord ) ); // $ExpectType uint8cndarray
|
|
41
|
-
zerosLike( zeros( 'generic', sh, ord ) ); // $ExpectType typedndarray<number>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
zerosLike( zeros( 'float64', sh, ord ), {} ); // $ExpectType float64ndarray
|
|
45
|
-
zerosLike( zeros( 'float32', sh, ord ), {} ); // $ExpectType float32ndarray
|
|
46
|
-
zerosLike( zeros( 'complex128', sh, ord ), {} ); // $ExpectType complex128ndarray
|
|
47
|
-
zerosLike( zeros( 'complex64', sh, ord ), {} ); // $ExpectType complex64ndarray
|
|
48
|
-
zerosLike( zeros( 'int32', sh, ord ), {} ); // $ExpectType int32ndarray
|
|
49
|
-
zerosLike( zeros( 'int16', sh, ord ), {} ); // $ExpectType int16ndarray
|
|
50
|
-
zerosLike( zeros( 'int8', sh, ord ), {} ); // $ExpectType int8ndarray
|
|
51
|
-
zerosLike( zeros( 'uint32', sh, ord ), {} ); // $ExpectType uint32ndarray
|
|
52
|
-
zerosLike( zeros( 'uint16', sh, ord ), {} ); // $ExpectType uint16ndarray
|
|
53
|
-
zerosLike( zeros( 'uint8', sh, ord ), {} ); // $ExpectType uint8ndarray
|
|
54
|
-
zerosLike( zeros( 'uint8c', sh, ord ), {} ); // $ExpectType uint8cndarray
|
|
55
|
-
zerosLike( zeros( 'generic', sh, ord ), {} ); // $ExpectType typedndarray<number>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
zerosLike( zeros( 'float64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float64ndarray
|
|
59
|
-
zerosLike( zeros( 'float32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType float32ndarray
|
|
60
|
-
zerosLike( zeros( 'complex128', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex128ndarray
|
|
61
|
-
zerosLike( zeros( 'complex64', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType complex64ndarray
|
|
62
|
-
zerosLike( zeros( 'int32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int32ndarray
|
|
63
|
-
zerosLike( zeros( 'int16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int16ndarray
|
|
64
|
-
zerosLike( zeros( 'int8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType int8ndarray
|
|
65
|
-
zerosLike( zeros( 'uint32', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint32ndarray
|
|
66
|
-
zerosLike( zeros( 'uint16', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint16ndarray
|
|
67
|
-
zerosLike( zeros( 'uint8', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8ndarray
|
|
68
|
-
zerosLike( zeros( 'uint8c', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType uint8cndarray
|
|
69
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'shape': [ 2, 2, 2 ] } ); // $ExpectType typedndarray<number>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
zerosLike( zeros( 'float64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float64ndarray
|
|
73
|
-
zerosLike( zeros( 'float32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType float32ndarray
|
|
74
|
-
zerosLike( zeros( 'complex128', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex128ndarray
|
|
75
|
-
zerosLike( zeros( 'complex64', sh, ord ), { 'order': 'column-major' } ); // $ExpectType complex64ndarray
|
|
76
|
-
zerosLike( zeros( 'int32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int32ndarray
|
|
77
|
-
zerosLike( zeros( 'int16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int16ndarray
|
|
78
|
-
zerosLike( zeros( 'int8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType int8ndarray
|
|
79
|
-
zerosLike( zeros( 'uint32', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint32ndarray
|
|
80
|
-
zerosLike( zeros( 'uint16', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint16ndarray
|
|
81
|
-
zerosLike( zeros( 'uint8', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8ndarray
|
|
82
|
-
zerosLike( zeros( 'uint8c', sh, ord ), { 'order': 'column-major' } ); // $ExpectType uint8cndarray
|
|
83
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'order': 'column-major' } ); // $ExpectType typedndarray<number>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'float64' } ); // $ExpectType float64ndarray
|
|
87
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'float32' } ); // $ExpectType float32ndarray
|
|
88
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex128' } ); // $ExpectType complex128ndarray
|
|
89
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'complex64' } ); // $ExpectType complex64ndarray
|
|
90
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int32' } ); // $ExpectType int32ndarray
|
|
91
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int16' } ); // $ExpectType int16ndarray
|
|
92
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'int8' } ); // $ExpectType int8ndarray
|
|
93
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint32' } ); // $ExpectType uint32ndarray
|
|
94
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint16' } ); // $ExpectType uint16ndarray
|
|
95
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8' } ); // $ExpectType uint8ndarray
|
|
96
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'uint8c' } ); // $ExpectType uint8cndarray
|
|
97
|
-
zerosLike( zeros( 'generic', sh, ord ), { 'dtype': 'generic' } ); // $ExpectType typedndarray<number>
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// The compiler throws an error if the function is provided a first argument is not an ndarray which has a recognized/supported data type...
|
|
101
|
-
{
|
|
102
|
-
zerosLike( '10' ); // $ExpectError
|
|
103
|
-
zerosLike( 10 ); // $ExpectError
|
|
104
|
-
zerosLike( false ); // $ExpectError
|
|
105
|
-
zerosLike( true ); // $ExpectError
|
|
106
|
-
zerosLike( null ); // $ExpectError
|
|
107
|
-
zerosLike( [] ); // $ExpectError
|
|
108
|
-
zerosLike( {} ); // $ExpectError
|
|
109
|
-
zerosLike( ( x: number ): number => x ); // $ExpectError
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// The compiler throws an error if the function is provided a second argument is not an options object...
|
|
113
|
-
{
|
|
114
|
-
const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
|
|
115
|
-
|
|
116
|
-
zerosLike( x, '10' ); // $ExpectError
|
|
117
|
-
zerosLike( x, 10 ); // $ExpectError
|
|
118
|
-
zerosLike( x, false ); // $ExpectError
|
|
119
|
-
zerosLike( x, true ); // $ExpectError
|
|
120
|
-
zerosLike( x, [] ); // $ExpectError
|
|
121
|
-
zerosLike( x, ( x: number ): number => x ); // $ExpectError
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// The compiler throws an error if the function is provided a `dtype` option which is not a valid data type...
|
|
125
|
-
{
|
|
126
|
-
const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
|
|
127
|
-
|
|
128
|
-
zerosLike( x, { 'dtype': '10' } ); // $ExpectError
|
|
129
|
-
zerosLike( x, { 'dtype': 10 } ); // $ExpectError
|
|
130
|
-
zerosLike( x, { 'dtype': null } ); // $ExpectError
|
|
131
|
-
zerosLike( x, { 'dtype': false } ); // $ExpectError
|
|
132
|
-
zerosLike( x, { 'dtype': true } ); // $ExpectError
|
|
133
|
-
zerosLike( x, { 'dtype': [] } ); // $ExpectError
|
|
134
|
-
zerosLike( x, { 'dtype': {} } ); // $ExpectError
|
|
135
|
-
zerosLike( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// The compiler throws an error if the function is provided an `order` option which is not a valid order...
|
|
139
|
-
{
|
|
140
|
-
const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
|
|
141
|
-
|
|
142
|
-
zerosLike( x, { 'order': '10' } ); // $ExpectError
|
|
143
|
-
zerosLike( x, { 'order': 10 } ); // $ExpectError
|
|
144
|
-
zerosLike( x, { 'order': false } ); // $ExpectError
|
|
145
|
-
zerosLike( x, { 'order': true } ); // $ExpectError
|
|
146
|
-
zerosLike( x, { 'order': [] } ); // $ExpectError
|
|
147
|
-
zerosLike( x, { 'order': {} } ); // $ExpectError
|
|
148
|
-
zerosLike( x, { 'order': ( x: number ): number => x } ); // $ExpectError
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// The compiler throws an error if the function is provided a `shape` option which is not a valid shape...
|
|
152
|
-
{
|
|
153
|
-
const x = zeros( 'generic', [ 2, 2 ], 'row-major' );
|
|
154
|
-
|
|
155
|
-
zerosLike( x, { 'shape': '10' } ); // $ExpectError
|
|
156
|
-
zerosLike( x, { 'shape': false } ); // $ExpectError
|
|
157
|
-
zerosLike( x, { 'shape': true } ); // $ExpectError
|
|
158
|
-
zerosLike( x, { 'shape': [ '5' ] } ); // $ExpectError
|
|
159
|
-
zerosLike( x, { 'shape': {} } ); // $ExpectError
|
|
160
|
-
zerosLike( x, { 'shape': ( x: number ): number => x } ); // $ExpectError
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
164
|
-
{
|
|
165
|
-
zerosLike(); // $ExpectError
|
|
166
|
-
zerosLike( zeros( 'float64', [ 2, 2 ], 'row-major' ), {}, 1 ); // $ExpectError
|
|
167
|
-
}
|