Skip to content

Commit 33e79b3

Browse files
committed
Add package to create a filled array having a specified length
1 parent cfcdc57 commit 33e79b3

22 files changed

+2491
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
# full
22+
23+
> Create a filled array having a specified length.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var full = require( '@stdlib/array/full' );
41+
```
42+
43+
#### full( length, value\[, dtype] )
44+
45+
Creates a filled array having a specified length.
46+
47+
```javascript
48+
var arr = full( 2, 1.0 );
49+
// returns <Float64Array>[ 1.0, 1.0 ]
50+
```
51+
52+
The function recognizes the following data types:
53+
54+
- `float64`: double-precision floating-point numbers (IEEE 754)
55+
- `float32`: single-precision floating-point numbers (IEEE 754)
56+
- `complex128`: double-precision complex floating-point numbers
57+
- `complex64`: single-precision complex floating-point numbers
58+
- `int32`: 32-bit two's complement signed integers
59+
- `uint32`: 32-bit unsigned integers
60+
- `int16`: 16-bit two's complement signed integers
61+
- `uint16`: 16-bit unsigned integers
62+
- `int8`: 8-bit two's complement signed integers
63+
- `uint8`: 8-bit unsigned integers
64+
- `uint8c`: 8-bit unsigned integers clamped to `0-255`
65+
- `generic`: generic JavaScript values
66+
67+
By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument.
68+
69+
```javascript
70+
var arr = full( 2, 1, 'int32' );
71+
// returns <Int32Array>[ 1, 1 ]
72+
```
73+
74+
</section>
75+
76+
<!-- /.usage -->
77+
78+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
79+
80+
<section class="notes">
81+
82+
</section>
83+
84+
<!-- /.notes -->
85+
86+
<!-- Package usage examples. -->
87+
88+
<section class="examples">
89+
90+
## Examples
91+
92+
<!-- eslint no-undef: "error" -->
93+
94+
```javascript
95+
var dtypes = require( '@stdlib/array/typed-real-dtypes' );
96+
var full = require( '@stdlib/array/full' );
97+
98+
// Get a list of array data types:
99+
var dt = dtypes();
100+
101+
// Generate filled arrays...
102+
var arr;
103+
var i;
104+
for ( i = 0; i < dt.length; i++ ) {
105+
arr = full( 5, i+1, dt[ i ] );
106+
console.log( arr );
107+
}
108+
```
109+
110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<!-- 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. -->
115+
116+
<section class="references">
117+
118+
</section>
119+
120+
<!-- /.references -->
121+
122+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
123+
124+
<section class="related">
125+
126+
</section>
127+
128+
<!-- /.related -->
129+
130+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
131+
132+
<section class="links">
133+
134+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
135+
136+
</section>
137+
138+
<!-- /.links -->

0 commit comments

Comments
 (0)