Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/node_modules/@stdlib/array/filled/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
b.end();
});

bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) {
var arr;
var i;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = filledarray( 0.0, 0, 'float16' );
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( format( '%s:dtype=bool', pkg ), function benchmark( b ) {
var arr;
var i;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
/**
* @license Apache-2.0
*
* Copyright (c) 2020 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 isTypedArray = require( '@stdlib/assert/is-typed-array' );
var format = require( '@stdlib/string/format' );
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 arr;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr = filledarray( 1.0, len, 'float16' );
if ( arr.length !== len ) {
b.fail( 'unexpected length' );
}
}
b.toc();
if ( !isTypedArray( 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( format( '%s:dtype=float32,len=%d', pkg, len ), f );
}
}

main();
42 changes: 42 additions & 0 deletions lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@
* @example
* var arr = filledarray( 'float32' );
* // returns <Float32Array>
*
* @example
* var arr = filledarray( 'float16' );
* // returns <Float16Array>
*/
declare function filledarray<T = any, U extends keyof DataTypeMap<T> = 'float64'>( dtype?: U ): DataTypeMap<any>[U];

Check warning on line 46 in lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type

Check warning on line 46 in lib/node_modules/@stdlib/array/filled/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type

/**
* Creates a filled array having a specified `length`.
Expand All @@ -56,6 +60,10 @@
* @example
* var arr = filledarray( 1.0, 5, 'float32' );
* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]
*
* @example
* var arr = filledarray( 1.0, 5, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap<T>[U];

Expand All @@ -74,6 +82,10 @@
* @example
* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' );
* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
*
* @example
* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float16' );
* // returns <Float16Array>[ 1.0, 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap<T>[U];

Expand Down Expand Up @@ -102,6 +114,15 @@
* });
* var arr = filledarray( 1.0, it, 'float32' );
* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
*
* @example
* var iterConstant = require( '@stdlib/iter/constant' );
*
* var it = iterConstant( 3.0, {
* 'iter': 3
* });
* var arr = filledarray( 1.0, it, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap<T>[U];

Expand Down Expand Up @@ -132,6 +153,13 @@
* var buf = new ArrayBuffer( 32 );
* var arr = filledarray( 1.0, buf, 8, 2, 'float32' );
* // returns <Float32Array>[ 1.0, 1.0 ]
*
* @example
* var ArrayBuffer = require( '@stdlib/array/buffer' );
*
* var buf = new ArrayBuffer( 32 );
* var arr = filledarray( 1.0, buf, 8, 2, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap<T>[U];

Expand Down Expand Up @@ -161,6 +189,13 @@
* var buf = new ArrayBuffer( 32 );
* var arr = filledarray( 1.0, buf, 8, 'float32' );
* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
*
* @example
* var ArrayBuffer = require( '@stdlib/array/buffer' );
*
* var buf = new ArrayBuffer( 32 );
* var arr = filledarray( 1.0, buf, 8, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap<T>[U];

Expand Down Expand Up @@ -189,6 +224,13 @@
* var buf = new ArrayBuffer( 32 );
* var arr = filledarray( 1.0, buf, 'float32' );
* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
*
* @example
* var ArrayBuffer = require( '@stdlib/array/buffer' );
*
* var buf = new ArrayBuffer( 16 );
* var arr = filledarray( 1.0, buf, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
*/
declare function filledarray<T, U extends keyof DataTypeMap<T> = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap<T>[U];

Expand Down
6 changes: 6 additions & 0 deletions lib/node_modules/@stdlib/array/filled/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
* @example
* var filledarray = require( '@stdlib/array/filled' );
*
* var arr = filledarray( 1.0, 2, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0 ]
*
* @example
* var filledarray = require( '@stdlib/array/filled' );
*
* var arr = filledarray( 1.0, 2, 'generic' );
* // returns [ 1.0, 1.0 ]
*
Expand Down
4 changes: 4 additions & 0 deletions lib/node_modules/@stdlib/array/filled/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ function filledAccessors( arr, value ) {
* // returns <Float32Array>[ 1.0, 1.0 ]
*
* @example
* var arr = filledarray( 1.0, 2, 'float16' );
* // returns <Float16Array>[ 1.0, 1.0 ]
*
* @example
* var arr = filledarray( 1.0, 2, 'generic' );
* // returns [ 1.0, 1.0 ]
*
Expand Down
Loading
Loading