Skip to content

Commit 24b0647

Browse files
committed
Auto-generated commit
1 parent de6f9cf commit 24b0647

13 files changed

+746
-37
lines changed

.github/workflows/test_coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ jobs:
7272
env:
7373
webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }}
7474
webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }}
75-
data: '${{ steps.extract-coverage.outputs.coverage }}'
75+
data: '{ "coverage": ${{ steps.extract-coverage.outputs.coverage }}, "run_id": "${{ github.run_id }}" }'
7676
if: ${{ false }}

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The function recognizes the following data types:
6565

6666
- `float64`: double-precision floating-point numbers (IEEE 754)
6767
- `float32`: single-precision floating-point numbers (IEEE 754)
68+
- `complex128`: double-precision complex floating-point numbers
69+
- `complex64`: single-precision complex floating-point numbers
6870
- `int32`: 32-bit two's complement signed integers
6971
- `uint32`: 32-bit unsigned integers
7072
- `int16`: 16-bit two's complement signed integers
@@ -190,13 +192,13 @@ arr = filledarray( 1, buf, 10, 4, 'int16' );
190192

191193
```javascript
192194
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
193-
var dtypes = require( '@stdlib/array-dtypes' );
195+
var dtypes = require( '@stdlib/array-typed-dtypes' );
194196
var filledarray = require( '@stdlib/array-filled' );
195197

196198
// Generate a random number:
197199
var r = discreteUniform( 0, 100 );
198200

199-
// Get the list of supported array data types:
201+
// Get a list of array data types:
200202
var dt = dtypes();
201203

202204
// Generate filled arrays...

benchmark/benchmark.js

+57-11
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var isTypedArray = require( '@stdlib/assert-is-typed-array' );
24+
var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );
2525
var isArray = require( '@stdlib/assert-is-array' );
26+
var Complex64 = require( '@stdlib/complex-float32' );
27+
var Complex128 = require( '@stdlib/complex-float64' );
2628
var pkg = require( './../package.json' ).name;
2729
var filledarray = require( './../lib' );
2830

@@ -40,7 +42,7 @@ bench( pkg, function benchmark( b ) {
4042
}
4143
}
4244
b.toc();
43-
if ( !isTypedArray( arr ) ) {
45+
if ( !isTypedArrayLike( arr ) ) {
4446
b.fail( 'should return a typed array' );
4547
}
4648
b.pass( 'benchmark finished' );
@@ -58,7 +60,7 @@ bench( pkg+':dtype=float64', function benchmark( b ) {
5860
}
5961
}
6062
b.toc();
61-
if ( !isTypedArray( arr ) ) {
63+
if ( !isTypedArrayLike( arr ) ) {
6264
b.fail( 'should return a typed array' );
6365
}
6466
b.pass( 'benchmark finished' );
@@ -76,7 +78,51 @@ bench( pkg+':dtype=float32', function benchmark( b ) {
7678
}
7779
}
7880
b.toc();
79-
if ( !isTypedArray( arr ) ) {
81+
if ( !isTypedArrayLike( arr ) ) {
82+
b.fail( 'should return a typed array' );
83+
}
84+
b.pass( 'benchmark finished' );
85+
b.end();
86+
});
87+
88+
bench( pkg+':dtype=complex128', function benchmark( b ) {
89+
var arr;
90+
var v;
91+
var i;
92+
93+
v = new Complex128( 3.0, 5.0 );
94+
95+
b.tic();
96+
for ( i = 0; i < b.iterations; i++ ) {
97+
arr = filledarray( v, 0, 'complex128' );
98+
if ( arr.length !== 0 ) {
99+
b.fail( 'should have length 0' );
100+
}
101+
}
102+
b.toc();
103+
if ( !isTypedArrayLike( arr ) ) {
104+
b.fail( 'should return a typed array' );
105+
}
106+
b.pass( 'benchmark finished' );
107+
b.end();
108+
});
109+
110+
bench( pkg+':dtype=complex64', function benchmark( b ) {
111+
var arr;
112+
var v;
113+
var i;
114+
115+
v = new Complex64( 3.0, 5.0 );
116+
117+
b.tic();
118+
for ( i = 0; i < b.iterations; i++ ) {
119+
arr = filledarray( v, 0, 'complex64' );
120+
if ( arr.length !== 0 ) {
121+
b.fail( 'should have length 0' );
122+
}
123+
}
124+
b.toc();
125+
if ( !isTypedArrayLike( arr ) ) {
80126
b.fail( 'should return a typed array' );
81127
}
82128
b.pass( 'benchmark finished' );
@@ -94,7 +140,7 @@ bench( pkg+':dtype=int32', function benchmark( b ) {
94140
}
95141
}
96142
b.toc();
97-
if ( !isTypedArray( arr ) ) {
143+
if ( !isTypedArrayLike( arr ) ) {
98144
b.fail( 'should return a typed array' );
99145
}
100146
b.pass( 'benchmark finished' );
@@ -112,7 +158,7 @@ bench( pkg+':dtype=uint32', function benchmark( b ) {
112158
}
113159
}
114160
b.toc();
115-
if ( !isTypedArray( arr ) ) {
161+
if ( !isTypedArrayLike( arr ) ) {
116162
b.fail( 'should return a typed array' );
117163
}
118164
b.pass( 'benchmark finished' );
@@ -130,7 +176,7 @@ bench( pkg+':dtype=int16', function benchmark( b ) {
130176
}
131177
}
132178
b.toc();
133-
if ( !isTypedArray( arr ) ) {
179+
if ( !isTypedArrayLike( arr ) ) {
134180
b.fail( 'should return a typed array' );
135181
}
136182
b.pass( 'benchmark finished' );
@@ -148,7 +194,7 @@ bench( pkg+':dtype=uint16', function benchmark( b ) {
148194
}
149195
}
150196
b.toc();
151-
if ( !isTypedArray( arr ) ) {
197+
if ( !isTypedArrayLike( arr ) ) {
152198
b.fail( 'should return a typed array' );
153199
}
154200
b.pass( 'benchmark finished' );
@@ -166,7 +212,7 @@ bench( pkg+':dtype=int8', function benchmark( b ) {
166212
}
167213
}
168214
b.toc();
169-
if ( !isTypedArray( arr ) ) {
215+
if ( !isTypedArrayLike( arr ) ) {
170216
b.fail( 'should return a typed array' );
171217
}
172218
b.pass( 'benchmark finished' );
@@ -184,7 +230,7 @@ bench( pkg+':dtype=uint8', function benchmark( b ) {
184230
}
185231
}
186232
b.toc();
187-
if ( !isTypedArray( arr ) ) {
233+
if ( !isTypedArrayLike( arr ) ) {
188234
b.fail( 'should return a typed array' );
189235
}
190236
b.pass( 'benchmark finished' );
@@ -202,7 +248,7 @@ bench( pkg+':dtype=uint8c', function benchmark( b ) {
202248
}
203249
}
204250
b.toc();
205-
if ( !isTypedArray( arr ) ) {
251+
if ( !isTypedArrayLike( arr ) ) {
206252
b.fail( 'should return a typed array' );
207253
}
208254
b.pass( 'benchmark finished' );
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math-base-special-pow' );
25+
var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );
26+
var Complex128 = require( '@stdlib/complex-float64' );
27+
var pkg = require( './../package.json' ).name;
28+
var filledarray = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
return benchmark;
42+
43+
/**
44+
* Benchmark function.
45+
*
46+
* @private
47+
* @param {Benchmark} b - benchmark instance
48+
*/
49+
function benchmark( b ) {
50+
var arr;
51+
var v;
52+
var i;
53+
54+
v = new Complex128( 1.0, 1.0 );
55+
56+
b.tic();
57+
for ( i = 0; i < b.iterations; i++ ) {
58+
arr = filledarray( v, len, 'complex128' );
59+
if ( arr.length !== len ) {
60+
b.fail( 'unexpected length' );
61+
}
62+
}
63+
b.toc();
64+
if ( !isTypedArrayLike( arr ) ) {
65+
b.fail( 'should return a typed array' );
66+
}
67+
b.pass( 'benchmark finished' );
68+
b.end();
69+
}
70+
}
71+
72+
73+
// MAIN //
74+
75+
/**
76+
* Main execution sequence.
77+
*
78+
* @private
79+
*/
80+
function main() {
81+
var len;
82+
var min;
83+
var max;
84+
var f;
85+
var i;
86+
87+
min = 1; // 10^min
88+
max = 6; // 10^max
89+
90+
for ( i = min; i <= max; i++ ) {
91+
len = pow( 10, i );
92+
f = createBenchmark( len );
93+
bench( pkg+':dtype=complex128,len='+len, f );
94+
}
95+
}
96+
97+
main();
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math-base-special-pow' );
25+
var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );
26+
var Complex64 = require( '@stdlib/complex-float32' );
27+
var pkg = require( './../package.json' ).name;
28+
var filledarray = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
return benchmark;
42+
43+
/**
44+
* Benchmark function.
45+
*
46+
* @private
47+
* @param {Benchmark} b - benchmark instance
48+
*/
49+
function benchmark( b ) {
50+
var arr;
51+
var v;
52+
var i;
53+
54+
v = new Complex64( 1.0, 1.0 );
55+
56+
b.tic();
57+
for ( i = 0; i < b.iterations; i++ ) {
58+
arr = filledarray( v, len, 'complex64' );
59+
if ( arr.length !== len ) {
60+
b.fail( 'unexpected length' );
61+
}
62+
}
63+
b.toc();
64+
if ( !isTypedArrayLike( arr ) ) {
65+
b.fail( 'should return a typed array' );
66+
}
67+
b.pass( 'benchmark finished' );
68+
b.end();
69+
}
70+
}
71+
72+
73+
// MAIN //
74+
75+
/**
76+
* Main execution sequence.
77+
*
78+
* @private
79+
*/
80+
function main() {
81+
var len;
82+
var min;
83+
var max;
84+
var f;
85+
var i;
86+
87+
min = 1; // 10^min
88+
max = 6; // 10^max
89+
90+
for ( i = min; i <= max; i++ ) {
91+
len = pow( 10, i );
92+
f = createBenchmark( len );
93+
bench( pkg+':dtype=complex64,len='+len, f );
94+
}
95+
}
96+
97+
main();

docs/repl.txt

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- float64: double-precision floating-point numbers (IEEE 754)
88
- float32: single-precision floating-point numbers (IEEE 754)
9+
- complex128: double-precision complex floating-point numbers
10+
- complex64: single-precision complex floating-point numbers
911
- int32: 32-bit two's complement signed integers
1012
- uint32: 32-bit unsigned integers
1113
- int16: 16-bit two's complement signed integers

0 commit comments

Comments
 (0)