diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/README.md b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/README.md new file mode 100644 index 000000000000..b2b1644d6eb2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/README.md @@ -0,0 +1,288 @@ + + +# Float32Results + +> Create a NaN-aware summation single-precision floating-point results object. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Float32Results = require( '@stdlib/blas/ext/base/nannsum/results/float32' ); +``` + +#### Float32Results( \[arg\[, byteOffset\[, byteLength]]] ) + +Returns a NaN-aware summation single-precision floating-point results object. + +```javascript +var results = new Float32Results(); +// returns {...} +``` + +The function supports the following parameters: + +- **arg**: an [`ArrayBuffer`][@stdlib/array/buffer] or a data object (_optional_). +- **byteOffset**: byte offset (_optional_). +- **byteLength**: maximum byte length (_optional_). + +A data object argument is an object having one or more of the following properties: + +- **sum**: sum of non-NaN elements. +- **count**: number of non-NaN elements. + +#### Float32Results.prototype.sum + +Sum of non-NaN elements. + +```javascript +var results = new Float32Results(); +// returns {...} + +// ... + +var v = results.sum; +// returns +``` + +#### Float32Results.prototype.count + +Number of non-NaN elements. + +```javascript +var results = new Float32Results(); +// returns {...} + +// ... + +var v = results.count; +// returns +``` + +#### Float32Results.prototype.toString( \[options] ) + +Serializes a results object to a formatted string. + +```javascript +var results = new Float32Results(); +// returns {...} + +// ... + +var v = results.toString(); +// returns +``` + +The method supports the following options: + +- **digits**: number of digits to display after decimal points. Default: `4`. + +Example output: + +```text + +NaN-aware summation + + sum: 11.7586 + count: 5 + +``` + +#### Float32Results.prototype.toJSON() + +Serializes a results object as a JSON object. + +```javascript +var results = new Float32Results(); +// returns {...} + +// ... + +var v = results.toJSON(); +// returns {...} +``` + +`JSON.stringify()` implicitly calls this method when stringifying a results instance. + +#### Float32Results.prototype.toDataView() + +Returns a [`DataView`][@stdlib/array/dataview] of a results object. + +```javascript +var results = new Float32Results(); +// returns {...} + +// ... + +var v = results.toDataView(); +// returns +``` + +
+ + + + + +
+ +## Notes + +- A results object is a [`struct`][@stdlib/dstructs/struct] providing a fixed-width composite data structure for storing NaN-aware summation results and providing an ABI-stable data layout for JavaScript-C interoperation. + +
+ + + + + +
+ +## Examples + + + +```javascript +var BigInt = require( '@stdlib/bigint/ctor' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var Results = require( '@stdlib/blas/ext/base/nannsum/results/float32' ); + +var results = new Results({ + 'sum': f32( 11.7586 ), + 'count': BigInt( 5 ) +}); + +var str = results.toString(); +console.log( str ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/nannsum/results/float32.h" +``` + +#### stdlib_blas_ext_base_nannsum_float32_results + +Structure for storing NaN-aware summation results. + + + +```c +#include + +struct stdlib_blas_ext_base_nannsum_float32_results { + // Sum of non-NaN elements: + float sum; + + // Number of non-NaN elements: + int64_t count; +}; +``` + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/benchmark/benchmark.js new file mode 100644 index 000000000000..961ca455f3b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/benchmark/benchmark.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isObject = require( '@stdlib/assert/is-object' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Float32Results = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::constructor,new', pkg ), function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = new Float32Results(); + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isObject( v ) ) { + b.fail( 'should return an object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::constructor,no_new', pkg ), function benchmark( b ) { + var results; + var v; + var i; + + results = Float32Results; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = results(); + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isObject( v ) ) { + b.fail( 'should return an object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/repl.txt new file mode 100644 index 000000000000..c201075bdba9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( [arg[, byteOffset[, byteLength]]] ) + Returns a NaN-aware summation single-precision floating-point results + object. + + Parameters + ---------- + arg: Object|ArrayBuffer (optional) + ArrayBuffer or data object. + + byteOffset: integer (optional) + Byte offset. + + byteLength: integer (optional) + Maximum byte length. + + Returns + ------- + out: Object + Results object. + + Examples + -------- + > var r = new {{alias}}(); + > r.toString() + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/index.d.ts new file mode 100644 index 000000000000..e0c6bcd88e42 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/index.d.ts @@ -0,0 +1,146 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing NaN-aware summation results. +*/ +interface Results { + /** + * Sum of non-NaN elements. + */ + sum?: number; + + /** + * Number of non-NaN elements. + */ + count?: bigint; +} + +/** +* Interface describing options when serializing a results object to a string. +*/ +interface ToStringOptions { + /** + * Number of digits to display after decimal points. Default: `4`. + */ + digits?: number; +} + +/** +* Interface describing a results data structure. +*/ +declare class ResultsStruct { + /** + * Results constructor. + * + * @param arg - buffer or data object + * @param byteOffset - byte offset + * @param byteLength - maximum byte length + * @returns results + */ + constructor( arg?: ArrayBuffer | Results, byteOffset?: number, byteLength?: number ); + + /** + * Sum of non-NaN elements. + */ + sum: number; + + /** + * Number of non-NaN elements. + */ + count: bigint; + + /** + * Method name. + */ + method: string; + + /** + * Serializes a results object as a formatted string. + * + * @param options - options object + * @returns serialized results + */ + toString( options?: ToStringOptions ): string; + + /** + * Serializes a results object as a JSON object. + * + * @returns serialized object + */ + toJSON(): object; + + /** + * Returns a DataView of a results object. + * + * @returns DataView + */ + toDataView(): DataView; +} + +/** +* Interface defining a results constructor which is both "newable" and "callable". +*/ +interface ResultsConstructor { + /** + * Results constructor. + * + * @param arg - buffer or data object + * @param byteOffset - byte offset + * @param byteLength - maximum byte length + * @returns results object + */ + new( arg?: ArrayBuffer | Results, byteOffset?: number, byteLength?: number ): ResultsStruct; + + /** + * Results constructor. + * + * @param arg - buffer or data object + * @param byteOffset - byte offset + * @param byteLength - maximum byte length + * @returns results object + */ + ( arg?: ArrayBuffer | Results, byteOffset?: number, byteLength?: number ): ResultsStruct; +} + +/** +* Returns a NaN-aware summation single-precision floating-point results object. +* +* @param arg - buffer or data object +* @param byteOffset - byte offset +* @param byteLength - maximum byte length +* @returns results object +* +* @example +* var results = new Results(); +* // returns +* +* results.sum = 11.7586; +* results.count = 5n; +* +* var str = results.toString(); +* // returns +*/ +declare var Results: ResultsConstructor; + + +// EXPORTS // + +export = Results; diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/test.ts new file mode 100644 index 000000000000..3baf36aff560 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +import Results = require( './index' ); + + +// TESTS // + +// The function returns a results object... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const r1 = new Results( new ArrayBuffer( 80 ) ); // $ExpectType ResultsStruct + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const r2 = new Results( new ArrayBuffer( 80 ), 8 ); // $ExpectType ResultsStruct + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const r3 = new Results( new ArrayBuffer( 80 ), 8, 16 ); // $ExpectType ResultsStruct +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/examples/index.js new file mode 100644 index 000000000000..7c7a130c0dab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/examples/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +var BigInt = require( '@stdlib/bigint/ctor' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var Results = require( './../lib' ); + +var results = new Results({ + 'sum': f32( 11.7586 ), + 'count': BigInt( 5 ) +}); + +var str = results.toString(); +console.log( str ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/include/stdlib/blas/ext/base/nannsum/results/float32.h b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/include/stdlib/blas/ext/base/nannsum/results/float32.h new file mode 100644 index 000000000000..a89fe98f80a0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/include/stdlib/blas/ext/base/nannsum/results/float32.h @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#ifndef STDLIB_BLAS_EXT_BASE_NANNSUM_RESULTS_FLOAT32_H +#define STDLIB_BLAS_EXT_BASE_NANNSUM_RESULTS_FLOAT32_H + +#include + +/** +* Struct for storing NaN-aware summation results. +*/ +struct stdlib_blas_ext_base_nannsum_float32_results { + // Sum of non-NaN elements: + float sum; + + // Number of non-NaN elements: + int64_t count; +}; + +#endif // !STDLIB_BLAS_EXT_BASE_NANNSUM_RESULTS_FLOAT32_H diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/index.js new file mode 100644 index 000000000000..3105b8038c3b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/index.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Create a NaN-aware summation single-precision floating-point results object. +* +* @module @stdlib/blas/ext/base/nannsum/results/float32 +* +* @example +* var BigInt = require( '@stdlib/bigint/ctor' ); +* var Results = require( '@stdlib/blas/ext/base/nannsum/results/float32' ); +* +* var results = new Results(); +* // returns +* +* results.sum = 11.7586; +* results.count = BigInt( 5 ); +* +* var str = results.toString(); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/main.js new file mode 100644 index 000000000000..265c5c4bd8e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/lib/main.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 factory = require( '@stdlib/blas/ext/base/nannsum/results/factory' ); + + +// MAIN // + +/** +* Returns a NaN-aware summation single-precision floating-point results object. +* +* @name Results +* @constructor +* @type {Function} +* @param {(ArrayBuffer|Object)} [arg] - underlying byte buffer or data object +* @param {NonNegativeInteger} [byteOffset] - byte offset +* @param {NonNegativeInteger} [byteLength] - maximum byte length +* @returns {Results} results object +* +* @example +* var BigInt = require( '@stdlib/bigint/ctor' ); +* +* var results = new Results(); +* // returns +* +* results.sum = 11.7586; +* results.count = BigInt( 5 ); +* +* var str = results.toString(); +* // returns +*/ +var Results = factory( 'float32' ); + + +// EXPORTS // + +module.exports = Results; diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/package.json b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/package.json new file mode 100644 index 000000000000..3d8c944ce316 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/blas/ext/base/nannsum/results/float32", + "version": "0.0.0", + "description": "Create a NaN-aware summation single-precision floating-point results object.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "blas", + "linear", + "algebra", + "linalg", + "nannsum", + "nan", + "sum", + "utilities", + "utility", + "utils", + "util", + "constructor", + "ctor", + "results", + "float32" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/test/test.js new file mode 100644 index 000000000000..b069836f72a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/nannsum/results/float32/test/test.js @@ -0,0 +1,381 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Number = require( '@stdlib/number/ctor' ); +var isDataView = require( '@stdlib/assert/is-dataview' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var Float32Results = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Float32Results, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ArrayBuffer or data object', function test( t ) { + var results; + var values; + var i; + + results = Float32Results; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + results( value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a nonnegative integer', function test( t ) { + var results; + var values; + var i; + + results = Float32Results; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + results( new ArrayBuffer( 1024 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a nonnegative integer', function test( t ) { + var results; + var values; + var i; + + results = Float32Results; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + results( new ArrayBuffer( 1024 ), 0, value ); + }; + } +}); + +tape( 'the function is a constructor which does not require the `new` operator', function test( t ) { + var results; + var res; + + results = Float32Results; + + res = results(); + t.strictEqual( res instanceof results, true, 'returns expected value' ); + + res = results( {} ); + t.strictEqual( res instanceof results, true, 'returns expected value' ); + + res = results( new ArrayBuffer( 1024 ) ); + t.strictEqual( res instanceof results, true, 'returns expected value' ); + + res = results( new ArrayBuffer( 1024 ), 0 ); + t.strictEqual( res instanceof results, true, 'returns expected value' ); + + res = results( new ArrayBuffer( 1024 ), 0, 1024 ); + t.strictEqual( res instanceof results, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object', function test( t ) { + var expected; + var actual; + + actual = new Float32Results({ + 'sum': f32( 11.7586 ), + 'count': BigInt( 5 ) + }); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object (no arguments)', function test( t ) { + var expected; + var actual; + + actual = new Float32Results(); + + actual.sum = f32( 11.7586 ); + actual.count = BigInt( 5 ); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object (empty object)', function test( t ) { + var expected; + var actual; + + actual = new Float32Results( {} ); + + actual.sum = f32( 11.7586 ); + actual.count = BigInt( 5 ); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object (ArrayBuffer)', function test( t ) { + var expected; + var actual; + var buf; + + buf = new ArrayBuffer( 1024 ); + actual = new Float32Results( buf ); + + actual.sum = f32( 11.7586 ); + actual.count = BigInt( 5 ); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.toDataView().buffer, buf, 'returns expected value' ); + t.strictEqual( actual.toDataView().byteOffset, 0, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object (ArrayBuffer, byteOffset)', function test( t ) { + var expected; + var actual; + var buf; + + buf = new ArrayBuffer( 1024 ); + actual = new Float32Results( buf, 16 ); + + actual.sum = f32( 11.7586 ); + actual.count = BigInt( 5 ); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.toDataView().buffer, buf, 'returns expected value' ); + t.strictEqual( actual.toDataView().byteOffset, 16, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor for a fixed-width results object (ArrayBuffer, byteOffset, byteLength)', function test( t ) { + var expected; + var actual; + var buf; + + buf = new ArrayBuffer( 1024 ); + actual = new Float32Results( buf, 16, 160 ); + + actual.sum = f32( 11.7586 ); + actual.count = BigInt( 5 ); + + expected = { + 'sum': f32( 11.7586 ), + 'count': 5 + }; + + t.strictEqual( actual instanceof Float32Results, true, 'returns expected value' ); + t.strictEqual( actual.toDataView().buffer, buf, 'returns expected value' ); + t.strictEqual( actual.toDataView().byteOffset, 16, 'returns expected value' ); + t.strictEqual( actual.sum, expected.sum, 'returns expected value' ); + t.strictEqual( Number( actual.count ), expected.count, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a method property', function test( t ) { + var results = new Float32Results(); + + t.strictEqual( results.method, 'NaN-aware summation', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `toString` method', function test( t ) { + var results; + var actual; + + results = new Float32Results(); + + actual = results.toString(); + t.strictEqual( typeof actual, 'string', 'returns expected value' ); + + actual = results.toString({ + 'digits': 2 + }); + t.strictEqual( typeof actual, 'string', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `toJSON` method', function test( t ) { + var results = new Float32Results(); + t.strictEqual( typeof results.toJSON, 'function', 'returns expected value' ); + t.strictEqual( typeof results.toJSON(), 'object', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `toDataView` method', function test( t ) { + var results = new Float32Results(); + t.strictEqual( typeof results.toDataView, 'function', 'returns expected value' ); + t.strictEqual( isDataView( results.toDataView() ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `name` property', function test( t ) { + t.strictEqual( typeof Float32Results.name, 'string', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has an `alignment` property', function test( t ) { + t.strictEqual( typeof Float32Results.alignment, 'number', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `byteLength` property', function test( t ) { + t.strictEqual( typeof Float32Results.byteLength, 'number', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `fields` property', function test( t ) { + t.strictEqual( isStringArray( Float32Results.fields ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `layout` property', function test( t ) { + t.strictEqual( typeof Float32Results.layout, 'string', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `bufferOf` method', function test( t ) { + t.strictEqual( typeof Float32Results.bufferOf, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `byteLengthOf` method', function test( t ) { + t.strictEqual( typeof Float32Results.byteLengthOf, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `byteOffsetOf` method', function test( t ) { + t.strictEqual( typeof Float32Results.byteOffsetOf, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `descriptionOf` method', function test( t ) { + t.strictEqual( typeof Float32Results.descriptionOf, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has an `isStruct` method', function test( t ) { + t.strictEqual( typeof Float32Results.isStruct, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor has a `viewOf` method', function test( t ) { + t.strictEqual( typeof Float32Results.viewOf, 'function', 'returns expected value' ); + t.end(); +});