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 Jul 1, 2024
1 parent b6f3a8d commit 24127a3
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 156 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,28 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="array-filled-by-unreleased">

#### [@stdlib/array/filled-by](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by)

<details>

<section class="features">

##### Features

- [`37ca4b7`](https://github.com/stdlib-js/stdlib/commit/37ca4b7ca0d5a2d0553f4d3b0d763d81e38a1bc9) - add boolean dtype support to `array/filled-by` [(#2487)](https://github.com/stdlib-js/stdlib/pull/2487)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-from-scalar-unreleased">

#### [@stdlib/array/from-scalar](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-scalar)
Expand Down Expand Up @@ -2313,6 +2335,7 @@ A total of 13 people contributed to this release. Thank you to the following con

<details>

- [`37ca4b7`](https://github.com/stdlib-js/stdlib/commit/37ca4b7ca0d5a2d0553f4d3b0d763d81e38a1bc9) - **feat:** add boolean dtype support to `array/filled-by` [(#2487)](https://github.com/stdlib-js/stdlib/pull/2487) _(by Jaysukh Makvana, Athan Reines)_
- [`88cece6`](https://github.com/stdlib-js/stdlib/commit/88cece679d728150847dc2b5c957b395bffe7d90) - **feat:** add boolean dtype support to `array/pool` [(#2486)](https://github.com/stdlib-js/stdlib/pull/2486) _(by Jaysukh Makvana, Athan Reines)_
- [`3368a35`](https://github.com/stdlib-js/stdlib/commit/3368a3503ee7df4d1c0803ada84863b4250c76fa) - **docs:** update namespace TypeScript declarations [(#2477)](https://github.com/stdlib-js/stdlib/pull/2477) _(by stdlib-bot, Athan Reines)_
- [`3a3116e`](https://github.com/stdlib-js/stdlib/commit/3a3116e3ff5bef42e4b4f39e5375b89a877ccff0) - **feat:** add boolean dtype support to `array/from-scalar` [(#2470)](https://github.com/stdlib-js/stdlib/pull/2470) _(by Jaysukh Makvana, Athan Reines)_
Expand Down
23 changes: 5 additions & 18 deletions filled-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@license Apache-2.0
Copyright (c) 2021 The Stdlib Authors.
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.
Expand Down Expand Up @@ -42,29 +42,14 @@ var filledarrayBy = require( '@stdlib/array/filled-by' );

#### filledarrayBy( \[dtype] )

Creates a filled array having a specified data type `dtype`.
Creates a filled array having a specified [data type][@stdlib/array/dtypes] `dtype`.

```javascript
var arr = filledarrayBy();
// returns <Float64Array>
```

The function recognizes the following data types:

- `float64`: double-precision floating-point numbers (IEEE 754)
- `float32`: single-precision floating-point numbers (IEEE 754)
- `complex128`: double-precision complex floating-point numbers
- `complex64`: single-precision complex floating-point numbers
- `int32`: 32-bit two's complement signed integers
- `uint32`: 32-bit unsigned integers
- `int16`: 16-bit two's complement signed integers
- `uint16`: 16-bit unsigned integers
- `int8`: 8-bit two's complement signed integers
- `uint8`: 8-bit unsigned integers
- `uint8c`: 8-bit unsigned integers clamped to `0-255`
- `generic`: generic JavaScript values

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.
By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument.

```javascript
var arr = filledarrayBy( 'int32' );
Expand Down Expand Up @@ -261,6 +246,8 @@ for ( i = 0; i < dt.length; i++ ) {

[mdn-arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer

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

<!-- <related-links> -->

[@stdlib/array/filled]: https://github.com/stdlib-js/array/tree/main/filled
Expand Down
24 changes: 23 additions & 1 deletion filled-by/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2021 The Stdlib Authors.
* 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.
Expand Down Expand Up @@ -98,6 +98,28 @@ bench( pkg+':dtype=float32', function benchmark( b ) {
b.end();
});

bench( pkg+':dtype=bool', function benchmark( b ) {
var clbk;
var arr;
var i;

clbk = constantFunction( true );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = filledarrayBy( 0, 'bool', clbk );
if ( arr.length !== 0 ) {
b.fail( 'should have length 0' );
}
}
b.toc();
if ( !isTypedArrayLike( arr ) ) {
b.fail( 'should return a typed array' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+':dtype=complex128', function benchmark( b ) {
var clbk;
var arr;
Expand Down
97 changes: 97 additions & 0 deletions filled-by/benchmark/benchmark.length.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
var constantFunction = require( '@stdlib/utils/constant-function' );
var pkg = require( './../package.json' ).name;
var filledarray = require( './../lib' );


// FUNCTIONS //

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

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

clbk = constantFunction( true );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = filledarray( len, 'bool', clbk );
if ( arr.length !== len ) {
b.fail( 'unexpected length' );
}
}
b.toc();
if ( !isTypedArrayLike( arr ) ) {
b.fail( 'should return a typed array' );
}
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+':dtype=bool,len='+len, f );
}
}

main();
17 changes: 0 additions & 17 deletions filled-by/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@
{{alias}}( [dtype] )
Creates a filled array.

The function supports the following data types:

- float64: double-precision floating-point numbers (IEEE 754)
- float32: single-precision floating-point numbers (IEEE 754)
- complex128: double-precision complex floating-point numbers
- complex64: single-precision complex floating-point numbers
- int32: 32-bit two's complement signed integers
- uint32: 32-bit unsigned integers
- int16: 16-bit two's complement signed integers
- uint16: 16-bit unsigned integers
- int8: 8-bit two's complement signed integers
- uint8: 8-bit unsigned integers
- uint8c: 8-bit unsigned integers clamped to 0-255
- generic: generic JavaScript values

The default array data type is `float64`.

Parameters
----------
dtype: string (optional)
Expand Down
Loading

0 comments on commit 24127a3

Please sign in to comment.