@stdlib/ndarray-zeros-like 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +481 -0
- package/NOTICE +1 -0
- package/README.md +239 -0
- package/docs/repl.txt +53 -0
- package/docs/types/index.d.ts +1037 -0
- package/docs/types/test.ts +167 -0
- package/lib/index.js +50 -0
- package/lib/main.js +131 -0
- package/package.json +107 -0
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
# zerosLike
|
|
22
|
+
|
|
23
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
|
+
|
|
25
|
+
> Create a zero-filled [ndarray][@stdlib/ndarray/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
|
|
26
|
+
|
|
27
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
28
|
+
|
|
29
|
+
<section class="intro">
|
|
30
|
+
|
|
31
|
+
</section>
|
|
32
|
+
|
|
33
|
+
<!-- /.intro -->
|
|
34
|
+
|
|
35
|
+
<!-- Package usage documentation. -->
|
|
36
|
+
|
|
37
|
+
<section class="installation">
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @stdlib/ndarray-zeros-like
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</section>
|
|
46
|
+
|
|
47
|
+
<section class="usage">
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
var zerosLike = require( '@stdlib/ndarray-zeros-like' );
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### zerosLike( x\[, options] )
|
|
56
|
+
|
|
57
|
+
Creates a zero-filled [ndarray][@stdlib/ndarray/ctor] having the same shape and [data type][@stdlib/ndarray/dtypes] as a provided ndarray.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
var zeros = require( '@stdlib/ndarray-zeros' );
|
|
61
|
+
|
|
62
|
+
var x = zeros( [ 2, 2 ] );
|
|
63
|
+
// returns <ndarray>
|
|
64
|
+
|
|
65
|
+
var y = zerosLike( x );
|
|
66
|
+
// returns <ndarray>
|
|
67
|
+
|
|
68
|
+
var sh = y.shape;
|
|
69
|
+
// returns [ 2, 2 ]
|
|
70
|
+
|
|
71
|
+
var dt = y.dtype;
|
|
72
|
+
// returns 'float64'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The function supports the following `options`:
|
|
76
|
+
|
|
77
|
+
- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes]. Overrides the input ndarray's inferred [data type][@stdlib/ndarray/dtypes].
|
|
78
|
+
- **shape**: output [ndarray][@stdlib/ndarray/ctor] shape. Overrides the input ndarray's inferred shape.
|
|
79
|
+
- **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.
|
|
80
|
+
|
|
81
|
+
To override either the `dtype`, `shape`, or `order`, specify the corresponding option. For example, to override the inferred [data type][@stdlib/ndarray/dtypes],
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
var zeros = require( '@stdlib/ndarray-zeros' );
|
|
85
|
+
|
|
86
|
+
var x = zeros( [ 2, 2 ] );
|
|
87
|
+
// returns <ndarray>
|
|
88
|
+
|
|
89
|
+
var dt = x.dtype;
|
|
90
|
+
// returns 'float64'
|
|
91
|
+
|
|
92
|
+
var y = zerosLike( x, {
|
|
93
|
+
'dtype': 'int32'
|
|
94
|
+
});
|
|
95
|
+
// returns <ndarray>
|
|
96
|
+
|
|
97
|
+
var sh = y.shape;
|
|
98
|
+
// returns [ 2, 2 ]
|
|
99
|
+
|
|
100
|
+
dt = y.dtype;
|
|
101
|
+
// returns 'int32'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
</section>
|
|
105
|
+
|
|
106
|
+
<!-- /.usage -->
|
|
107
|
+
|
|
108
|
+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
109
|
+
|
|
110
|
+
<section class="notes">
|
|
111
|
+
|
|
112
|
+
</section>
|
|
113
|
+
|
|
114
|
+
<!-- /.notes -->
|
|
115
|
+
|
|
116
|
+
<!-- Package usage examples. -->
|
|
117
|
+
|
|
118
|
+
<section class="examples">
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
<!-- eslint no-undef: "error" -->
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
var dtypes = require( '@stdlib/ndarray-dtypes' );
|
|
126
|
+
var zeros = require( '@stdlib/ndarray-zeros' );
|
|
127
|
+
var zerosLike = require( '@stdlib/ndarray-zeros-like' );
|
|
128
|
+
|
|
129
|
+
// Get a list of data types:
|
|
130
|
+
var dt = dtypes();
|
|
131
|
+
|
|
132
|
+
// Generate zero-filled arrays...
|
|
133
|
+
var x;
|
|
134
|
+
var y;
|
|
135
|
+
var i;
|
|
136
|
+
for ( i = 0; i < dt.length; i++ ) {
|
|
137
|
+
x = zeros( [ 2, 2 ], {
|
|
138
|
+
'dtype': dt[ i ]
|
|
139
|
+
});
|
|
140
|
+
y = zerosLike( x );
|
|
141
|
+
console.log( y.data );
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
</section>
|
|
146
|
+
|
|
147
|
+
<!-- /.examples -->
|
|
148
|
+
|
|
149
|
+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
150
|
+
|
|
151
|
+
<section class="references">
|
|
152
|
+
|
|
153
|
+
</section>
|
|
154
|
+
|
|
155
|
+
<!-- /.references -->
|
|
156
|
+
|
|
157
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
158
|
+
|
|
159
|
+
<section class="related">
|
|
160
|
+
|
|
161
|
+
</section>
|
|
162
|
+
|
|
163
|
+
<!-- /.related -->
|
|
164
|
+
|
|
165
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<section class="main-repo" >
|
|
169
|
+
|
|
170
|
+
* * *
|
|
171
|
+
|
|
172
|
+
## Notice
|
|
173
|
+
|
|
174
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
175
|
+
|
|
176
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
177
|
+
|
|
178
|
+
#### Community
|
|
179
|
+
|
|
180
|
+
[![Chat][chat-image]][chat-url]
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
See [LICENSE][stdlib-license].
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
## Copyright
|
|
190
|
+
|
|
191
|
+
Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
192
|
+
|
|
193
|
+
</section>
|
|
194
|
+
|
|
195
|
+
<!-- /.stdlib -->
|
|
196
|
+
|
|
197
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
198
|
+
|
|
199
|
+
<section class="links">
|
|
200
|
+
|
|
201
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-zeros-like.svg
|
|
202
|
+
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-zeros-like
|
|
203
|
+
|
|
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
|
|
206
|
+
|
|
207
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-zeros-like/main.svg
|
|
208
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-zeros-like?branch=main
|
|
209
|
+
|
|
210
|
+
<!--
|
|
211
|
+
|
|
212
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/ndarray-zeros-like.svg
|
|
213
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/ndarray-zeros-like/main
|
|
214
|
+
|
|
215
|
+
-->
|
|
216
|
+
|
|
217
|
+
[umd]: https://github.com/umdjs/umd
|
|
218
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
219
|
+
|
|
220
|
+
[deno-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/deno
|
|
221
|
+
[umd-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/umd
|
|
222
|
+
[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
|
|
230
|
+
|
|
231
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros-like/main/LICENSE
|
|
232
|
+
|
|
233
|
+
[@stdlib/ndarray/ctor]: https://www.npmjs.com/package/@stdlib/stdlib
|
|
234
|
+
|
|
235
|
+
[@stdlib/ndarray/dtypes]: https://www.npmjs.com/package/@stdlib/stdlib
|
|
236
|
+
|
|
237
|
+
</section>
|
|
238
|
+
|
|
239
|
+
<!-- /.links -->
|
package/docs/repl.txt
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
|