Skip to content

Commit fa07a54

Browse files
committed
Auto-generated commit
1 parent b6e2728 commit fa07a54

10 files changed

Lines changed: 722 additions & 8 deletions

File tree

.github/workflows/npm_downloads.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ jobs:
102102

103103
# Send data to events server:
104104
- name: 'Post data'
105-
# Pin action to full length commit SHA corresponding to v3.0.3:
106-
uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629
105+
# Pin action to full length commit SHA
106+
uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3
107107
env:
108108
webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }}
109109
webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }}

.github/workflows/test_coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ jobs:
119119

120120
# Send data to events server:
121121
- name: 'Post data'
122-
# Pin action to full length commit SHA corresponding to v3.0.3:
123-
uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629
122+
# Pin action to full length commit SHA
123+
uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3
124124
env:
125125
webhook_url: ${{ secrets.STDLIB_COVERAGE_URL }}
126126
webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }}

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,100 @@ var count = context.count;
16381638
// returns 2
16391639
```
16401640

1641+
<a name="method-subarray"></a>
1642+
1643+
#### Complex64Array.prototype.subarray( \[begin\[, end]] )
1644+
1645+
Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array.
1646+
1647+
```javascript
1648+
var realf = require( '@stdlib/complex-realf' );
1649+
var imagf = require( '@stdlib/complex-imagf' );
1650+
1651+
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1652+
1653+
var subarr = arr.subarray();
1654+
// returns <Complex64Array>
1655+
1656+
var len = subarr.length;
1657+
// returns 4
1658+
1659+
var z = subarr.get( 0 );
1660+
// returns <Complex64>
1661+
1662+
var re = realf( z );
1663+
// returns 1.0
1664+
1665+
var im = imagf( z );
1666+
// returns 2.0
1667+
1668+
z = subarr.get( len-1 );
1669+
// returns <Complex64>
1670+
1671+
re = realf( z );
1672+
// returns 7.0
1673+
1674+
im = imagf( z );
1675+
// returns 8.0
1676+
```
1677+
1678+
By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive).
1679+
1680+
```javascript
1681+
var imagf = require( '@stdlib/complex-imagf' );
1682+
var realf = require( '@stdlib/complex-realf' );
1683+
1684+
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1685+
1686+
var subarr = arr.subarray( 1 );
1687+
// returns <Complex64Array>
1688+
1689+
var len = subarr.length;
1690+
// returns 3
1691+
1692+
var z = subarr.get( 0 );
1693+
// returns <Complex64>
1694+
1695+
var re = realf( z );
1696+
// returns 3.0
1697+
1698+
var im = imagf( z );
1699+
// returns 4.0
1700+
```
1701+
1702+
By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive).
1703+
1704+
```javascript
1705+
var realf = require( '@stdlib/complex-realf' );
1706+
var imagf = require( '@stdlib/complex-imagf' );
1707+
1708+
var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
1709+
1710+
var subarr = arr.subarray( 1, -1 );
1711+
// returns <Complex64Array>
1712+
1713+
var len = subarr.length;
1714+
// returns 2
1715+
1716+
var z = subarr.get( 0 );
1717+
// returns <Complex64>
1718+
1719+
var re = realf( z );
1720+
// returns 3.0
1721+
1722+
var im = imagf( z );
1723+
// returns 4.0
1724+
1725+
z = subarr.get( len-1 );
1726+
// returns <Complex64>
1727+
1728+
re = realf( z );
1729+
// returns 5.0
1730+
1731+
im = imagf( z );
1732+
// returns 6.0
1733+
```
1734+
16411735
</section>
16421736

16431737
<!-- /.usage -->

benchmark/benchmark.subarray.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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-harness' );
24+
var isComplex64Array = require( '@stdlib/assert-is-complex64array' );
25+
var pkg = require( './../package.json' ).name;
26+
var Complex64Array = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg+':subarray', function benchmark( b ) {
32+
var out;
33+
var arr;
34+
var i;
35+
36+
arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] );
37+
38+
b.tic();
39+
for ( i = 0; i < b.iterations; i++ ) {
40+
out = arr.subarray();
41+
if ( typeof out !== 'object' ) {
42+
b.fail( 'should return an object' );
43+
}
44+
}
45+
b.toc();
46+
if ( !isComplex64Array( out ) ) {
47+
b.fail( 'should return a Complex64Array' );
48+
}
49+
b.pass( 'benchmark finished' );
50+
b.end();
51+
});
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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-harness' );
24+
var isComplex64Array = require( '@stdlib/assert-is-complex64array' );
25+
var pow = require( '@stdlib/math-base-special-pow' );
26+
var Complex64 = require( '@stdlib/complex-float32' );
27+
var pkg = require( './../package.json' ).name;
28+
var Complex64Array = 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+
var arr;
42+
var i;
43+
44+
arr = [];
45+
for ( i = 0; i < len; i++ ) {
46+
arr.push( new Complex64( i, i ) );
47+
}
48+
arr = new Complex64Array( arr );
49+
50+
return benchmark;
51+
52+
/**
53+
* Benchmark function.
54+
*
55+
* @private
56+
* @param {Benchmark} b - benchmark instance
57+
*/
58+
function benchmark( b ) {
59+
var out;
60+
var i;
61+
62+
b.tic();
63+
for ( i = 0; i < b.iterations; i++ ) {
64+
out = arr.subarray();
65+
if ( typeof out !== 'object' ) {
66+
b.fail( 'should return an object' );
67+
}
68+
}
69+
b.toc();
70+
if ( !isComplex64Array( out ) ) {
71+
b.fail( 'should return a Complex64Array' );
72+
}
73+
b.pass( 'benchmark finished' );
74+
b.end();
75+
}
76+
}
77+
78+
79+
// MAIN //
80+
81+
/**
82+
* Main execution sequence.
83+
*
84+
* @private
85+
*/
86+
function main() {
87+
var len;
88+
var min;
89+
var max;
90+
var f;
91+
var i;
92+
93+
min = 1; // 10^min
94+
max = 6; // 10^max
95+
96+
for ( i = min; i <= max; i++ ) {
97+
len = pow( 10, i );
98+
f = createBenchmark( len );
99+
bench( pkg+':subarray:len='+len, f );
100+
}
101+
}
102+
103+
main();

0 commit comments

Comments
 (0)