Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Apr 14, 2024
1 parent a0e1071 commit a47230a
Show file tree
Hide file tree
Showing 12 changed files with 641 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/productionize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down Expand Up @@ -518,7 +517,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down Expand Up @@ -698,7 +696,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,5 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()
3 changes: 0 additions & 3 deletions .github/workflows/test_bundles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down Expand Up @@ -139,7 +138,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down Expand Up @@ -184,6 +182,5 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()
5 changes: 3 additions & 2 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ jobs:
- name: 'Upload coverage to Codecov'
id: upload
# Pin action to full length commit SHA
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0
with:
directory: reports/coverage
flags: unittests
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# Extract coverage value:
- name: 'Extract coverage value and assign to output'
Expand Down Expand Up @@ -117,7 +119,6 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,5 @@ jobs:
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#npm-ci'
if: failure()
52 changes: 51 additions & 1 deletion complex64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ var bool = it.next().done;
// returns true
```

The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:

- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.

<a name="method-every"></a>

#### Complex64Array.prototype.every( predicate\[, thisArg] )
Expand Down Expand Up @@ -2222,9 +2227,52 @@ var str = arr.toString();
// returns '1 + 1i,2 - 2i,3 + 3i'
```

<a name="method-values"></a>

#### Complex64Array.prototype.values()

Returns an iterator for iterating over each value in a typed array.

```javascript
var realf = require( '@stdlib/complex/realf' );
var imagf = require( '@stdlib/complex/imagf' );
var arr = new Complex64Array( 2 );

arr.set( [ 1.0, -1.0 ], 0 );
arr.set( [ 2.0, -2.0 ], 1 );

var iter = arr.values();

var v = iter.next().value;
// returns <Complex64>

var re = realf( v );
// returns 1.0

var im = imagf( v );
// returns -1.0

v = iter.next().value;
// returns <Complex64>

re = realf( v );
// returns 2.0

im = imagf( v );
// returns -2.0

var bool = iter.next().done;
// returns true
```

The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:

- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished.
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.

<a name="method-with"></a>

#### Complex128Array.prototype.with( index, value )
#### Complex64Array.prototype.with( index, value )

Returns a new typed array with the element at a provided index replaced with a provided value.

Expand Down Expand Up @@ -2352,6 +2400,8 @@ logEach( '%s', out );

<section class="links">

[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol

[@stdlib/array/typed]: https://github.com/stdlib-js/array/tree/main/typed

[@stdlib/array/buffer]: https://github.com/stdlib-js/array/tree/main/buffer
Expand Down
51 changes: 51 additions & 0 deletions complex64/benchmark/benchmark.values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isIteratorLike = require( '@stdlib/assert/is-iterator-like' );
var pkg = require( './../package.json' ).name;
var Complex64Array = require( './../lib' );


// MAIN //

bench( pkg+':values:len=2', function benchmark( b ) {
var iter;
var arr;
var i;

arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
iter = arr.values();
if ( typeof iter !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isIteratorLike( iter ) ) {
b.fail( 'should return an iterator protocol-compliant object' );
}
b.pass( 'benchmark finished' );
b.end();
});
103 changes: 103 additions & 0 deletions complex64/benchmark/benchmark.values.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex64 = require( '@stdlib/complex/float32' );
var isIteratorLike = require('@stdlib/assert/is-iterator-like');
var pkg = require( './../package.json' ).name;
var Complex64Array = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr;
var i;

arr = [];
for ( i = 0; i < len; i++ ) {
arr.push( new Complex64( i, i ) );
}
arr = new Complex64Array( arr );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var iter;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
iter = arr.values();
if ( typeof iter !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isIteratorLike( iter ) ) {
b.fail( 'should return an iterator protocol-compliant object' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':values:len='+len, f );
}
}

main();
42 changes: 40 additions & 2 deletions complex64/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/// <reference types="@stdlib/types"/>

import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter';
import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter';
import { ArrayLike, RealOrComplexTypedArray, Complex64Array as Complex64ArrayInterface } from '@stdlib/types/array';
import { ComplexLike, Complex64 } from '@stdlib/types/complex';
import ArrayBuffer = require( './../../../buffer' );
Expand Down Expand Up @@ -459,7 +459,7 @@ declare class Complex64Array implements Complex64ArrayInterface {
* var bool = it.next().done;
* // returns true
*/
entries(): Iterator;
entries(): TypedIterator<[number, Complex64]>;

/**
* Tests whether all elements in an array pass a test implemented by a predicate function.
Expand Down Expand Up @@ -1260,6 +1260,44 @@ declare class Complex64Array implements Complex64ArrayInterface {
*/
toString(): string;

/**
* Returns an iterator for iterating over each value in a typed array.
*
* @returns iterator
*
* @example
* var realf = require( '@stdlib/complex/realf' );
* var imagf = require( '@stdlib/complex/imagf' );
* var arr = new Complex64Array( 2 );
*
* arr.set( [ 1.0, -1.0 ], 0 );
* arr.set( [ 2.0, -2.0 ], 1 );
*
* var iter = arr.values();
*
* var v = iter.next().value;
* // returns <Complex64>
*
* var re = realf( v );
* // returns 1.0
*
* var im = imagf( v );
* // returns -1.0
*
* v = iter.next().value;
* // returns <Complex64>
*
* re = realf( v );
* // returns 2.0
*
* im = imagf( v );
* // returns -2.0
*
* var bool = iter.next().done;
* // returns true
*/
values(): TypedIterator<Complex64>;

/**
* Returns a new typed array with the element at a provided index replaced with a provided value.
*
Expand Down
Loading

0 comments on commit a47230a

Please sign in to comment.