From 0807fdb4a8f4652496840fef343cdb3019d44e41 Mon Sep 17 00:00:00 2001 From: Uday Kakade Date: Fri, 3 Apr 2026 00:34:46 +0530 Subject: [PATCH 01/12] Add complexFactory Package --- etc/eslint/rules/spellcheck.js | 236 +- .../@stdlib/array/complex-factory/README.md | 3277 ++++++++++++++++ .../complex-factory/benchmark/benchmark.at.js | 160 + .../benchmark/benchmark.copy_within.js | 101 + .../benchmark/benchmark.copy_within.length.js | 172 + .../benchmark/benchmark.entries.js | 97 + .../benchmark/benchmark.every.js | 97 + .../benchmark/benchmark.every.length.js | 193 + .../benchmark/benchmark.fill.js | 100 + .../benchmark/benchmark.fill.length.js | 165 + .../benchmark/benchmark.filter.js | 96 + .../benchmark/benchmark.filter.length.js | 193 + .../benchmark/benchmark.find.js | 96 + .../benchmark/benchmark.find.length.js | 195 + .../benchmark/benchmark.find_index.js | 97 + .../benchmark/benchmark.find_index.length.js | 195 + .../benchmark/benchmark.find_last.js | 96 + .../benchmark/benchmark.find_last.length.js | 195 + .../benchmark/benchmark.find_last_index.js | 97 + .../benchmark.find_last_index.length.js | 195 + .../benchmark/benchmark.for_each.js | 98 + .../benchmark/benchmark.for_each.length.js | 176 + .../benchmark/benchmark.from.js | 791 ++++ .../benchmark/benchmark.get.js | 103 + .../benchmark/benchmark.includes.js | 102 + .../benchmark/benchmark.includes.length.js | 175 + .../benchmark/benchmark.index_of.js | 102 + .../benchmark/benchmark.index_of.length.js | 175 + .../benchmark/benchmark.join.js | 87 + .../benchmark/benchmark.join.length.js | 166 + .../complex-factory/benchmark/benchmark.js | 754 ++++ .../benchmark/benchmark.keys.js | 88 + .../benchmark/benchmark.keys.length.js | 167 + .../benchmark/benchmark.last_index_of.js | 102 + .../benchmark.last_index_of.length.js | 173 + .../benchmark/benchmark.length.js | 152 + .../benchmark/benchmark.map.js | 96 + .../benchmark/benchmark.map.length.js | 168 + .../complex-factory/benchmark/benchmark.of.js | 187 + .../benchmark/benchmark.reduce.js | 90 + .../benchmark/benchmark.reduce.length.js | 169 + .../benchmark/benchmark.reduce_right.js | 90 + .../benchmark.reduce_right.length.js | 169 + .../benchmark/benchmark.reverse.js | 88 + .../benchmark/benchmark.reverse.length.js | 167 + .../benchmark/benchmark.set.js | 325 ++ .../benchmark/benchmark.set.length.js | 197 + .../benchmark/benchmark.slice.js | 88 + .../benchmark/benchmark.slice.length.js | 167 + .../benchmark/benchmark.some.js | 97 + .../benchmark/benchmark.some.length.js | 195 + .../benchmark/benchmark.sort.js | 155 + .../benchmark/benchmark.sort.length.js | 231 ++ .../benchmark/benchmark.subarray.js | 88 + .../benchmark/benchmark.subarray.length.js | 167 + .../benchmark/benchmark.to_locale_string.js | 87 + .../benchmark.to_locale_string.length.js | 166 + .../benchmark/benchmark.to_reversed.js | 88 + .../benchmark/benchmark.to_reversed.length.js | 167 + .../benchmark/benchmark.to_sorted.js | 155 + .../benchmark/benchmark.to_sorted.length.js | 231 ++ .../benchmark/benchmark.to_string.js | 87 + .../benchmark/benchmark.to_string.length.js | 166 + .../benchmark/benchmark.values.js | 88 + .../benchmark/benchmark.values.length.js | 167 + .../benchmark/benchmark.with.js | 100 + .../benchmark/benchmark.with.length.js | 165 + .../array/complex-factory/docs/repl.txt | 2878 ++++++++++++++ .../complex-factory/docs/types/index.d.ts | 3330 +++++++++++++++++ .../array/complex-factory/docs/types/test.ts | 104 + .../array/complex-factory/examples/index.js | 81 + .../array/complex-factory/lib/from_array.js | 71 + .../complex-factory/lib/from_iterator.js | 75 + .../complex-factory/lib/from_iterator_map.js | 80 + .../array/complex-factory/lib/index.js | 66 + .../@stdlib/array/complex-factory/lib/main.js | 2038 ++++++++++ .../array/complex-factory/package.json | 76 + .../array/complex-factory/test/test.at.js | 281 ++ .../complex-factory/test/test.copy_within.js | 769 ++++ .../complex-factory/test/test.entries.js | 451 +++ .../array/complex-factory/test/test.every.js | 345 ++ .../array/complex-factory/test/test.fill.js | 589 +++ .../array/complex-factory/test/test.filter.js | 372 ++ .../array/complex-factory/test/test.find.js | 349 ++ .../complex-factory/test/test.find_index.js | 345 ++ .../complex-factory/test/test.find_last.js | 349 ++ .../test/test.find_last_index.js | 345 ++ .../complex-factory/test/test.for_each.js | 349 ++ .../array/complex-factory/test/test.from.js | 1530 ++++++++ .../array/complex-factory/test/test.get.js | 263 ++ .../complex-factory/test/test.includes.js | 499 +++ .../complex-factory/test/test.index_of.js | 503 +++ .../array/complex-factory/test/test.join.js | 321 ++ .../array/complex-factory/test/test.js | 1331 +++++++ .../array/complex-factory/test/test.keys.js | 472 +++ .../test/test.last_index_of.js | 475 +++ .../array/complex-factory/test/test.map.js | 455 +++ .../array/complex-factory/test/test.of.js | 293 ++ .../array/complex-factory/test/test.reduce.js | 422 +++ .../complex-factory/test/test.reduce_right.js | 432 +++ .../complex-factory/test/test.reverse.js | 216 ++ .../array/complex-factory/test/test.set.js | 1464 ++++++++ .../array/complex-factory/test/test.slice.js | 560 +++ .../array/complex-factory/test/test.some.js | 391 ++ .../array/complex-factory/test/test.sort.js | 347 ++ .../complex-factory/test/test.subarray.js | 560 +++ .../test/test.to_locale_string.js | 375 ++ .../complex-factory/test/test.to_reversed.js | 214 ++ .../complex-factory/test/test.to_sorted.js | 345 ++ .../complex-factory/test/test.to_string.js | 183 + .../array/complex-factory/test/test.values.js | 498 +++ .../array/complex-factory/test/test.with.js | 405 ++ 112 files changed, 39846 insertions(+), 116 deletions(-) create mode 100644 lib/node_modules/@stdlib/array/complex-factory/README.md create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/array/complex-factory/examples/index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/lib/from_array.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator_map.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/lib/index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/lib/main.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/package.json create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.at.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.every.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.find.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.from.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.get.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.join.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.map.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.of.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.set.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.some.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.values.js create mode 100644 lib/node_modules/@stdlib/array/complex-factory/test/test.with.js diff --git a/etc/eslint/rules/spellcheck.js b/etc/eslint/rules/spellcheck.js index 8c72144d65ec..22a05f08bca0 100644 --- a/etc/eslint/rules/spellcheck.js +++ b/etc/eslint/rules/spellcheck.js @@ -1,126 +1,130 @@ /** -* @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. -*/ + * @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'; +"use strict"; /** -* ESLint rules for spellchecking. -* -* @namespace rules -*/ + * ESLint rules for spellchecking. + * + * @namespace rules + */ var rules = {}; /** -* Warn when encountering potentially misspelled words in comments and strings. -* -* @name @cspell/spellchecker -* @memberof rules -* @type {Array} -* @see [spellchecker]{@link https://www.npmjs.com/package/@cspell/eslint-plugin} -* -* @example -* // Bad... -* var str = 'Functionl programming is a paradigm...'; -* -* @example -* // Good... -* var str = 'Functional programming is a paradigm...'; -*/ -rules[ '@cspell/spellchecker' ] = [ 'warn', { - 'checkComments': true, - 'checkStrings': true, - 'autoFix': false, - 'checkIdentifiers': false, - 'cspell': { - 'allowCompoundWords': true, - 'ignoreRegExpList': [ - '/[a-z0-9.]+\\(/gi', // ignore functions or methods invoked in comments - '/var [a-zA-Z0-9]+/g', // ignore variable declarations - '/[A-Z][a-z]+/g', // ignore proper nouns - '/[A-Z]+/g', // ignore acronyms - '/@stdlib\\/[a-z0-9/-]+/g', // ignore stdlib package paths - '/@name [a-zA-Z0-9]+/g', // ignore identifier names in JSDoc - '/\\/\\/ returns \'[^\']+\'/g', // ignore return value annotations - '/setReadOnly\\( [.a-z0-9]+, \'[^\']+?\'/gi', // ignore namespace or prototype assignments - '/```[\\s\\S]+?```/g', // ignore code blocks - '/(? + +# complexFactory + +> Factory for creating complex number typed array constructors. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +``` + + + +#### complexFactory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) + +Returns a complex number typed array constructor. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); + +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); +// returns + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +// returns +``` + +The function accepts the following arguments: + +- **dtype**: complex number array data type (e.g., `'complex64'` or `'complex128'`). +- **FloatArray**: underlying float typed array constructor (e.g., `Float32Array` or `Float64Array`). +- **ComplexScalar**: complex number scalar constructor (e.g., `Complex64` or `Complex128`). +- **getReal**: function returning the real component of a complex number. +- **getImag**: function returning the imaginary component of a complex number. +- **reinterpret**: function reinterpreting a same-type complex array as its underlying float array. + +The returned constructor (referred to below as `ComplexArray`) supports the following signatures: + +* * * + + + +#### ComplexArray() + +Creates a complex number array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array(); +// returns + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array(); +// returns +``` + +#### ComplexArray( length ) + +Creates a complex number array having a specified `length`. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); +// returns + +var len = arr.length; +// returns 10 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); +// returns + +len = arr.length; +// returns 10 +``` + +#### ComplexArray( complexarray ) + +Creates a complex number array from another complex number array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] +// returns + +var arr2 = new Complex64Array( arr1 ); +// returns + +var len = arr2.length; +// returns 2 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +var arr3 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] +// returns + +var arr4 = new Complex128Array( arr3 ); +// returns + +len = arr4.length; +// returns 2 +``` + +#### ComplexArray( typedarray ) + +Creates a complex number array from a [typed array][@stdlib/array/typed] containing interleaved real and imaginary components. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] +// returns [ 1.0, -1.0, 2.0, -2.0 ] + +var arr = new Complex64Array( buf ); +// returns + +var len = arr.length; +// returns 2 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +buf = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] +// returns [ 1.0, -1.0, 2.0, -2.0 ] + +arr = new Complex128Array( buf ); +// returns + +len = arr.length; +// returns 2 +``` + +#### ComplexArray( obj ) + +Creates a complex number array from an array-like object or iterable. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +// From an array of interleaved real and imaginary components: +var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); +// returns + +var len = arr1.length; +// returns 2 + +// From an array containing complex numbers: +var buf = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ]; +var arr2 = new Complex64Array( buf ); + +len = arr2.length; +// returns 2 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +// From an array of interleaved real and imaginary components: +var arr3 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); +// returns + +len = arr3.length; +// returns 2 + +// From an array containing complex numbers: +buf = [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ]; +var arr4 = new Complex128Array( buf ); + +len = arr4.length; +// returns 2 +``` + +#### ComplexArray( buffer\[, byteOffset\[, length]] ) + +Returns a complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var buf = new ArrayBuffer( 240 ); + +var arr1 = new Complex64Array( buf ); +// returns + +var len = arr1.length; +// returns 30 + +var arr2 = new Complex64Array( buf, 8 ); +// returns + +len = arr2.length; +// returns 29 + +var arr3 = new Complex64Array( buf, 8, 20 ); +// returns + +len = arr3.length; +// returns 20 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +buf = new ArrayBuffer( 480 ); + +var arr4 = new Complex128Array( buf ); +// returns + +len = arr4.length; +// returns 30 + +var arr5 = new Complex128Array( buf, 16 ); +// returns + +len = arr5.length; +// returns 29 + +var arr6 = new Complex128Array( buf, 16, 20 ); +// returns + +len = arr6.length; +// returns 20 +``` + +* * * + +### Properties + + + +#### ComplexArray.BYTES\_PER\_ELEMENT + +Static property returning the size (in bytes) of each array element. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var nbytes = Complex64Array.BYTES_PER_ELEMENT; +// returns 8 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +nbytes = Complex128Array.BYTES_PER_ELEMENT; +// returns 16 +``` + + + +#### ComplexArray.name + +Static property returning the constructor name. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var str = Complex64Array.name; +// returns 'Complex64Array' + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +str = Complex128Array.name; +// returns 'Complex128Array' +``` + + + +#### ComplexArray.prototype.buffer + +Pointer to the underlying data buffer. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 2 ); +// returns + +var buf = arr.buffer; +// returns + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 2 ); +// returns + +buf = arr.buffer; +// returns +``` + + + +#### ComplexArray.prototype.byteLength + +Size (in bytes) of the array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); +// returns + +var nbytes = arr.byteLength; +// returns 80 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); +// returns + +nbytes = arr.byteLength; +// returns 160 +``` + + + +#### ComplexArray.prototype.byteOffset + +Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); +// returns + +var offset = arr.byteOffset; +// returns 0 + +var buf = new ArrayBuffer( 240 ); +arr = new Complex64Array( buf, 64 ); +// returns + +offset = arr.byteOffset; +// returns 64 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); +// returns + +offset = arr.byteOffset; +// returns 0 + +buf = new ArrayBuffer( 480 ); +arr = new Complex128Array( buf, 128 ); +// returns + +offset = arr.byteOffset; +// returns 128 +``` + + + +#### ComplexArray.prototype.BYTES\_PER\_ELEMENT + +Size (in bytes) of each array element. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); +// returns + +var nbytes = arr.BYTES_PER_ELEMENT; +// returns 8 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); +// returns + +nbytes = arr.BYTES_PER_ELEMENT; +// returns 16 +``` + + + +#### ComplexArray.prototype.length + +Number of array elements. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); +// returns + +var len = arr.length; +// returns 10 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); +// returns + +len = arr.length; +// returns 10 +``` + +* * * + +### Methods + + + +#### ComplexArray.from( src\[, clbk\[, thisArg]] ) + +Creates a new complex number array from an array-like object or an iterable. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +// Create an array from interleaved real and imaginary components: +var arr = Complex64Array.from( [ 1.0, -1.0 ] ); +// returns + +var len = arr.length; +// returns 1 + +// Create an array from an array of complex numbers: +arr = Complex64Array.from( [ new Complex64( 1.0, -1.0 ) ] ); +// returns + +len = arr.length; +// returns 1 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +// Create an array from interleaved real and imaginary components: +arr = Complex128Array.from( [ 1.0, -1.0 ] ); +// returns + +len = arr.length; +// returns 1 + +// Create an array from an array of complex numbers: +arr = Complex128Array.from( [ new Complex128( 1.0, -1.0 ) ] ); +// returns + +len = arr.length; +// returns 1 +``` + +To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like object containing complex numbers, the callback must return either a complex number or an array-like object containing real and imaginary components. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function map64( z ) { + return new Complex64( realf(z)*2.0, imagf(z)*2.0 ); +} + +var src = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ]; + +var arr = Complex64Array.from( src, map64 ); +// returns + +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns -2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function map128( z ) { + return new Complex128( real(z)*2.0, imag(z)*2.0 ); +} + +src = [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ]; + +arr = Complex128Array.from( src, map128 ); +// returns + +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns -2.0 +``` + +If `src` is an array-like object containing interleaved real and imaginary components, the callback is invoked for each component and should return the transformed component value. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function map( v ) { + return v * 2.0; +} + +var arr = Complex64Array.from( new Float32Array( [ 1.0, -1.0 ] ), map ); +// returns + +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns -2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = Complex128Array.from( new Float64Array( [ 1.0, -1.0 ] ), map ); +// returns + +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns -2.0 +``` + +A callback function is provided two arguments: + +- **value**: source value. +- **index**: source index. + +To set the callback execution context, provide a `thisArg`. + + + +#### ComplexArray.of( element0\[, element1\[, ...elementN]] ) + +Creates a new complex number array from a variable number of arguments. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 ); +// returns + +var len = arr.length; +// returns 2 + +var z1 = new Complex64( 1.0, -1.0 ); +var z2 = new Complex64( 2.0, -2.0 ); + +arr = Complex64Array.of( z1, z2 ); +// returns + +len = arr.length; +// returns 2 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = Complex128Array.of( 1.0, -1.0, 2.0, -2.0 ); +// returns + +len = arr.length; +// returns 2 + +var z3 = new Complex128( 1.0, -1.0 ); +var z4 = new Complex128( 2.0, -2.0 ); + +arr = Complex128Array.of( z3, z4 ); +// returns + +len = arr.length; +// returns 2 +``` + + + +#### ComplexArray.prototype.at( i ) + +Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 9.0, -9.0 ], 9 ); + +// Get the first element: +var z = arr.at( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +// Get the last element using a negative index: +z = arr.at( -1 ); +// returns + +re = realf( z ); +// returns 9.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 9.0, -9.0 ], 9 ); + +// Get the first element: +z = arr.at( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +// Get the last element using a negative index: +z = arr.at( -1 ); +// returns + +re = real( z ); +// returns 9.0 +``` + +If provided an out-of-bounds index, the method returns `undefined`. + + + +#### ComplexArray.prototype.copyWithin( target, start\[, end] ) + +Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 4 ); + +arr.set( new Complex64( 1.0, -1.0 ), 0 ); +arr.set( new Complex64( 2.0, -2.0 ), 1 ); +arr.set( new Complex64( 3.0, -3.0 ), 2 ); +arr.set( new Complex64( 4.0, -4.0 ), 3 ); + +// Copy the last two elements to the first two elements: +arr.copyWithin( 0, 2 ); + +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns -3.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 4 ); + +arr.set( new Complex128( 1.0, -1.0 ), 0 ); +arr.set( new Complex128( 2.0, -2.0 ), 1 ); +arr.set( new Complex128( 3.0, -3.0 ), 2 ); +arr.set( new Complex128( 4.0, -4.0 ), 3 ); + +// Copy the last two elements to the first two elements: +arr.copyWithin( 0, 2 ); + +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns -3.0 +``` + +When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. + + + +#### ComplexArray.prototype.entries() + +Returns an iterator for iterating over array key-value pairs. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); + +var it = arr.entries(); + +var v = it.next().value; +// returns [ 0, ] + +var re = realf( v[ 1 ] ); +// returns 1.0 + +v = it.next().value; +// returns [ 1, ] + +re = realf( v[ 1 ] ); +// returns 2.0 + +var bool = it.next().done; +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); + +it = arr.entries(); + +v = it.next().value; +// returns [ 0, ] + +re = real( v[ 1 ] ); +// returns 1.0 + +v = it.next().value; +// returns [ 1, ] + +re = real( v[ 1 ] ); +// returns 2.0 + +bool = it.next().done; +// returns true +``` + + + +#### ComplexArray.prototype.every( predicate\[, thisArg] ) + +Returns a boolean indicating whether all elements pass a test implemented by a predicate function. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ) ] ); + +var bool = arr.every( predicate64 ); +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ) ] ); + +bool = arr.every( predicate128 ); +// returns true +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.fill( value\[, start\[, end]] ) + +Returns a modified typed array filled with a fill value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.fill( new Complex64( 1.0, -1.0 ) ); + +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.fill( new Complex128( 1.0, -1.0 ) ); + +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 +``` + +By default, the method fills the entire array. To fill a sub-range, provide `start` (inclusive) and `end` (exclusive) indices. Negative indices are resolved relative to the last array element. + + + +#### ComplexArray.prototype.filter( predicate\[, thisArg] ) + +Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) > 0.0 ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( -2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); + +var out = arr.filter( predicate64 ); +// returns + +var len = out.length; +// returns 2 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) > 0.0 ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( -2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); + +out = arr.filter( predicate128 ); +// returns + +len = out.length; +// returns 2 +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.find( predicate\[, thisArg] ) + +Returns the first element in an array for which a predicate function returns a truthy value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); + +var z = arr.find( predicate64 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns 2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); + +z = arr.find( predicate128 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns 2.0 +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. If no element satisfies the predicate, the method returns `undefined`. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.findIndex( predicate\[, thisArg] ) + +Returns the index of the first element in an array for which a predicate function returns a truthy value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); + +var idx = arr.findIndex( predicate64 ); +// returns 1 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); + +idx = arr.findIndex( predicate128 ); +// returns 1 +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. If no element satisfies the predicate, the method returns `-1`. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.findLast( predicate\[, thisArg] ) + +Returns the last element in an array for which a predicate function returns a truthy value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); + +var z = arr.findLast( predicate64 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); + +z = arr.findLast( predicate128 ); +// returns + +re = real( z ); +// returns 2.0 +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. If no element satisfies the predicate, the method returns `undefined`. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.findLastIndex( predicate\[, thisArg] ) + +Returns the index of the last element in an array for which a predicate function returns a truthy value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); + +var idx = arr.findLastIndex( predicate64 ); +// returns 1 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); + +idx = arr.findLastIndex( predicate128 ); +// returns 1 +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. If no element satisfies the predicate, the method returns `-1`. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.forEach( fcn\[, thisArg] ) + +Invokes a function once for each array element. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); + +arr.forEach( function( v, i ) { + console.log( i, realf( v ), imagf( v ) ); +}); + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); + +arr.forEach( function( v, i ) { + console.log( i, real( v ), imag( v ) ); +}); +``` + +The invoked function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.get( i ) + +Returns an array element. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +arr.set( new Complex64( 1.0, -1.0 ), 0 ); + +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +arr.set( new Complex128( 1.0, -1.0 ), 0 ); + +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 +``` + +If provided an out-of-bounds index, the method returns `undefined`. + + + +#### ComplexArray.prototype.includes( searchElement\[, fromIndex] ) + +Returns a boolean indicating whether an array includes a provided value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 5.0, -5.0 ], 4 ); + +var bool = arr.includes( new Complex64( 3.0, -3.0 ) ); +// returns true + +bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); +// returns false + +bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 5.0, -5.0 ], 4 ); + +bool = arr.includes( new Complex128( 3.0, -3.0 ) ); +// returns true + +bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 ); +// returns false + +bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); +// returns true +``` + + + +#### ComplexArray.prototype.indexOf( searchElement\[, fromIndex] ) + +Returns the first index at which a given element can be found. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 2.0, -2.0 ], 4 ); + +var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); +// returns 2 + +idx = arr.indexOf( new Complex64( 2.0, -2.0 ), 2 ); +// returns 4 + +idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 ); +// returns 3 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 2.0, -2.0 ], 4 ); + +idx = arr.indexOf( new Complex128( 3.0, -3.0 ) ); +// returns 2 + +idx = arr.indexOf( new Complex128( 2.0, -2.0 ), 2 ); +// returns 4 + +idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 ); +// returns 3 +``` + +If `searchElement` is not present in the array, the method returns `-1`. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); +// returns -1 + +idx = arr.indexOf( new Complex64( 1.0, -1.0 ), 1 ); +// returns -1 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +idx = arr.indexOf( new Complex128( 3.0, -3.0 ) ); +// returns -1 + +idx = arr.indexOf( new Complex128( 1.0, -1.0 ), 1 ); +// returns -1 +``` + + + +#### ComplexArray.prototype.join( \[separator] ) + +Returns a new string by concatenating all array elements. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var str = arr.join(); +// returns '1 + 1i,2 - 2i,3 + 3i' + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +str = arr.join(); +// returns '1 + 1i,2 - 2i,3 + 3i' +``` + +By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var str = arr.join( '/' ); +// returns '1 + 1i/2 - 2i/3 + 3i' + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +str = arr.join( '/' ); +// returns '1 + 1i/2 - 2i/3 + 3i' +``` + + + +#### ComplexArray.prototype.keys() + +Returns an iterator for iterating over each index key in a typed array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 2 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +var iter = arr.keys(); + +var v = iter.next().value; +// returns 0 + +v = iter.next().value; +// returns 1 + +var bool = iter.next().done; +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 2 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +iter = arr.keys(); + +v = iter.next().value; +// returns 0 + +v = iter.next().value; +// returns 1 + +bool = iter.next().done; +// returns true +``` + + + +#### ComplexArray.prototype.lastIndexOf( searchElement\[, fromIndex] ) + +Returns the last index at which a given element can be found. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 2.0, -2.0 ], 4 ); + +var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); +// returns 2 + +idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 2 ); +// returns 1 + +idx = arr.lastIndexOf( new Complex64( 4.0, -4.0 ), -1 ); +// returns 3 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); +arr.set( [ 4.0, -4.0 ], 3 ); +arr.set( [ 2.0, -2.0 ], 4 ); + +idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); +// returns 2 + +idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), 2 ); +// returns 1 + +idx = arr.lastIndexOf( new Complex128( 4.0, -4.0 ), -1 ); +// returns 3 +``` + +If `searchElement` is not present in the array, the method returns `-1`. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); +// returns -1 + +idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 0 ); +// returns -1 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 5 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); +// returns -1 + +idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), 0 ); +// returns -1 +``` + + + +#### ComplexArray.prototype.map( callbackFn\[, thisArg] ) + +Returns a new array with each element being the result of a provided callback function. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function scale64( v ) { + return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); + +var out = arr.map( scale64 ); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns -2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function scale128( v ) { + return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); + +out = arr.map( scale128 ); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns -2.0 +``` + +The callback function is provided three arguments: + +- **value**: current array element. +- **index**: current array element index. +- **arr**: the array on which this method was called. + +To set the function execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.reduce( reducerFn\[, initialValue] ) + +Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. + +```javascript +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var z = arr.reduce( caddf ); +// returns + +var re = realf( z ); +// returns 6.0 + +var im = imagf( z ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +z = arr.reduce( cadd ); +// returns + +re = real( z ); +// returns 6.0 + +im = imag( z ); +// returns 6.0 +``` + +The reducer function is provided four arguments: + +- **acc**: accumulated result. +- **value**: current array element. +- **index**: current array element index. +- **arr**: the array on which this method was called. + +By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. + +```javascript +var realf = require( '@stdlib/complex/float32/real' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function reducer64( acc, v ) { + acc += realf( v ); + return acc; +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var z = arr.reduce( reducer64, 0.0 ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function reducer128( acc, v ) { + acc += real( v ); + return acc; +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +z = arr.reduce( reducer128, 0.0 ); +// returns 6.0 +``` + + + +#### ComplexArray.prototype.reduceRight( reducerFn\[, initialValue] ) + +Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. + +```javascript +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var z = arr.reduceRight( caddf ); +// returns + +var re = realf( z ); +// returns 6.0 + +var im = imagf( z ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +z = arr.reduceRight( cadd ); +// returns + +re = real( z ); +// returns 6.0 + +im = imag( z ); +// returns 6.0 +``` + +The reducer function is provided four arguments: + +- **acc**: accumulated result. +- **value**: current array element. +- **index**: current array element index. +- **arr**: the array on which this method was called. + +By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. + +```javascript +var realf = require( '@stdlib/complex/float32/real' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function reducer64( acc, v ) { + acc += realf( v ); + return acc; +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var z = arr.reduceRight( reducer64, 0.0 ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function reducer128( acc, v ) { + acc += real( v ); + return acc; +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +z = arr.reduceRight( reducer128, 0.0 ); +// returns 6.0 +``` + + + +#### ComplexArray.prototype.reverse() + +Reverses an array in-place. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var out = arr.reverse(); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 3.0 + +z = out.get( 2 ); +// returns + +re = realf( z ); +// returns 1.0 + +im = imagf( z ); +// returns 1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +out = arr.reverse(); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 3.0 + +z = out.get( 2 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 1.0 +``` + + + +#### ComplexArray.prototype.set( z\[, i] ) + +Sets one or more array elements. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +// Set the first element: +arr.set( new Complex64( 1.0, -1.0 ) ); + +// Get the first element: +var z = arr.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +// Set the first element: +arr.set( new Complex128( 1.0, -1.0 ) ); + +// Get the first element: +z = arr.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 +``` + +By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +// Set the fifth element: +arr.set( new Complex64( 1.0, -1.0 ), 4 ); + +// Get the fifth element: +var z = arr.get( 4 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +// Set the fifth element: +arr.set( new Complex128( 1.0, -1.0 ), 4 ); + +// Get the fifth element: +z = arr.get( 4 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 +``` + +In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +var buf = [ + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ) +]; + +// Set the fifth, sixth, and seventh elements: +arr.set( buf, 4 ); + +// Get the sixth element: +var z = arr.get( 5 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns -2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +buf = [ + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ) +]; + +// Set the fifth, sixth, and seventh elements: +arr.set( buf, 4 ); + +// Get the sixth element: +z = arr.get( 5 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns -2.0 +``` + +or interleaved real and imaginary components + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 10 ); + +var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + +// Set the fifth, sixth, and seventh elements: +arr.set( buf, 4 ); + +// Get the sixth element: +var z = arr.get( 5 ); +// returns + +var re = realf( z ); +// returns 2.0 + +var im = imagf( z ); +// returns -2.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 10 ); + +buf = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + +// Set the fifth, sixth, and seventh elements: +arr.set( buf, 4 ); + +// Get the sixth element: +z = arr.get( 5 ); +// returns + +re = real( z ); +// returns 2.0 + +im = imag( z ); +// returns -2.0 +``` + +A few notes: + +- If `i` is out-of-bounds, the method throws an error. +- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. +- If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. + + + +#### ComplexArray.prototype.slice( \[start\[, end]] ) + +Copies a portion of a typed array to a new typed array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var out = arr.slice(); +// returns + +var len = out.length; +// returns 4 + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns 2.0 + +z = out.get( len-1 ); +// returns + +re = realf( z ); +// returns 7.0 + +im = imagf( z ); +// returns 8.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +out = arr.slice(); +// returns + +len = out.length; +// returns 4 + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 2.0 + +z = out.get( len-1 ); +// returns + +re = real( z ); +// returns 7.0 + +im = imag( z ); +// returns 8.0 +``` + +By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive). + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var out = arr.slice( 1 ); +// returns + +var len = out.length; +// returns 3 + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 4.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +out = arr.slice( 1 ); +// returns + +len = out.length; +// returns 3 + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 4.0 +``` + +By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive). + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var out = arr.slice( 1, -1 ); +// returns + +var len = out.length; +// returns 2 + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 4.0 + +z = out.get( len-1 ); +// returns + +re = realf( z ); +// returns 5.0 + +im = imagf( z ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +out = arr.slice( 1, -1 ); +// returns + +len = out.length; +// returns 2 + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 4.0 + +z = out.get( len-1 ); +// returns + +re = real( z ); +// returns 5.0 + +im = imag( z ); +// returns 6.0 +``` + + + +#### ComplexArray.prototype.some( predicate\[, thisArg] ) + +Returns a boolean indicating whether at least one element passes a test. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function predicate64( v ) { + return ( realf( v ) === imagf( v ) ); +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); + +var bool = arr.some( predicate64 ); +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function predicate128( v ) { + return ( real( v ) === imag( v ) ); +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, -3.0 ], 2 ); + +bool = arr.some( predicate128 ); +// returns true +``` + +The `predicate` function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. + + + +#### ComplexArray.prototype.sort( compareFcn ) + +Sorts an array in-place. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function compare64( a, b ) { + var re1 = realf( a ); + var re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + var im1 = imagf( a ); + var im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 3.0, -3.0 ], 0 ); +arr.set( [ 1.0, -1.0 ], 1 ); +arr.set( [ 2.0, -2.0 ], 2 ); + +var out = arr.sort( compare64 ); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function compare128( a, b ) { + var re1 = real( a ); + var re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + var im1 = imag( a ); + var im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 3.0, -3.0 ], 0 ); +arr.set( [ 1.0, -1.0 ], 1 ); +arr.set( [ 2.0, -2.0 ], 2 ); + +out = arr.sort( compare128 ); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 +``` + +The `compareFcn` determines the order of the elements. The function is called with the following arguments: + +- **a**: the first element for comparison. +- **b**: the second element for comparison. + +The function should return a number where: + +- a negative value indicates that `a` should come before `b`. +- a positive value indicates that `a` should come after `b`. +- zero or `NaN` indicates that `a` and `b` are considered equal. + +In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. + + + +#### ComplexArray.prototype.subarray( \[begin\[, end]] ) + +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. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var subarr = arr.subarray(); +// returns + +var len = subarr.length; +// returns 4 + +var z = subarr.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns 2.0 + +z = subarr.get( len-1 ); +// returns + +re = realf( z ); +// returns 7.0 + +im = imagf( z ); +// returns 8.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +subarr = arr.subarray(); +// returns + +len = subarr.length; +// returns 4 + +z = subarr.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 2.0 + +z = subarr.get( len-1 ); +// returns + +re = real( z ); +// returns 7.0 + +im = imag( z ); +// returns 8.0 +``` + +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). + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var subarr = arr.subarray( 1 ); +// returns + +var len = subarr.length; +// returns 3 + +var z = subarr.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 4.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +subarr = arr.subarray( 1 ); +// returns + +len = subarr.length; +// returns 3 + +z = subarr.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 4.0 +``` + +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). + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +var subarr = arr.subarray( 1, -1 ); +// returns + +var len = subarr.length; +// returns 2 + +var z = subarr.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 4.0 + +z = subarr.get( len-1 ); +// returns + +re = realf( z ); +// returns 5.0 + +im = imagf( z ); +// returns 6.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +subarr = arr.subarray( 1, -1 ); +// returns + +len = subarr.length; +// returns 2 + +z = subarr.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 4.0 + +z = subarr.get( len-1 ); +// returns + +re = real( z ); +// returns 5.0 + +im = imag( z ); +// returns 6.0 +``` + + + +#### ComplexArray.prototype.toLocaleString( \[locales\[, options]] ) + +Serializes an array as a locale-specific string. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 2 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); + +var str = arr.toLocaleString(); +// returns '1 + 1i,2 + 2i' + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 2 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); + +str = arr.toLocaleString(); +// returns '1 + 1i,2 + 2i' +``` + +The method supports the following arguments: + +- **locales**: a string with a BCP 47 language tag or an array of such strings. +- **options**: configuration properties. + + + +#### ComplexArray.prototype.toReversed() + +Returns a new typed array containing the elements in reversed order. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var out = arr.toReversed(); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 3.0 + +var im = imagf( z ); +// returns 3.0 + +z = out.get( 2 ); +// returns + +re = realf( z ); +// returns 1.0 + +im = imagf( z ); +// returns 1.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +out = arr.toReversed(); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns 3.0 + +z = out.get( 2 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 1.0 +``` + + + +#### ComplexArray.prototype.toSorted( compareFcn ) + +Returns a new typed array containing the elements in sorted order. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +function compare64( a, b ) { + var re1 = realf( a ); + var re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + var im1 = imagf( a ); + var im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +var arr = new Complex64Array( 3 ); + +arr.set( [ 3.0, -3.0 ], 0 ); +arr.set( [ 1.0, -1.0 ], 1 ); +arr.set( [ 2.0, -2.0 ], 2 ); + +var out = arr.toSorted( compare64 ); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 1.0 + +var im = imagf( z ); +// returns -1.0 + +z = out.get( 2 ); +// returns + +re = realf( z ); +// returns 3.0 + +im = imagf( z ); +// returns -3.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +function compare128( a, b ) { + var re1 = real( a ); + var re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + var im1 = imag( a ); + var im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +arr = new Complex128Array( 3 ); + +arr.set( [ 3.0, -3.0 ], 0 ); +arr.set( [ 1.0, -1.0 ], 1 ); +arr.set( [ 2.0, -2.0 ], 2 ); + +out = arr.toSorted( compare128 ); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns -1.0 + +z = out.get( 2 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); +// returns -3.0 +``` + +The `compareFcn` determines the order of the elements. The function is called with the following arguments: + +- **a**: the first element for comparison. +- **b**: the second element for comparison. + +The function should return a number where: + +- a negative value indicates that `a` should come before `b`. +- a positive value indicates that `a` should come after `b`. +- zero or `NaN` indicates that `a` and `b` are considered equal. + +In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. + + + +#### ComplexArray.prototype.toString() + +Serializes an array as a string. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var str = arr.toString(); +// returns '1 + 1i,2 - 2i,3 + 3i' + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +str = arr.toString(); +// returns '1 + 1i,2 - 2i,3 + 3i' +``` + + + +#### ComplexArray.prototype.values() + +Returns an iterator for iterating over each value in a typed array. + +```javascript +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +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 + +var re = realf( v ); +// returns 1.0 + +var im = imagf( v ); +// returns -1.0 + +v = iter.next().value; +// returns + +re = realf( v ); +// returns 2.0 + +im = imagf( v ); +// returns -2.0 + +var bool = iter.next().done; +// returns true + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 2 ); + +arr.set( [ 1.0, -1.0 ], 0 ); +arr.set( [ 2.0, -2.0 ], 1 ); + +iter = arr.values(); + +v = iter.next().value; +// returns + +re = real( v ); +// returns 1.0 + +im = imag( v ); +// returns -1.0 + +v = iter.next().value; +// returns + +re = real( v ); +// returns 2.0 + +im = imag( v ); +// returns -2.0 + +bool = iter.next().done; +// returns true +``` + + + +#### ComplexArray.prototype.with( index, value ) + +Returns a new typed array with the element at a provided index replaced with a provided value. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + +var arr = new Complex64Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +var out = arr.with( 0, new Complex64( 4.0, 4.0 ) ); +// returns + +var z = out.get( 0 ); +// returns + +var re = realf( z ); +// returns 4.0 + +var im = imagf( z ); +// returns 4.0 + +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); + +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +arr = new Complex128Array( 3 ); + +arr.set( [ 1.0, 1.0 ], 0 ); +arr.set( [ 2.0, 2.0 ], 1 ); +arr.set( [ 3.0, 3.0 ], 2 ); + +out = arr.with( 0, new Complex128( 4.0, 4.0 ) ); +// returns + +z = out.get( 0 ); +// returns + +re = real( z ); +// returns 4.0 + +im = imag( z ); +// returns 4.0 +``` + +
+ + + + + +
+ +* * * + +## Notes + +- While a `ComplexArray` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: + + - The constructor does **not** require the `new` operator. + - The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input. + - Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output. + - The `set` method has extended behavior in order to support complex numbers. + +
+ + + + + +
+ +* * * + +## Examples + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var logEach = require( '@stdlib/console/log-each' ); +var complexFactory = require( '@stdlib/array/complex-factory' ); + +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +// Create a complex array by specifying a length: +var out = new Complex64Array( 3 ); +logEach( '%s', out ); + +out = new Complex128Array( 3 ); +logEach( '%s', out ); + +// Create a complex array from an array of complex numbers: +var arr = [ + new Complex64( 1.0, -1.0 ), + new Complex64( -3.14, 3.14 ), + new Complex64( 0.5, 0.5 ) +]; +out = new Complex64Array( arr ); +logEach( '%s', out ); + +arr = [ + new Complex128( 1.0, -1.0 ), + new Complex128( -3.14, 3.14 ), + new Complex128( 0.5, 0.5 ) +]; +out = new Complex128Array( arr ); +logEach( '%s', out ); + +// Create a complex array from an interleaved typed array: +arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex64Array( arr ); +logEach( '%s', out ); + +arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex128Array( arr ); +logEach( '%s', out ); + +// Create a complex array from an array buffer: +arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex64Array( arr.buffer ); +logEach( '%s', out ); + +arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex128Array( arr.buffer ); +logEach( '%s', out ); + +// Create a complex array from an array buffer view: +arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex64Array( arr.buffer, 8, 2 ); +logEach( '%s', out ); + +arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex128Array( arr.buffer, 16, 2 ); +logEach( '%s', out ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js new file mode 100644 index 000000000000..640751d6288a --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js @@ -0,0 +1,160 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,nonnegative_indices:at', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var N; + var z; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.at( i%N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,negative_indices:at', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var N; + var z; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.at( -(i%N)-1 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,nonnegative_indices:at', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var N; + var z; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.at( i%N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,negative_indices:at', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var N; + var z; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.at( -(i%N)-1 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js new file mode 100644 index 000000000000..beab30c25fe4 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js @@ -0,0 +1,101 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,copyWithin:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var buf; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = []; + for ( i = 0; i < 5; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + buf = arr.buffer; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = i; + arr = arr.copyWithin( 1, 0 ); + if ( buf[ 0 ] !== i ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( buf[ 0 ] !== buf[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,copyWithin:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var buf; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = []; + for ( i = 0; i < 5; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + buf = arr.buffer; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = i; + arr = arr.copyWithin( 1, 0 ); + if ( buf[ 0 ] !== i ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( buf[ 0 ] !== buf[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js new file mode 100644 index 000000000000..42ec992491d8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js @@ -0,0 +1,172 @@ +/** +* @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 pow = require( '@stdlib/math/base/special/pow' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for Complex128Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var buf; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = []; + for ( i = 0; i < len+1; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + buf = arr.buffer; + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = i; + arr.copyWithin( 1, 0 ); + if ( buf[ 0 ] !== i ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( buf[ 0 ] !== buf[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for Complex64Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var buf; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = []; + for ( i = 0; i < len+1; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + buf = arr.buffer; + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = i; + arr.copyWithin( 1, 0 ); + if ( buf[ 0 ] !== i ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( buf[ 0 ] !== buf[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128,copyWithin:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64,copyWithin:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js new file mode 100644 index 000000000000..edb09ef25f75 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js @@ -0,0 +1,97 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,entries:len=10', pkg ), function benchmark( b ) { + var Complex128Array; + var iter; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.entries(); + if ( typeof iter !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { + b.fail( 'should return an iterator protocol-compliant object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,entries:len=10', pkg ), function benchmark( b ) { + var Complex64Array; + var iter; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.entries(); + if ( typeof iter !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { + b.fail( 'should return an iterator protocol-compliant object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js new file mode 100644 index 000000000000..9acb9060256a --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js @@ -0,0 +1,97 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:every', pkg ), function benchmark( b ) { + var Complex128Array; + var bool; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:every', pkg ), function benchmark( b ) { + var Complex64Array; + var bool; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js new file mode 100644 index 000000000000..6bc1d4afadb5 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js @@ -0,0 +1,193 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate128 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate64 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:every:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:every:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js new file mode 100644 index 000000000000..eeb0d30c501f --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js @@ -0,0 +1,100 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:fill', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var out; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + values = [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, 3.0 ) + ]; + arr = new Complex128Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:fill', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var out; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + values = [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, 3.0 ) + ]; + arr = new Complex64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js new file mode 100644 index 000000000000..e99ba91e499d --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js @@ -0,0 +1,165 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var values; + var out; + var i; + + values = [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, 3.0 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var values; + var out; + var i; + + values = [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, 3.0 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:fill:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:fill:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js new file mode 100644 index 000000000000..ff19675ffe60 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js @@ -0,0 +1,96 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:filter', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:filter', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js new file mode 100644 index 000000000000..0dc9408ab4c3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js @@ -0,0 +1,193 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate128 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate64 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:filter:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:filter:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js new file mode 100644 index 000000000000..addb381f658e --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js @@ -0,0 +1,96 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:find', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var z; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.find( predicate ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:find', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var z; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.find( predicate ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js new file mode 100644 index 000000000000..677c5eeac2cf --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === -imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === -imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr.push( new Complex128( len-1, -( len-1 ) ) ); + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.find( predicate128 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr.push( new Complex64( len-1, -( len-1 ) ) ); + arr = new Complex64Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.find( predicate64 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:find:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:find:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js new file mode 100644 index 000000000000..7b71c9ba9493 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js @@ -0,0 +1,97 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:findIndex', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var idx; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:findIndex', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var idx; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js new file mode 100644 index 000000000000..b64e292b4449 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === -imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === -imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr.push( new Complex128( len-1, -( len-1 ) ) ); + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate128 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr.push( new Complex64( len-1, -( len-1 ) ) ); + arr = new Complex64Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate64 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:findIndex:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:findIndex:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js new file mode 100644 index 000000000000..dc609d7e693f --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js @@ -0,0 +1,96 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:findLast', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var z; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.findLast( predicate ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:findLast', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var z; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.findLast( predicate ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js new file mode 100644 index 000000000000..f07417957b45 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === -imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === -imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + arr.push( new Complex128( 1, -1 ) ); + for ( i = 1; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.findLast( predicate128 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + arr.push( new Complex64( 1, -1 ) ); + for ( i = 1; 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 z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.findLast( predicate64 ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( z ) ) { + b.fail( 'should return a complex number' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:findLast:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:findLast:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js new file mode 100644 index 000000000000..302cc4410af7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js @@ -0,0 +1,97 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:findLastIndex', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var idx; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findLastIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:findLastIndex', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var idx; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findLastIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js new file mode 100644 index 000000000000..35e6251f2ee4 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === -imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === -imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + arr.push( new Complex128( 1, -1 ) ); + for ( i = 1; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findLastIndex( predicate128 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + arr.push( new Complex64( 1, -1 ) ); + for ( i = 1; 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 idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findLastIndex( predicate64 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:findLastIndex:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:findLastIndex:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js new file mode 100644 index 000000000000..e0cba1e9ec6a --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js @@ -0,0 +1,98 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:forEach', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( check ); + if ( arr.length !== 2 ) { + b.fail( 'should not change an array length' ); + } + } + b.toc(); + if ( arr.length !== 2 ) { + b.fail( 'should not change an array length' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function check( v ) { + if ( !isComplexLike( v ) ) { + b.fail( 'should be a complex number' ); + } + } +}); + +bench( format( '%s::complex64:forEach', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( check ); + if ( arr.length !== 2 ) { + b.fail( 'should not change an array length' ); + } + } + b.toc(); + if ( arr.length !== 2 ) { + b.fail( 'should not change an array length' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function check( v ) { + if ( !isComplexLike( v ) ) { + b.fail( 'should be a complex number' ); + } + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js new file mode 100644 index 000000000000..8dcd737647fe --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js @@ -0,0 +1,176 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( callback ); + if ( arr.length !== len ) { + b.fail( 'should not change an array length' ); + } + } + b.toc(); + if ( arr.length !== len ) { + b.fail( 'should not change an array length' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function callback( value ) { + if ( real( value ) !== imag( value ) ) { + throw new Error( 'something went wrong' ); + } + } + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( callback ); + if ( arr.length !== len ) { + b.fail( 'should not change an array length' ); + } + } + b.toc(); + if ( arr.length !== len ) { + b.fail( 'should not change an array length' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function callback( value ) { + if ( realf( value ) !== imagf( value ) ) { + throw new Error( 'something went wrong' ); + } + } + } +} + + +// 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 = createBenchmark128( len ); + bench( format( '%s::complex128:forEach:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:forEach:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js new file mode 100644 index 000000000000..43bbc1d53d2c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js @@ -0,0 +1,791 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': ( ITERATOR_SYMBOL === null ) +}; + + +// MAIN // + +bench( format( '%s::complex128,typed_array,from', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Float64Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,typed_array,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Float64Array( 10 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,typed_array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Float64Array( 10 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v + 1.0; + } +}); + +bench( format( '%s::complex128,complex_typed_array,from', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Complex128Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,complex_typed_array,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Complex128Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,complex_typed_array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Complex128Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v; + } +}); + +bench( format( '%s::complex128,array,from', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = []; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,array,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v + 1.0; + } +}); + +bench( format( '%s::complex128,iterable,from', pkg ), opts, function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( createIterable() ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +bench( format( '%s::complex128,iterable,from:len=5', pkg ), opts, function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( createIterable() ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + var it = { + 'next': next, + 'i': 0, + 'N': 5 + }; + return it; + + function next() { + it.i += 1; + if ( it.i <= it.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + } + } +}); + +bench( format( '%s::complex128,iterable,clbk,from:len=5', pkg ), opts, function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.from( createIterable(), clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + var it = { + 'next': next, + 'i': 0, + 'N': 5 + }; + return it; + + function next() { + it.i += 1; + if ( it.i <= it.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + } + } + + function clbk( v ) { + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } +}); + +bench( format( '%s::complex64,typed_array,from', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Float32Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,typed_array,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Float32Array( 10 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,typed_array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Float32Array( 10 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v + 1.0; + } +}); + +bench( format( '%s::complex64,complex_typed_array,from', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Complex64Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,complex_typed_array,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Complex64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,complex_typed_array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Complex64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v; + } +}); + +bench( format( '%s::complex64,array,from', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = []; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,array,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,array,clbk,from:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( buf, clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function clbk( v ) { + return v + 1.0; + } +}); + +bench( format( '%s::complex64,iterable,from', pkg ), opts, function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( createIterable() ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +bench( format( '%s::complex64,iterable,from:len=5', pkg ), opts, function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( createIterable() ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + var it = { + 'next': next, + 'i': 0, + 'N': 5 + }; + return it; + + function next() { + it.i += 1; + if ( it.i <= it.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + } + } +}); + +bench( format( '%s::complex64,iterable,clbk,from:len=5', pkg ), opts, function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.from( createIterable(), clbk ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + var it = { + 'next': next, + 'i': 0, + 'N': 5 + }; + return it; + + function next() { + it.i += 1; + if ( it.i <= it.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + } + } + + function clbk( v ) { + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js new file mode 100644 index 000000000000..a794f02b5cb8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js @@ -0,0 +1,103 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplex64 = require( '@stdlib/assert/is-complex64' ); +var isComplex128 = require( '@stdlib/assert/is-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,get', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var N; + var z; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.get( i%N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplex128( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,get', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var N; + var z; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = arr.get( i%N ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplex64( z ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js new file mode 100644 index 000000000000..e4ad61125eb8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js @@ -0,0 +1,102 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:includes', pkg ), function benchmark( b ) { + var Complex128Array; + var bool; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + v = new Complex128( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v, 0 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:includes', pkg ), function benchmark( b ) { + var Complex64Array; + var bool; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + + v = new Complex64( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v, 0 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js new file mode 100644 index 000000000000..847dafaa13cd --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js @@ -0,0 +1,175 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr.push( new Complex128( i, i ) ); + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var v; + var i; + + v = new Complex128( len-1, len-1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex64( i, -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 bool; + var v; + var i; + + v = new Complex64( len-1, len-1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:includes:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:includes:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js new file mode 100644 index 000000000000..1905a555fb06 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js @@ -0,0 +1,102 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:indexOf', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var idx; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + v = new Complex128( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.indexOf( v, 0 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:indexOf', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var idx; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + + v = new Complex64( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.indexOf( v, 0 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js new file mode 100644 index 000000000000..8dd03af89d56 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js @@ -0,0 +1,175 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr.push( new Complex128( i, i ) ); + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var v; + var i; + + v = new Complex128( len-1, len-1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.indexOf( v ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex64( i, -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 idx; + var v; + var i; + + v = new Complex64( len-1, len-1 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.indexOf( v ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:indexOf:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:indexOf:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js new file mode 100644 index 000000000000..ba5c9acd2812 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js @@ -0,0 +1,87 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:join', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:join', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js new file mode 100644 index 000000000000..ec70e1bb0f77 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js @@ -0,0 +1,166 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join( '/' ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join( '/' ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:join:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:join:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js new file mode 100644 index 000000000000..b595b8a068d6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js @@ -0,0 +1,754 @@ +/** +* @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 ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': ( ITERATOR_SYMBOL === null ) +}; + + +// MAIN // + +bench( format( '%s::complex128,instantiation,new', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,no_new', pkg ), function benchmark( b ) { + var Complex128Array; + var ctor; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctor = Complex128Array; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = ctor(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,length', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,typed_array', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Float64Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,complex_typed_array', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new Complex128Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,array', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = []; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,iterable', pkg ), opts, function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( createIterable() ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +bench( format( '%s::complex128,instantiation,arraybuffer', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new ArrayBuffer( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new ArrayBuffer( 16 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf, 16 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = new ArrayBuffer( 16 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex128Array( buf, 16, 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,get:buffer', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.buffer; + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isArrayBuffer( v ) ) { + b.fail( 'should return an ArrayBuffer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,get:byteLength', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.byteLength; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,get:byteOffset', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.byteOffset; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,get:length', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.length; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,new', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,no_new', pkg ), function benchmark( b ) { + var Complex64Array; + var ctor; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctor = Complex64Array; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = ctor(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,length', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,typed_array', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Float32Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,complex_typed_array', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new Complex64Array( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,array', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = []; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,iterable', pkg ), opts, function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( createIterable() ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function createIterable() { + var out = {}; + out[ ITERATOR_SYMBOL ] = iterator; + return out; + + function iterator() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +bench( format( '%s::complex64,instantiation,arraybuffer', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new ArrayBuffer( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new ArrayBuffer( 8 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf, 8 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = new ArrayBuffer( 8 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Complex64Array( buf, 8, 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,get:buffer', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.buffer; + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isArrayBuffer( v ) ) { + b.fail( 'should return an ArrayBuffer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,get:byteLength', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.byteLength; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,get:byteOffset', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.byteOffset; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,get:length', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... + v = arr.length; + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( v ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js new file mode 100644 index 000000000000..6f8314ef77d1 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:keys:len=2', pkg ), function benchmark( b ) { + var Complex128Array; + var iter; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.keys(); + 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(); +}); + +bench( format( '%s::complex64:keys:len=2', pkg ), function benchmark( b ) { + var Complex64Array; + var iter; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.keys(); + 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(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js new file mode 100644 index 000000000000..36963bb7e573 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( 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.keys(); + 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(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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.keys(); + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:keys:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:keys:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js new file mode 100644 index 000000000000..6d96c47cad20 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js @@ -0,0 +1,102 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:lastIndexOf', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var idx; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + v = new Complex128( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.lastIndexOf( v, 9 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:lastIndexOf', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var idx; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( arr ); + + v = new Complex64( 10.0, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.lastIndexOf( v, 9 ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js new file mode 100644 index 000000000000..2e53c78bbf83 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js @@ -0,0 +1,173 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var v; + var i; + + v = new Complex128( 0, 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.lastIndexOf( v ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 idx; + var v; + var i; + + v = new Complex64( 0, 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.lastIndexOf( v ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:lastIndexOf:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:lastIndexOf:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js new file mode 100644 index 000000000000..b0c42dc61cfc --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js @@ -0,0 +1,152 @@ +/** +* @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 pow = require( '@stdlib/math/base/special/pow' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for Complex128Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + 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 = new Complex128Array( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for Complex64Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + 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 = new Complex64Array( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128,len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64,len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js new file mode 100644 index 000000000000..5cf346828785 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js @@ -0,0 +1,96 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:map', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( scale ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function scale( v ) { + return new Complex128( real( v )*2.0, imag( v )*2.0 ); + } +}); + +bench( format( '%s::complex64:map', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( scale ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function scale( v ) { + return new Complex64( realf( v )*2.0, imagf( v )*2.0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js new file mode 100644 index 000000000000..2312472b7377 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js @@ -0,0 +1,168 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var identity = require( '@stdlib/utils/identity-function' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( identity ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( identity ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:map:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:map:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js new file mode 100644 index 000000000000..ede18435b438 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js @@ -0,0 +1,187 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,of', pkg ), function benchmark( b ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.of(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,interleaved,of:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.of.apply( Complex128Array, buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,complex_numbers,of:len=5', pkg ), function benchmark( b ) { + var Complex128Array; + var buf; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + buf = []; + for ( i = 0; i < 5; i++ ) { + buf.push( new Complex128( 1.0, 1.0 ) ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex128Array.of.apply( Complex128Array, buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex128Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,of', pkg ), function benchmark( b ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.of(); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,interleaved,of:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.of.apply( Complex64Array, buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,complex_numbers,of:len=5', pkg ), function benchmark( b ) { + var Complex64Array; + var buf; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + buf = []; + for ( i = 0; i < 5; i++ ) { + buf.push( new Complex64( 1.0, 1.0 ) ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = Complex64Array.of.apply( Complex64Array, buf ); + if ( arr.length !== 5 ) { + b.fail( 'should have length 5' ); + } + } + b.toc(); + if ( !(arr instanceof Complex64Array) ) { + b.fail( 'should return an instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js new file mode 100644 index 000000000000..6e312e9dfb97 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js @@ -0,0 +1,90 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:reduce', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( cadd ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:reduce', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( caddf ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js new file mode 100644 index 000000000000..7156847c7a38 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js @@ -0,0 +1,169 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( cadd ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( caddf ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:reduce:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:reduce:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js new file mode 100644 index 000000000000..e59e42da0436 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js @@ -0,0 +1,90 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:reduceRight', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduceRight( cadd ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:reduceRight', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduceRight( caddf ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js new file mode 100644 index 000000000000..2a485a079e96 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js @@ -0,0 +1,169 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var cadd = require( '@stdlib/complex/float64/base/add' ); +var caddf = require( '@stdlib/complex/float32/base/add' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduceRight( cadd ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduceRight( caddf ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out ) ) { + b.fail( 'should return a complex number' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:reduceRight:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:reduceRight:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js new file mode 100644 index 000000000000..bc4d6235e352 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:reverse', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:reverse', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js new file mode 100644 index 000000000000..bd92e11cd0de --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:reverse:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:reverse:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js new file mode 100644 index 000000000000..985861ffaf89 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js @@ -0,0 +1,325 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128,complex_number,set', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var N; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = []; + for ( i = 0; i < 10; i++ ) { + values.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( values ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( values[ (i+1)%N ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,array,set', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var N; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = []; + for ( i = 0; i < 10; i++ ) { + values.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( values ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( [ values[ (i+1)%N ] ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,typed_array,set', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var buf; + var M; + var N; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = new Float64Array( 20 ); + M = values.length; + for ( i = 0; i < M; i++ ) { + values[ i ] = i; + } + + arr = new Complex128Array( values ); + N = arr.length; + + buf = new Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = values[ i%N ]; + buf[ 1 ] = values[ (i+1)%N ]; + v = arr.set( buf ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex128,complex_typed_array,set', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var buf; + var M; + var N; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = new Float64Array( 20 ); + M = values.length; + for ( i = 0; i < M; i++ ) { + values[ i ] = i; + } + + arr = new Complex128Array( values ); + N = arr.length; + + buf = new Complex128Array( 1 ); + buf.set( new Complex128( 1.0, -1.0 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( buf, i%N ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,complex_number,set', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var N; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = []; + for ( i = 0; i < 10; i++ ) { + values.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( values ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( values[ (i+1)%N ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,array,set', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var N; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = []; + for ( i = 0; i < 10; i++ ) { + values.push( new Complex64( i, i ) ); + } + arr = new Complex64Array( values ); + N = arr.length; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( [ values[ (i+1)%N ] ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,typed_array,set', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var buf; + var M; + var N; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = new Float32Array( 20 ); + M = values.length; + for ( i = 0; i < M; i++ ) { + values[ i ] = i; + } + + arr = new Complex64Array( values ); + N = arr.length; + + buf = new Float32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + buf[ 0 ] = values[ i%N ]; + buf[ 1 ] = values[ (i+1)%N ]; + v = arr.set( buf ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64,complex_typed_array,set', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var buf; + var M; + var N; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = new Float32Array( 20 ); + M = values.length; + for ( i = 0; i < M; i++ ) { + values[ i ] = i; + } + + arr = new Complex64Array( values ); + N = arr.length; + + buf = new Complex64Array( 1 ); + buf.set( new Complex64( 1.0, -1.0 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr.set( buf, i%N ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js new file mode 100644 index 000000000000..007856683c14 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js @@ -0,0 +1,197 @@ +/** +* @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 pow = require( '@stdlib/math/base/special/pow' ); +var randu = require( '@stdlib/random/base/randu' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for Complex128Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var values; + var arr1; + var arr2; + var arr3; + var N; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr1 = []; + arr2 = []; + arr3 = []; + for ( i = 0; i < len; i++ ) { + arr1.push( new Complex128( i, i ) ); + arr2.push( new Complex128( randu(), randu() ) ); + arr3.push( new Complex128( randu(), -randu() ) ); + } + arr1 = new Complex128Array( arr1 ); + + values = [ + new Complex128Array( arr2 ), + new Complex128Array( arr3 ) + ]; + N = values.length; + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr1.set( values[ i%N ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for Complex64Array. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var values; + var arr1; + var arr2; + var arr3; + var N; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr1 = []; + arr2 = []; + arr3 = []; + for ( i = 0; i < len; i++ ) { + arr1.push( new Complex64( i, i ) ); + arr2.push( new Complex64( randu(), randu() ) ); + arr3.push( new Complex64( randu(), -randu() ) ); + } + arr1 = new Complex64Array( arr1 ); + + values = [ + new Complex64Array( arr2 ), + new Complex64Array( arr3 ) + ]; + N = values.length; + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = arr1.set( values[ i%N ] ); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof v !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + 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 = 4; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark128( len ); + bench( format( '%s::complex128,set:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64,set:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js new file mode 100644 index 000000000000..9fffb3fd8252 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:slice', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.slice(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:slice', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.slice(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js new file mode 100644 index 000000000000..60ed96ca9dc6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.slice(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.slice(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:slice:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:slice:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js new file mode 100644 index 000000000000..736b8efa651c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js @@ -0,0 +1,97 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:some', pkg ), function benchmark( b ) { + var Complex128Array; + var bool; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.some( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); + +bench( format( '%s::complex64:some', pkg ), function benchmark( b ) { + var Complex64Array; + var bool; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.some( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isComplexLike( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js new file mode 100644 index 000000000000..bc28c3a5babb --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js @@ -0,0 +1,195 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function for complex128. +* +* @private +* @param {Complex128} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate128( value ) { + return ( real( value ) === imag( value ) ); +} + +/** +* Predicate function for complex64. +* +* @private +* @param {Complex64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Object} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate64( value ) { + return ( realf( value ) === imagf( value ) ); +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr.push( new Complex128( i, i ) ); + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.some( predicate128 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Complex64( i, -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 bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.some( predicate64 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:some:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:some:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js new file mode 100644 index 000000000000..9e94a9b9a8a7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js @@ -0,0 +1,155 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128. +* +* @private +* @param {Complex128} a - first value +* @param {Complex128} b - second value +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64. +* +* @private +* @param {Complex64} a - first value +* @param {Complex64} b - second value +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + + +// MAIN // + +bench( format( '%s::complex128:sort', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.sort( compareFcn128 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:sort', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.sort( compareFcn64 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js new file mode 100644 index 000000000000..070046c98afa --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js @@ -0,0 +1,231 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128. +* +* @private +* @param {Complex128} a - first value +* @param {Complex128} b - second value +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64. +* +* @private +* @param {Complex64} a - first value +* @param {Complex64} b - second value +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.sort( compareFcn128 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.sort( compareFcn64 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:sort:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:sort:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js new file mode 100644 index 000000000000..9b747830b668 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:subarray', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.subarray(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:subarray', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.subarray(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js new file mode 100644 index 000000000000..eb6c171e51b0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.subarray(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.subarray(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:subarray:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:subarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js new file mode 100644 index 000000000000..97a0213584ad --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js @@ -0,0 +1,87 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:toLocaleString', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toLocaleString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:toLocaleString', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toLocaleString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js new file mode 100644 index 000000000000..bedd73630f5c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js @@ -0,0 +1,166 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toLocaleString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toLocaleString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:toLocaleString:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:toLocaleString:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js new file mode 100644 index 000000000000..88edaba02284 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:toReversed', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:toReversed', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js new file mode 100644 index 000000000000..c4fc419d8a3d --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:toReversed:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:toReversed:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js new file mode 100644 index 000000000000..f2042a2bc3d3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js @@ -0,0 +1,155 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128. +* +* @private +* @param {Complex128} a - first value +* @param {Complex128} b - second value +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64. +* +* @private +* @param {Complex64} a - first value +* @param {Complex64} b - second value +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + + +// MAIN // + +bench( format( '%s::complex128:toSorted', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toSorted( compareFcn128 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:toSorted', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toSorted( compareFcn64 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js new file mode 100644 index 000000000000..88bf5bdd1415 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js @@ -0,0 +1,231 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128. +* +* @private +* @param {Complex128} a - first value +* @param {Complex128} b - second value +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64. +* +* @private +* @param {Complex64} a - first value +* @param {Complex64} b - second value +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toSorted( compareFcn128 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toSorted( compareFcn64 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:toSorted:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:toSorted:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js new file mode 100644 index 000000000000..4132304c0857 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js @@ -0,0 +1,87 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:toString', pkg ), function benchmark( b ) { + var Complex128Array; + var out; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:toString', pkg ), function benchmark( b ) { + var Complex64Array; + var out; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js new file mode 100644 index 000000000000..1efb7b63c4f9 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js @@ -0,0 +1,166 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toString(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:toString:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:toString:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js new file mode 100644 index 000000000000..1fac6caa28d9 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js @@ -0,0 +1,88 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:values:len=2', pkg ), function benchmark( b ) { + var Complex128Array; + var iter; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 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(); +}); + +bench( format( '%s::complex64:values:len=2', pkg ), function benchmark( b ) { + var Complex64Array; + var iter; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js new file mode 100644 index 000000000000..e4cc3802c7b5 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js @@ -0,0 +1,167 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( new Complex128( i, i ) ); + } + arr = new Complex128Array( 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(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + 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 = createBenchmark128( len ); + bench( format( '%s::complex128:values:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:values:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js new file mode 100644 index 000000000000..370623175360 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js @@ -0,0 +1,100 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::complex128:with', pkg ), function benchmark( b ) { + var Complex128Array; + var values; + var arr; + var out; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + values = [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, 3.0 ) + ]; + arr = new Complex128Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.with( i%arr.length, values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::complex64:with', pkg ), function benchmark( b ) { + var Complex64Array; + var values; + var arr; + var out; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + values = [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, 3.0 ) + ]; + arr = new Complex64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.with( i%arr.length, values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js new file mode 100644 index 000000000000..6ac351be0813 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js @@ -0,0 +1,165 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function for complex128. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark128( len ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var values; + var out; + var i; + + values = [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, 3.0 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.with( i%len, values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + +/** +* Creates a benchmark function for complex64. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark64( len ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var values; + var out; + var i; + + values = [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, 3.0 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.with( i%len, values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isComplexLike( out.get( 0 ) ) ) { + b.fail( 'should return a complex 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 = createBenchmark128( len ); + bench( format( '%s::complex128:with:len=%d', pkg, len ), f ); + } + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark64( len ); + bench( format( '%s::complex64:with:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt new file mode 100644 index 000000000000..b9fbe3f64f75 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt @@ -0,0 +1,2878 @@ +{{alias}}( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) + Returns a complex number typed array constructor. + + Parameters + ---------- + dtype: string + Complex number array data type (e.g., 'complex64'). + + FloatArray: Function + Underlying float typed array constructor (e.g., Float32Array). + + ComplexScalar: Function + Complex number scalar constructor (e.g., Complex64). + + getReal: Function + Function returning the real component of a complex number. + + getImag: Function + Function returning the imaginary component of a complex number. + + reinterpret: Function + Function reinterpreting a same-type complex array as its underlying + float array. + + Returns + ------- + ctor: Function + Complex number typed array constructor. + + Examples + -------- + > var f = require( '@stdlib/array/float32' ); + > var C = require( '@stdlib/complex/float32/ctor' ); + > var re = require( '@stdlib/complex/float32/real' ); + > var im = require( '@stdlib/complex/float32/imag' ); + > var ri = require( '@stdlib/strided/base/reinterpret-complex64' ); + > var Complex64Array = {{alias}}( 'complex64', f, C, re, im, ri ) + + > var arr = new Complex64Array( 3 ) + + + +{{alias:@stdlib/array/complex128}}() + A 128-bit complex number array. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}() + + + +{{alias:@stdlib/array/complex64}}() + A 64-bit complex number array. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}() + + + +{{alias:@stdlib/array/complex128}}( length ) + Creates a 128-bit complex number array having a specified length. + + Parameters + ---------- + length: integer + Typed array length. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 10 ) + + > var len = arr.length + 10 + + +{{alias:@stdlib/array/complex64}}( length ) + Creates a 64-bit complex number array having a specified length. + + Parameters + ---------- + length: integer + Typed array length. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 10 ) + + > var len = arr.length + 10 + + +{{alias:@stdlib/array/complex128}}( complexarray ) + Creates a 128-bit complex number array from another complex number array. + + Parameters + ---------- + complexarray: Complex128Array + Complex array from which to generate another complex array. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var arr1 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var arr2 = new {{alias:@stdlib/array/complex128}}( arr1 ) + + > var len = arr2.length + 2 + + +{{alias:@stdlib/array/complex64}}( complexarray ) + Creates a 64-bit complex number array from another complex number array. + + Parameters + ---------- + complexarray: Complex64Array + Complex array from which to generate another complex array. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var arr1 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var arr2 = new {{alias:@stdlib/array/complex64}}( arr1 ) + + > var len = arr2.length + 2 + + +{{alias:@stdlib/array/complex128}}( typedarray ) + Creates a 128-bit complex number array from a typed array containing + interleaved real and imaginary components. + + Parameters + ---------- + typedarray: TypedArray + Typed array from which to generate a complex array. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/float64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) + + > var len = arr.length + 2 + + +{{alias:@stdlib/array/complex64}}( typedarray ) + Creates a 64-bit complex number array from a typed array containing + interleaved real and imaginary components. + + Parameters + ---------- + typedarray: TypedArray + Typed array from which to generate complex array. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/float32}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) + + > var len = arr.length + 2 + + +{{alias:@stdlib/array/complex128}}( obj ) + Creates a 128-bit complex number array from an array-like object or + iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate a complex array. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var arr1 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var len = arr1.length + 2 + > var buf = [ new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ) ]; + > var arr2 = new {{alias:@stdlib/array/complex128}}( buf ) + + > len = arr2.length + 2 + + +{{alias:@stdlib/array/complex64}}( obj ) + Creates a 64-bit complex number array from an array-like object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate a complex array. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var arr1 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var len = arr1.length + 2 + > var buf = [ new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ) ]; + > var arr2 = new {{alias:@stdlib/array/complex64}}( buf ) + + > len = arr2.length + 2 + + +{{alias:@stdlib/array/complex128}}( buffer[, byteOffset[, length]] ) + Returns a 128-bit complex number array view of an ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first typed array + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 480 ); + > var arr1 = new {{alias:@stdlib/array/complex128}}( buf ) + + > var len = arr1.length + 30 + > var arr2 = new {{alias:@stdlib/array/complex128}}( buf, 16 ) + + > len = arr2.length + 29 + > var arr3 = new {{alias:@stdlib/array/complex128}}( buf, 16, 20 ) + + > len = arr3.length + 20 + + +{{alias:@stdlib/array/complex64}}( buffer[, byteOffset[, length]] ) + Returns a 64-bit complex number array view of an ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first typed array + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); + > var arr1 = new {{alias:@stdlib/array/complex64}}( buf ) + + > var len = arr1.length + 30 + > var arr2 = new {{alias:@stdlib/array/complex64}}( buf, 8 ) + + > len = arr2.length + 29 + > var arr3 = new {{alias:@stdlib/array/complex64}}( buf, 8, 20 ) + + > len = arr3.length + 20 + + +{{alias:@stdlib/array/complex128}}.from( src[, clbk[, thisArg]] ) + Creates a new 128-bit complex number array from an array-like object or an + iterable. + + A callback function is provided two arguments: + + - value: source value. + - index: source index. + + Parameters + ---------- + src: ArrayLike|Iterable + Source of array elements. + + clbk: Function (optional) + Callback to invoke for each source element. + + thisArg: Any (optional) + Callback execution context. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > function clbkFcn( v ) { return v * 2.0 }; + > var arr = {{alias:@stdlib/array/complex128}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) + + > var len = arr.length + 2 + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex64}}.from( src[, clbk[, thisArg]] ) + Creates a new 64-bit complex number array from an array-like object or an + iterable. + + A callback function is provided two arguments: + + - value: source value. + - index: source index. + + Parameters + ---------- + src: ArrayLike|Iterable + Source of array elements. + + clbk: Function (optional) + Callback to invoke for each source element. + + thisArg: Any (optional) + Callback execution context. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > function clbkFcn( v ) { return v * 2.0 }; + > var arr = {{alias:@stdlib/array/complex64}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) + + > var len = arr.length + 2 + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex128}}.of( element0[, element1[, ...elementN]] ) + Creates a new 128-bit complex number array from a variable number of + arguments. + + Parameters + ---------- + element0: number|ComplexLike + Array element. + + element1: number|ComplexLike (optional) + Array element. + + elementN: ...number|ComplexLike (optional) + Array elements. + + Returns + ------- + out: Complex128Array + A typed array. + + Examples + -------- + > var arr = {{alias:@stdlib/array/complex128}}.of( 1.0, -1.0, 2.0, -2.0 ) + + > var len = arr.length + 2 + > var z1 = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ); + > var z2 = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ); + > arr = {{alias:@stdlib/array/complex128}}.of( z1, z2 ) + + > len = arr.length + 2 + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + + +{{alias:@stdlib/array/complex64}}.of( element0[, element1[, ...elementN]] ) + Creates a new 64-bit complex number array from a variable number of + arguments. + + Parameters + ---------- + element0: number + Array element. + + element1: number (optional) + Array element. + + elementN: ...number (optional) + Array elements. + + Returns + ------- + out: Complex64Array + A typed array. + + Examples + -------- + > var arr = {{alias:@stdlib/array/complex64}}.of( 1.0, -1.0, 2.0, -2.0 ) + + > var len = arr.length + 2 + > var z1 = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ); + > var z2 = new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ); + > arr = {{alias:@stdlib/array/complex64}}.of( z1, z2 ) + + > len = arr.length + 2 + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + + +{{alias:@stdlib/array/complex128}}.BYTES_PER_ELEMENT + The size of each array element in bytes. + + Examples + -------- + > var nbytes = {{alias:@stdlib/array/complex128}}.BYTES_PER_ELEMENT + 16 + + +{{alias:@stdlib/array/complex64}}.BYTES_PER_ELEMENT + The size of each array element in bytes. + + Examples + -------- + > var nbytes = {{alias:@stdlib/array/complex64}}.BYTES_PER_ELEMENT + 8 + + +{{alias:@stdlib/array/complex128}}.name + Typed array constructor name. + + Examples + -------- + > var str = {{alias:@stdlib/array/complex128}}.name + 'Complex128Array' + + +{{alias:@stdlib/array/complex64}}.name + Typed array constructor name. + + Examples + -------- + > var str = {{alias:@stdlib/array/complex64}}.name + 'Complex64Array' + + +{{alias:@stdlib/array/complex128}}.prototype.buffer + Pointer to the underlying data buffer. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 2 ) + + > var buf = arr.buffer + + + +{{alias:@stdlib/array/complex64}}.prototype.buffer + Pointer to the underlying data buffer. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 2 ) + + > var buf = arr.buffer + + + +{{alias:@stdlib/array/complex128}}.prototype.byteLength + Length of the array in bytes. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 10 ) + + > var nbytes = arr.byteLength + 160 + + +{{alias:@stdlib/array/complex64}}.prototype.byteLength + Length of the array in bytes. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 10 ) + + > var nbytes = arr.byteLength + 80 + + +{{alias:@stdlib/array/complex128}}.prototype.byteOffset + Offset (in bytes) of the array from the start of its underlying + ArrayBuffer. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 10 ) + + > var offset = arr.byteOffset + 0 + > var buf = new {{alias:@stdlib/array/buffer}}( 480 ); + > arr = new {{alias:@stdlib/array/complex128}}( buf, 128 ) + + > offset = arr.byteOffset + 128 + + +{{alias:@stdlib/array/complex64}}.prototype.byteOffset + Offset (in bytes) of the array from the start of its underlying + ArrayBuffer. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 5 ) + + > var offset = arr.byteOffset + 0 + > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); + > arr = new {{alias:@stdlib/array/complex64}}( buf, 64 ) + + > offset = arr.byteOffset + 64 + + +{{alias:@stdlib/array/complex128}}.prototype.BYTES_PER_ELEMENT + Size (in bytes) of each array element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 10 ) + + > arr.BYTES_PER_ELEMENT + 16 + + +{{alias:@stdlib/array/complex64}}.prototype.BYTES_PER_ELEMENT + Size (in bytes) of each array element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 10 ) + + > arr.BYTES_PER_ELEMENT + 8 + + +{{alias:@stdlib/array/complex128}}.prototype.length + The number of array elements. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 10 ) + + > var len = arr.length + 10 + + +{{alias:@stdlib/array/complex64}}.prototype.length + The number of array elements. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 10 ) + + > var len = arr.length + 10 + + +{{alias:@stdlib/array/complex128}}.prototype.at( i ) + Returns an array element located at integer position (index) `i`, with + support for both nonnegative and negative integer positions. + + If provided an index outside the array index range, the method returns + `undefined`. + + Parameters + ---------- + i: integer + Element index. + + Returns + ------- + out: Complex128|void + An array element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.at( 1 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.at( i ) + Returns an array element located at integer position (index) `i`, with + support for both nonnegative and negative integer positions. + + If provided an index outside the array index range, the method returns + `undefined`. + + Parameters + ---------- + i: integer + Element index. + + Returns + ------- + out: Complex64|void + An array element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.at( 1 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.copyWithin( target, start[, end] ) + Copies a sequence of elements within the array starting at `start` and + ending at `end` (non-inclusive) to the position starting at `target`. + + Parameters + ---------- + target: integer + Target start index position. + + start: integer + Source start index position. + + end: integer (optional) + Source end index position. Default: out.length. + + Returns + ------- + out: Complex128Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > arr.copyWithin( 0, 2 ) + + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.copyWithin( target, start[, end] ) + Copies a sequence of elements within the array starting at `start` and + ending at `end` (non-inclusive) to the position starting at `target`. + + Parameters + ---------- + target: integer + Target start index position. + + start: integer + Source start index position. + + end: integer (optional) + Source end index position. Default: out.length. + + Returns + ------- + out: Complex64Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > arr.copyWithin( 0, 2 ) + + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.entries() + Returns an iterator for iterating over array key-value pairs. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array key-value pairs. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > var it = arr.entries(); + > var v = it.next().value + [ 0, ] + > var re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) + -1.0 + > v = it.next().value + [ 1, ] + > re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) + -2.0 + > v = it.next().value + [ 2, ] + > re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) + -3.0 + > var bool = it.next().done + true + + +{{alias:@stdlib/array/complex64}}.prototype.entries() + Returns an iterator for iterating over array key-value pairs. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array key-value pairs. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > var it = arr.entries(); + > var v = it.next().value + [ 0, ] + > var re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) + -1.0 + > v = it.next().value + [ 1, ] + > re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) + -2.0 + > v = it.next().value + [ 2, ] + > re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) + 3.0 + > im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) + -3.0 + > var bool = it.next().done + true + + +{{alias:@stdlib/array/complex128}}.prototype.every( predicate[, thisArg] ) + Returns a boolean indicating whether all elements in the array pass a test. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. If a predicate function + returns a truthy value, an array element passes; otherwise, an array + element fails. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + bool: boolean + Boolean indicating whether all elements pass the test. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) > 0.0 ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var bool = arr.every( predicate ) + true + + +{{alias:@stdlib/array/complex64}}.prototype.every( predicate[, thisArg] ) + Returns a boolean indicating whether all elements in the array pass a test. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. If a predicate function + returns a truthy value, an array element passes; otherwise, an array + element fails. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + bool: boolean + Boolean indicating whether all elements pass the test. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) > 0.0 ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var bool = arr.every( predicate ) + true + + +{{alias:@stdlib/array/complex128}}.prototype.fill( value[, start[, end]] ) + Returns a modified typed array filled with a fill value. + + Parameters + ---------- + value: Complex128 + Fill value. + + start: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex128Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 3 ) + + > arr.fill( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 1.0 ) ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 1.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 1.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex64}}.prototype.fill( value[, start[, end]] ) + Returns a modified typed array filled with a fill value. + + Parameters + ---------- + value: Complex64 + Fill value. + + start: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex64Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 3 ) + + > arr.fill( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, 1.0 ) ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 1.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + 1.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex128}}.prototype.filter( predicate[, thisArg] ) + Returns a new array containing the elements of an array which pass a test + implemented by a predicate function. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + predicate: Function + Predicate function which filters array elements. If a predicate function + returns a truthy value, an array element is included in the output + array; otherwise, an array element is not included in the output array. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex128Array + A new typed array. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var out = arr.filter( predicate ) + + > var len = out.length + 1 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.filter( predicate[, thisArg] ) + Returns a new array containing the elements of an array which pass a test + implemented by a predicate function. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + predicate: Function + Predicate function which filters array elements. If a predicate function + returns a truthy value, an array element is included in the output + array; otherwise, an array element is not included in the output array. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex64Array + A new typed array. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var out = arr.filter( predicate ) + + > var len = out.length + 1 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.find( predicate[, thisArg] ) + Returns the first element in an array for which a predicate function + returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex128|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var z = arr.find( predicate ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex64}}.prototype.find( predicate[, thisArg] ) + Returns the first element in an array for which a predicate function + returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex64|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var z = arr.find( predicate ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex128}}.prototype.findIndex( predicate[, thisArg] ) + Returns the index of the first element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var idx = arr.findIndex( predicate ) + 0 + + +{{alias:@stdlib/array/complex64}}.prototype.findIndex( predicate[, thisArg] ) + Returns the index of the first element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var idx = arr.findIndex( predicate ) + 0 + + +{{alias:@stdlib/array/complex128}}.prototype.findLast( predicate[, thisArg] ) + Returns the last element in an array for which a predicate function returns + a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex128|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var z = arr.findLast( predicate ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.findLast( predicate[, thisArg] ) + Returns the last element in an array for which a predicate function returns + a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex64|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var z = arr.findLast( predicate ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.findLastIndex( predicate[, thisArg] ) + Returns the index of the last element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var idx = arr.findLastIndex( predicate ) + 1 + + +{{alias:@stdlib/array/complex64}}.prototype.findLastIndex( predicate[, thisArg] ) + Returns the index of the last element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var idx = arr.findLastIndex( predicate ) + 1 + + +{{alias:@stdlib/array/complex128}}.prototype.forEach( clbk[, thisArg] ) + Invokes a function once for each array element. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + clbk: Function + Function to invoke for each array element. + + thisArg: Any (optional) + Execution context. + + Examples + -------- + > var str = '%'; + > function clbk( v ) { str += v.toString() + '%'; }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > arr.forEach( clbk ); + > str + '%1 - 1i%2 - 2i%' + + +{{alias:@stdlib/array/complex64}}.prototype.forEach( clbk[, thisArg] ) + Invokes a function once for each array element. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + clbk: Function + Function to invoke for each array element. + + thisArg: Any (optional) + Execution context. + + Examples + -------- + > var str = '%'; + > function clbk( v ) { str += v.toString() + '%'; }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > arr.forEach( clbk ); + > str + '%1 - 1i%2 - 2i%' + + +{{alias:@stdlib/array/complex128}}.prototype.get( i ) + Returns an array element located at integer position (index) `i`. + + If provided an index outside the array index range, the method returns + `undefined`. + + Parameters + ---------- + i: integer + Element index. + + Returns + ------- + out: Complex128|void + Array element or `undefined`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.get( 1 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.get( i ) + Returns an array element located at integer position (index) `i`. + + If provided an index outside the array index range, the method returns + `undefined`. + + Parameters + ---------- + i: integer + Element index. + + Returns + ------- + out: Complex64|void + Array element or `undefined`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.get( 1 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.includes( searchElement[, fromIndex] ) + Returns a boolean indicating whether an array includes a provided value. + + Parameters + ---------- + searchElement: Complex128 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + bool: boolean + Boolean indicating whether an array includes a search element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + true + > bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) + false + + +{{alias:@stdlib/array/complex64}}.prototype.includes( searchElement[, fromIndex] ) + Returns a boolean indicating whether an array includes a provided value. + + Parameters + ---------- + searchElement: Complex64 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + bool: boolean + Boolean indicating whether an array includes a search element. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + true + > bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) + false + + +{{alias:@stdlib/array/complex128}}.prototype.indexOf( searchElement[, fromIndex] ) + Returns the first index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Complex128 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + 2 + > idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) + -1 + + +{{alias:@stdlib/array/complex64}}.prototype.indexOf( searchElement[, fromIndex] ) + Returns the first index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Complex64 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + 2 + > idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) + -1 + + +{{alias:@stdlib/array/complex128}}.prototype.join( [separator] ) + Returns a new string by concatenating all array elements separated by a + separator string. + + Parameters + ---------- + separator: string (optional) + Separator string. Default: ','. + + Returns + ------- + out: string + Array serialized as a string. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var str = arr.join() + '1 - 1i,2 - 2i' + > str = arr.join( '/' ) + '1 - 1i/2 - 2i' + + +{{alias:@stdlib/array/complex64}}.prototype.join( [separator] ) + Returns a new string by concatenating all array elements separated by a + separator string. + + Parameters + ---------- + separator: string (optional) + Separator string. Default: ','. + + Returns + ------- + out: string + Array serialized as a string. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var str = arr.join() + '1 - 1i,2 - 2i' + > str = arr.join( '/' ) + '1 - 1i/2 - 2i' + + +{{alias:@stdlib/array/complex128}}.prototype.keys() + Returns an iterator for iterating over each index key in a typed array. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array index keys. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var it = arr.keys(); + > var v = it.next().value + 0 + > v = it.next().value + 1 + > v = it.next().done + true + + +{{alias:@stdlib/array/complex64}}.prototype.keys() + Returns an iterator for iterating over each index key in a typed array. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array index keys. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var it = arr.keys(); + > var v = it.next().value + 0 + > v = it.next().value + 1 + > v = it.next().done + true + + +{{alias:@stdlib/array/complex128}}.prototype.lastIndexOf( searchElement[, fromIndex] ) + Returns the last index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Complex128 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: out.length-1. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ) ) + 3 + > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), 2 ) + 0 + + +{{alias:@stdlib/array/complex64}}.prototype.lastIndexOf( searchElement[, fromIndex] ) + Returns the last index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Complex64 + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: out.length-1. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ) ) + 3 + > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), 2 ) + 0 + + +{{alias:@stdlib/array/complex128}}.prototype.map( clbk[, thisArg] ) + Returns a new array with each element being the result of a provided + callback function. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + clbk: Function + Function which maps array elements to elements in the new array. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex128Array + A new typed array. + + Examples + -------- + > function clbk( v ) { return v; }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var out = arr.map( clbk ) + + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.map( clbk[, thisArg] ) + Returns a new array with each element being the result of a provided + callback function. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + clbk: Function + Function which maps array elements to elements in the new array. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + out: Complex64Array + A new typed array. + + Examples + -------- + > function clbk( v ) { return v; }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var out = arr.map( clbk ) + + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.reduce( reducerFn[, initialValue] ) + Applies a provided function to each element of the array, in order, passing + in the return value from the calculation on the preceding element and + returning the accumulated result upon completion. + + A reducer function is provided the following arguments: + + - acc: accumulated result. + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If provided an initial value, the method invokes a provided function with + the initial value as the first argument and the first array element as the + second argument. + + If not provided an initial value, the method invokes a provided function + with the first array element as the first argument and the second array + element as the second argument. + + Parameters + ---------- + reducerFn: Function + Function to apply to each array element. + + initialValue: any (optional) + Initial accumulation value. + + Returns + ------- + out: any + Accumulated result. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.reduce( {{alias:@stdlib/complex/float64/base/add}} ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.reduce( reducerFn[, initialValue] ) + Applies a provided function to each element of the array, in order, passing + in the return value from the calculation on the preceding element and + returning the accumulated result upon completion. + + A reducer function is provided the following arguments: + + - acc: accumulated result. + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If provided an initial value, the method invokes a provided function with + the initial value as the first argument and the first array element as the + second argument. + + If not provided an initial value, the method invokes a provided function + with the first array element as the first argument and the second array + element as the second argument. + + Parameters + ---------- + reducerFn: Function + Function to apply to each array element. + + initialValue: any (optional) + Initial accumulation value. + + Returns + ------- + out: any + Accumulated result. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.reduce( {{alias:@stdlib/complex/float32/base/add}} ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.reduceRight( reducerFn[, initialValue] ) + Applies a provided function to each element of the array, in reverse order, + passing in the return value from the calculation on the preceding element + and returning the accumulated result upon completion. + + A reducer function is provided the following arguments: + + - acc: accumulated result. + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If provided an initial value, the method invokes a provided function with + the initial value as the first argument and the last array element as the + second argument. + + If not provided an initial value, the method invokes a provided function + with the last array element as the first argument and the second-to-last + array element as the second argument. + + Parameters + ---------- + reducerFn: Function + Function to apply to each array element. + + initialValue: any (optional) + Initial accumulation value. + + Returns + ------- + out: any + Accumulated result. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.reduceRight( {{alias:@stdlib/complex/float64/base/add}} ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.reduceRight( reducerFn[, initialValue] ) + Applies a provided function to each element of the array, in reverse order, + passing in the return value from the calculation on the preceding element + and returning the accumulated result upon completion. + + A reducer function is provided the following arguments: + + - acc: accumulated result. + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If provided an initial value, the method invokes a provided function with + the initial value as the first argument and the last array element as the + second argument. + + If not provided an initial value, the method invokes a provided function + with the last array element as the first argument and the second-to-last + array element as the second argument. + + Parameters + ---------- + reducerFn: Function + Function to apply to each array element. + + initialValue: any (optional) + Initial accumulation value. + + Returns + ------- + out: any + Accumulated result. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var z = arr.reduceRight( {{alias:@stdlib/complex/float32/base/add}} ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.reverse() + Reverses the array *in-place*. + + This method mutates the array on which the method is invoked. + + Returns + ------- + out: Complex128Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > arr.reverse(); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + + +{{alias:@stdlib/array/complex64}}.prototype.reverse() + Reverses the array *in-place*. + + This method mutates the array on which the method is invoked. + + Returns + ------- + out: Complex64Array + Modified array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > arr.reverse(); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + + +{{alias:@stdlib/array/complex128}}.prototype.set( z[, i] ) + Sets one or more array elements. + + If provided a single argument, the method sets array elements starting at + position (index) `i = 0`. To set elements starting elsewhere in the array, + provide an index argument `i`. + + To set one or more array elements, provide an array-like object containing + either complex numbers or interleaved real and imaginary components. + + Parameters + ---------- + z: Complex128|Complex128Array|ArrayLikeObject + Complex number or complex number array. + + i: integer (optional) + Array index at which to start setting elements. Default: 0. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( 2 ) + + > arr.set( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ) ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + > arr.set( new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ), 1 ); + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex64}}.prototype.set( z[, i] ) + Sets one or more array elements. + + If provided a single argument, the method sets array elements starting at + position (index) `i = 0`. To set elements starting elsewhere in the array, + provide an index argument `i`. + + To set one or more array elements, provide an array-like object containing + either complex numbers or interleaved real and imaginary components. + + Parameters + ---------- + z: Complex64|Complex64Array|ArrayLikeObject + Complex number or complex number array. + + i: integer (optional) + Array index at which to start setting elements. Default: 0. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( 2 ) + + > arr.set( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ) ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + > arr.set( new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ), 1 ); + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + + +{{alias:@stdlib/array/complex128}}.prototype.slice( [start[, end]] ) + Copies a portion of a typed array to a new typed array. + + Parameters + ---------- + start: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex128Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > var out = arr.slice( 1 ) + + > var len = out.length + 2 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.slice( [start[, end]] ) + Copies a portion of a typed array to a new typed array. + + Parameters + ---------- + start: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex64Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + + > var out = arr.slice( 1 ) + + > var len = out.length + 2 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.some( predicate[, thisArg] ) + Returns a boolean indicating whether at least one element passes a test. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. If a predicate function + returns a truthy value, an array element passes; otherwise, an array + element fails. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + bool: boolean + Boolean indicating whether at least one element passes the test. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var bool = arr.some( predicate ) + true + + +{{alias:@stdlib/array/complex64}}.prototype.some( predicate[, thisArg] ) + Returns a boolean indicating whether at least one element passes a test. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. If a predicate function + returns a truthy value, an array element passes; otherwise, an array + element fails. + + thisArg: Any (optional) + Execution context. + + Returns + ------- + bool: boolean + Boolean indicating whether at least one element passes the test. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + + > var bool = arr.some( predicate ) + true + + +{{alias:@stdlib/array/complex128}}.prototype.sort( compareFunction ) + Sorts an array in-place. + + A comparison function determines the order of the array elements. The + function is provided two arguments: + + - a: first element for comparison. + - b: second element for comparison. + + The function should return a value less than zero if `a` comes before `b`, + a value greater than zero if `a` comes after `b`, and zero if `a` and `b` + are equivalent. + + Parameters + ---------- + compareFunction: Function + Comparison function. + + Returns + ------- + out: Complex128Array + Modified array. + + Examples + -------- + > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > arr.sort( compare ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.sort( compareFunction ) + Sorts an array in-place. + + A comparison function determines the order of the array elements. The + function is provided two arguments: + + - a: first element for comparison. + - b: second element for comparison. + + The function should return a value less than zero if `a` comes before `b`, + a value greater than zero if `a` comes after `b`, and zero if `a` and `b` + are equivalent. + + Parameters + ---------- + compareFunction: Function + Comparison function. + + Returns + ------- + out: Complex64Array + Modified array. + + Examples + -------- + > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > arr.sort( compare ); + > var z = arr.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + > z = arr.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + > z = arr.get( 2 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.subarray( [begin[, end]] ) + Creates a new typed array view over the same underlying `ArrayBuffer` and + with the same underlying data type as the host array. + + Parameters + ---------- + begin: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex128Array + New typed array view. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var out = arr.subarray( 1, 3 ) + + > var len = out.length + 2 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.subarray( [begin[, end]] ) + Creates a new typed array view over the same underlying `ArrayBuffer` and + with the same underlying data type as the host array. + + Parameters + ---------- + begin: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Complex64Array + New typed array view. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + + > var out = arr.subarray( 1, 3 ) + + > var len = out.length + 2 + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.toLocaleString( [locales[, options]] ) + Serializes an array as a locale-specific string. + + Parameters + ---------- + locales: string|Array (optional) + Locale identifier(s). + + options: Object (optional) + An object containing serialization options. + + Returns + ------- + str: string + Local-specific string. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0 ] ) + + > var str = arr.toLocaleString() + '1 + 1i,2 + 2i' + + +{{alias:@stdlib/array/complex64}}.prototype.toLocaleString( [locales[, options]] ) + Serializes an array as a locale-specific string. + + Parameters + ---------- + locales: string|Array (optional) + Locale identifier(s). + + options: Object (optional) + An object containing serialization options. + + Returns + ------- + str: string + Local-specific string. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0 ] ) + + > var str = arr.toLocaleString() + '1 + 1i,2 + 2i' + + +{{alias:@stdlib/array/complex128}}.prototype.toReversed() + Returns a new typed array containing the elements in reversed order. + + Returns + ------- + out: Complex128Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) + + > var out = arr.toReversed() + + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + 3.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 2.0 + > z = out.get( 2 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex64}}.prototype.toReversed() + Returns a new typed array containing the elements in reversed order. + + Returns + ------- + out: Complex64Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) + + > var out = arr.toReversed() + + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 3.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + 2.0 + > z = out.get( 2 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + 1.0 + + +{{alias:@stdlib/array/complex128}}.prototype.toSorted( compareFcn ) + Returns a new typed array containing the elements in sorted order. + + A comparison function determines the order of the array elements. The + function is provided two arguments: + + - a: first element for comparison. + - b: second element for comparison. + + The function should return a value less than zero if `a` comes before `b`, + a value greater than zero if `a` comes after `b`, and zero if `a` and `b` + are equivalent. + + Parameters + ---------- + compareFcn: Function + Comparison function. + + Returns + ------- + out: Complex128Array + New typed array. + + Examples + -------- + > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; + > var arr = new {{alias:@stdlib/array/complex128}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > var out = arr.toSorted( compare ); + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -1.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + > z = out.get( 2 ) + + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.toSorted( compareFcn ) + Returns a new typed array containing the elements in sorted order. + + A comparison function determines the order of the array elements. The + function is provided two arguments: + + - a: first element for comparison. + - b: second element for comparison. + + The function should return a value less than zero if `a` comes before `b`, + a value greater than zero if `a` comes after `b`, and zero if `a` and `b` + are equivalent. + + Parameters + ---------- + compareFcn: Function + Comparison function. + + Returns + ------- + out: Complex64Array + New typed array. + + Examples + -------- + > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; + > var arr = new {{alias:@stdlib/array/complex64}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + + > var out = arr.toSorted( compare ); + > var z = out.get( 0 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -1.0 + > z = out.get( 1 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -2.0 + > z = out.get( 2 ) + + > re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex128}}.prototype.toString() + Serializes an array as a string. + + Returns + ------- + str: string + String serialization of the array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) + + > var str = arr.toString() + '1 + 1i,2 - 2i,3 + 3i' + + +{{alias:@stdlib/array/complex64}}.prototype.toString() + Serializes an array as a string. + + Returns + ------- + str: string + String serialization of the array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) + + > var str = arr.toString() + '1 + 1i,2 - 2i,3 + 3i' + + +{{alias:@stdlib/array/complex128}}.prototype.values() + Returns an iterator for iterating over each value in a typed array. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array values. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var it = arr.values(); + > var v = it.next().value + + > var re = {{alias:@stdlib/complex/float64/real}}( v ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( v ) + -1.0 + > v = it.next().value + + > re = {{alias:@stdlib/complex/float64/real}}( v ) + 2.0 + > im = {{alias:@stdlib/complex/float64/imag}}( v ) + -2.0 + > var bool = it.next().done + true + + +{{alias:@stdlib/array/complex64}}.prototype.values() + Returns an iterator for iterating over each value in a typed array. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array values. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var it = arr.values(); + > var v = it.next().value + + > var re = {{alias:@stdlib/complex/float32/real}}( v ) + 1.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( v ) + -1.0 + > v = it.next().value + + > re = {{alias:@stdlib/complex/float32/real}}( v ) + 2.0 + > im = {{alias:@stdlib/complex/float32/imag}}( v ) + -2.0 + > var bool = it.next().done + true + + +{{alias:@stdlib/array/complex128}}.prototype.with( index, value ) + Returns a new typed array with the element at a provided index replaced + with a provided value. + + Parameters + ---------- + index: integer + Element index. + + value: Complex128 + Element value. + + Returns + ------- + out: Complex128Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var out = arr.with( 1, new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + + > var z = out.get( 1 ) + + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -3.0 + + +{{alias:@stdlib/array/complex64}}.prototype.with( index, value ) + Returns a new typed array with the element at a provided index replaced + with a provided value. + + Parameters + ---------- + index: integer + Element index. + + value: Complex64 + Element value. + + Returns + ------- + out: Complex64Array + New typed array. + + Examples + -------- + > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + + > var out = arr.with( 1, new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + + > var z = out.get( 1 ) + + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + 3.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + -3.0 + diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts new file mode 100644 index 000000000000..03ca253060ea --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts @@ -0,0 +1,3330 @@ +/* eslint-disable max-lines */ + +/* +* @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 + +/// + +import { TypedIterator } from '@stdlib/types/iter'; +import { ArrayLike, RealOrComplexTypedArray } from '@stdlib/types/array'; +import { ComplexLike } from '@stdlib/types/complex'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Returns the real component of a complex number. +* +* @param z - complex number +* @returns real component +*/ +type GetReal = ( z: ComplexLike ) => number; + +/** +* Returns the imaginary component of a complex number. +* +* @param z - complex number +* @returns imaginary component +*/ +type GetImag = ( z: ComplexLike ) => number; + +/** +* Reinterprets a complex typed array as a float typed array. +* +* @param x - complex typed array +* @param offset - index offset +* @returns float typed array view +*/ +type Reinterpret = ( x: any, offset: number ) => any; + +/** +* Callback invoked for each element in a source object. +* +* @returns transformed value +*/ +type FromNullary = ( this: U ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in a source object. +* +* @param value - source element +* @returns transformed value +*/ +type FromUnary = ( this: U, value: ComplexLike | ArrayLike | number ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in a source object. +* +* @param value - source element +* @param index - source element index +* @returns transformed value +*/ +type FromBinary = ( this: U, value: ComplexLike | ArrayLike | number, index: number ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in a source object. +* +* @param value - source element +* @param index - source element index +* @returns transformed value +*/ +type FromCallback = FromNullary | FromUnary | FromBinary; + +/** +* Checks whether an element in an array passes a test. +* +* @returns boolean indicating whether an element in an array passes a test +*/ +type NullaryPredicate = ( this: U ) => boolean; + +/** +* Checks whether an element in an array passes a test. +* +* @param value - current array element +* @returns boolean indicating whether an element in an array passes a test +*/ +type UnaryPredicate = ( this: U, value: T ) => boolean; + +/** +* Checks whether an element in an array passes a test. +* +* @param value - current array element +* @param index - current array element index +* @returns boolean indicating whether an element in an array passes a test +*/ +type BinaryPredicate = ( this: U, value: T, index: number ) => boolean; + +/** +* Checks whether an element in an array passes a test. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns boolean indicating whether an element in an array passes a test +*/ +type TernaryPredicate = ( this: U, value: T, index: number, arr: ComplexTypedArray ) => boolean; + +/** +* Checks whether an element in an array passes a test. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns boolean indicating whether an element in an array passes a test +*/ +type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; + +/** +* Callback invoked for each element in an array. +* +* @returns undefined +*/ +type NullaryCallback = ( this: U ) => void; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @returns undefined +*/ +type UnaryCallback = ( this: U, value: T ) => void; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @returns undefined +*/ +type BinaryCallback = ( this: U, value: T, index: number ) => void; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns undefined +*/ +type TernaryCallback = ( this: U, value: T, index: number, arr: ComplexTypedArray ) => void; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns undefined +*/ +type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; + +/** +* Callback invoked for each element in an array. +* +* @returns transformed value +*/ +type NullaryMapFcn = ( this: U ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @returns transformed value +*/ +type UnaryMapFcn = ( this: U, value: T ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @returns transformed value +*/ +type BinaryMapFcn = ( this: U, value: T, index: number ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns transformed value +*/ +type TernaryMapFcn = ( this: U, value: T, index: number, arr: ComplexTypedArray ) => ComplexLike | ArrayLike; + +/** +* Callback invoked for each element in an array. +* +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns transformed value +*/ +type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; + +/** +* Reducer function invoked for each element in an array. +* +* @returns accumulated result +*/ +type NullaryReducer = () => U; + +/** +* Reducer function invoked for each element in an array. +* +* @param acc - accumulated result +* @returns accumulated result +*/ +type UnaryReducer = ( acc: U ) => U; + +/** +* Reducer function invoked for each element in an array. +* +* @param acc - accumulated result +* @param value - current array element +* @returns accumulated result +*/ +type BinaryReducer = ( acc: U, value: T ) => U; + +/** +* Reducer function invoked for each element in an array. +* +* @param acc - accumulated result +* @param value - current array element +* @param index - current array element index +* @returns accumulated result +*/ +type TernaryReducer = ( acc: U, value: T, index: number ) => U; + +/** +* Reducer function invoked for each element in an array. +* +* @param acc - accumulated result +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns accumulated result +*/ +type QuaternaryReducer = ( acc: U, value: T, index: number, arr: ComplexTypedArray ) => U; + +/** +* Reducer function invoked for each element in an array. +* +* @param acc - accumulated result +* @param value - current array element +* @param index - current array element index +* @param arr - array on which the method was called +* @returns accumulated result +*/ +type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; + +/** +* Comparator function. +* +* @param a - first value for comparison +* @param b - second value for comparison +* @returns number indicating comparison result +*/ +type CompareFcn = ( a: T, b: T ) => number; + +/** +* Locale-specific configuration options. +*/ +interface LocaleOptions { + /** + * Configuration property. + */ + [ key: string | symbol | number ]: T | undefined; +} + +/** +* Interface describing a complex number typed array instance. +*/ +interface ComplexTypedArray { + /** + * Pointer to the underlying data buffer. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var buf = arr.buffer; + * // returns + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var buf = arr.buffer; + * // returns + */ + readonly buffer: ArrayBuffer; + + /** + * Length (in bytes) of the array. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var byteLength = arr.byteLength; + * // returns 80 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var byteLength = arr.byteLength; + * // returns 160 + */ + readonly byteLength: number; + + /** + * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var byteOffset = arr.byteOffset; + * // returns 0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var byteOffset = arr.byteOffset; + * // returns 0 + */ + readonly byteOffset: number; + + /** + * Size (in bytes) of each array element. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var nbytes = arr.BYTES_PER_ELEMENT; + * // returns 8 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var nbytes = arr.BYTES_PER_ELEMENT; + * // returns 16 + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Number of array elements. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var len = arr.length; + * // returns 10 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var len = arr.length; + * // returns 10 + */ + readonly length: number; + + /** + * Returns an array element with support for both nonnegative and negative integer indices. + * + * @param i - element index + * @throws index argument must be an integer + * @returns array element + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var z = arr.at( 0 ); + * // returns + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 9.0, -9.0 ], 9 ); + * + * z = arr.at( -1 ); + * // returns + * + * z = arr.at( 100 ); + * // returns undefined + * + * z = arr.at( -100 ); + * // returns undefined + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var z = arr.at( 0 ); + * // returns + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 9.0, -9.0 ], 9 ); + * + * z = arr.at( -1 ); + * // returns + * + * z = arr.at( 100 ); + * // returns undefined + * + * z = arr.at( -100 ); + * // returns undefined + */ + at( i: number ): T | void; + + /** + * Copies a sequence of elements within the array to the position starting at `target`. + * + * @param target - index at which to start copying elements + * @param start - source index at which to copy elements from + * @param end - source index at which to stop copying elements from (exclusive) + * @returns modified array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 4 ); + * + * // Set the array elements: + * arr.set( new Complex64( 1.0, 1.0 ), 0 ); + * arr.set( new Complex64( 2.0, 2.0 ), 1 ); + * arr.set( new Complex64( 3.0, 3.0 ), 2 ); + * arr.set( new Complex64( 4.0, 4.0 ), 3 ); + * + * // Copy the first two elements to the last two elements: + * arr.copyWithin( 2, 0, 2 ); + * + * // Get the last array element: + * var z = arr.get( 3 ); + * + * var re = realf( z ); + * // returns 2.0 + * + * var im = imagf( z ); + * // returns 2.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 4 ); + * + * // Set the array elements: + * arr.set( new Complex128( 1.0, 1.0 ), 0 ); + * arr.set( new Complex128( 2.0, 2.0 ), 1 ); + * arr.set( new Complex128( 3.0, 3.0 ), 2 ); + * arr.set( new Complex128( 4.0, 4.0 ), 3 ); + * + * // Copy the first two elements to the last two elements: + * arr.copyWithin( 2, 0, 2 ); + * + * // Get the last array element: + * var z = arr.get( 3 ); + * + * var re = real( z ); + * // returns 2.0 + * + * var im = imag( z ); + * // returns 2.0 + */ + copyWithin( target: number, start: number, end?: number ): ComplexTypedArray; + + /** + * Returns an iterator for iterating over array key-value pairs. + * + * @returns iterator + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = [ + * new Complex64( 1.0, 1.0 ), + * new Complex64( 2.0, 2.0 ), + * new Complex64( 3.0, 3.0 ) + * ]; + * arr = new Complex64Array( arr ); + * + * // Create an iterator: + * var it = arr.entries(); + * + * // Iterate over the key-value pairs... + * var v = it.next().value; + * // returns [ 0, ] + * + * v = it.next().value; + * // returns [ 1, ] + * + * v = it.next().value; + * // returns [ 2, ] + * + * var bool = it.next().done; + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = [ + * new Complex128( 1.0, 1.0 ), + * new Complex128( 2.0, 2.0 ), + * new Complex128( 3.0, 3.0 ) + * ]; + * arr = new Complex128Array( arr ); + * + * // Create an iterator: + * var it = arr.entries(); + * + * // Iterate over the key-value pairs... + * var v = it.next().value; + * // returns [ 0, ] + * + * v = it.next().value; + * // returns [ 1, ] + * + * v = it.next().value; + * // returns [ 2, ] + * + * var bool = it.next().done; + * // returns true + */ + entries(): TypedIterator<[number, T]>; + + /** + * Tests whether all elements in an array pass a test implemented by a predicate function. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns boolean indicating whether all elements pass a test + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var bool = arr.every( predicate ); + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var bool = arr.every( predicate ); + * // returns true + */ + every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + + /** + * Returns a modified typed array filled with a fill value. + * + * @param value - fill value + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @returns modified typed array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.fill( new Complex64( 1.0, 1.0 ), 1 ); + * + * var z = arr.get( 1 ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns 1.0 + * + * z = arr.get( 2 ); + * // returns + * + * re = realf( z ); + * // returns 1.0 + * + * im = imagf( z ); + * // returns 1.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.fill( new Complex128( 1.0, 1.0 ), 1 ); + * + * var z = arr.get( 1 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns 1.0 + * + * z = arr.get( 2 ); + * // returns + * + * re = real( z ); + * // returns 1.0 + * + * im = imag( z ); + * // returns 1.0 + */ + fill( value: ComplexLike, start?: number, end?: number ): ComplexTypedArray; + + /** + * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns new array containing elements which pass a test + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var out = arr.filter( predicate ); + * // returns + * + * var len = out.length; + * // returns 1 + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 2.0 + * + * var im = imagf( z ); + * // returns 2.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var out = arr.filter( predicate ); + * // returns + * + * var len = out.length; + * // returns 1 + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 2.0 + * + * var im = imag( z ); + * // returns 2.0 + */ + filter( predicate: Predicate, thisArg?: ThisParameterType> ): ComplexTypedArray; + + /** + * Returns the first element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns array element or undefined + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.find( predicate ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns 1.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.find( predicate ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns 1.0 + */ + find( predicate: Predicate, thisArg?: ThisParameterType> ): T | void; + + /** + * Returns the index of the first element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns index or -1 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var idx = arr.findIndex( predicate ); + * // returns 2 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var idx = arr.findIndex( predicate ); + * // returns 2 + */ + findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + + /** + * Returns the last element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns array element or undefined + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.findLast( predicate ); + * // returns + * + * var re = realf( z ); + * // returns 3.0 + * + * var im = imagf( z ); + * // returns 3.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.findLast( predicate ); + * // returns + * + * var re = real( z ); + * // returns 3.0 + * + * var im = imag( z ); + * // returns 3.0 + */ + findLast( predicate: Predicate, thisArg?: ThisParameterType> ): T | void; + + /** + * Returns the index of the last element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns index or -1 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var idx = arr.findLastIndex( predicate ); + * // returns 1 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var idx = arr.findLastIndex( predicate ); + * // returns 1 + */ + findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + + /** + * Invokes a function once for each array element. + * + * @param fcn - function to invoke + * @param thisArg - execution context + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function log( v, i ) { + * console.log( '%s: %s', i, v.toString() ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * arr.forEach( log ); + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function log( v, i ) { + * console.log( '%s: %s', i, v.toString() ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * arr.forEach( log ); + */ + forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; + + /** + * Returns an array element. + * + * @param i - element index + * @throws index argument must be a nonnegative integer + * @returns array element + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var z = arr.get( 0 ); + * // returns + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * + * z = arr.get( 100 ); + * // returns undefined + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var z = arr.get( 0 ); + * // returns + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * + * z = arr.get( 100 ); + * // returns undefined + */ + get( i: number ): T | void; + + /** + * Returns a boolean indicating whether an array contains a provided value. + * + * @param searchElement - search element + * @param fromIndex - starting index (inclusive) + * @returns boolean indicating whether an array contains a provided value + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var bool = arr.includes( new Complex64( 3.0, -3.0 ) ); + * // returns true + * + * bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); + * // returns false + * + * bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var bool = arr.includes( new Complex128( 3.0, -3.0 ) ); + * // returns true + * + * bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 ); + * // returns false + * + * bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); + * // returns true + */ + includes( searchElement: ComplexLike, fromIndex?: number ): boolean; + + /** + * Returns the first index at which a given element can be found. + * + * @param searchElement - element to find + * @param fromIndex - starting index (inclusive) + * @returns index or -1 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 5 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * arr.set( [ 2.0, 2.0 ], 3 ); + * arr.set( [ 5.0, 5.0 ], 4 ); + * + * var idx = arr.indexOf( new Complex64( 2.0, 2.0 ) ); + * // returns 1 + * + * idx = arr.indexOf( new Complex64( 2.0, 2.0 ), 2 ); + * // returns 3 + * + * idx = arr.indexOf( new Complex64( 2.0, 2.0 ), -3 ); + * // returns 3 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 5 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * arr.set( [ 2.0, 2.0 ], 3 ); + * arr.set( [ 5.0, 5.0 ], 4 ); + * + * var idx = arr.indexOf( new Complex128( 2.0, 2.0 ) ); + * // returns 1 + * + * idx = arr.indexOf( new Complex128( 2.0, 2.0 ), 2 ); + * // returns 3 + * + * idx = arr.indexOf( new Complex128( 2.0, 2.0 ), -3 ); + * // returns 3 + */ + indexOf( searchElement: ComplexLike, fromIndex?: number ): number; + + /** + * Returns a new string by concatenating all array elements. + * + * @param separator - value separator (default: ',') + * @returns string + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.join(); + * // returns '1 + 1i,2 + 2i' + * + * str = arr.join( '/' ); + * // returns '1 + 1i/2 + 2i' + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.join(); + * // returns '1 + 1i,2 + 2i' + * + * str = arr.join( '/' ); + * // returns '1 + 1i/2 + 2i' + */ + join( separator?: string ): string; + + /** + * Returns an iterator for iterating over each index key in a typed array. + * + * @returns iterator + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var it = arr.keys(); + * + * var v = it.next().value; + * // returns 0 + * + * v = it.next().value; + * // returns 1 + * + * var bool = it.next().done; + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var it = arr.keys(); + * + * var v = it.next().value; + * // returns 0 + * + * v = it.next().value; + * // returns 1 + * + * var bool = it.next().done; + * // returns true + */ + keys(): TypedIterator; + + /** + * Returns the last index at which a given element can be found. + * + * @param searchElement - element to find + * @param fromIndex - index at which to start searching backward (inclusive) + * @returns index or -1 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 3.0, -3.0 ], 4 ); + * + * var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); + * // returns 4 + * + * idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 ); + * // returns 2 + * + * idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 ); + * // returns 1 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 3.0, -3.0 ], 4 ); + * + * var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); + * // returns 4 + * + * idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 ); + * // returns 2 + * + * idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 ); + * // returns 1 + */ + lastIndexOf( searchElement: ComplexLike, fromIndex?: number ): number; + + /** + * Returns a new array with each element being the result of a provided callback function. + * + * @param fcn - callback function + * @param thisArg - execution context + * @returns new array containing transformed elements + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function scale( v ) { + * return new Complex64( 2.0 * realf( v ), 2.0 * imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var out = arr.map( scale ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 2.0 + * + * var im = imagf( z ); + * // returns -2.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function scale( v ) { + * return new Complex128( 2.0 * real( v ), 2.0 * imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var out = arr.map( scale ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 2.0 + * + * var im = imag( z ); + * // returns -2.0 + */ + map( fcn: MapFcn, thisArg?: ThisParameterType> ): ComplexTypedArray; + + /** + * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. + * + * @param reducer - callback function + * @param initialValue - initial value + * @returns accumulated result + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var caddf = require( '@stdlib/complex/float32/base/add' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.reduce( caddf ); + * // returns + * + * var re = realf( z ); + * // returns 6.0 + * + * var im = imagf( z ); + * // returns 6.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var cadd = require( '@stdlib/complex/float64/base/add' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.reduce( cadd ); + * // returns + * + * var re = real( z ); + * // returns 6.0 + * + * var im = imag( z ); + * // returns 6.0 + */ + reduce( reducer: Reducer, initialValue?: U ): U; + + /** + * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. + * + * @param reducer - callback function + * @param initialValue - initial value + * @returns accumulated result + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var caddf = require( '@stdlib/complex/float32/base/add' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.reduceRight( caddf ); + * // returns + * + * var re = realf( z ); + * // returns 6.0 + * + * var im = imagf( z ); + * // returns 6.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var cadd = require( '@stdlib/complex/float64/base/add' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var z = arr.reduceRight( cadd ); + * // returns + * + * var re = real( z ); + * // returns 6.0 + * + * var im = imag( z ); + * // returns 6.0 + */ + reduceRight( reducer: Reducer, initialValue?: U ): U; + + /** + * Reverses an array in-place. + * + * @returns reversed array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.reverse(); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 3.0 + * + * var im = imagf( z ); + * // returns 3.0 + * + * z = out.get( 1 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns 2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = realf( z ); + * // returns 1.0 + * + * im = imagf( z ); + * // returns 1.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.reverse(); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 3.0 + * + * var im = imag( z ); + * // returns 3.0 + * + * z = out.get( 1 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns 2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = real( z ); + * // returns 1.0 + * + * im = imag( z ); + * // returns 1.0 + */ + reverse(): ComplexTypedArray; + + /** + * Sets an array element. + * + * ## Notes + * + * - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: + * + * ```text + * buf: --------------------- + * src: --------------------- + * ``` + * + * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. + * + * In the other overlapping scenario, + * + * ```text + * buf: --------------------- + * src: --------------------- + * ``` + * + * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. + * + * @param value - value(s) to set + * @param i - element index at which to start writing values (default: 0) + * @throws index argument must be a nonnegative integer + * @throws array-like objects must have a length which is a multiple of two + * @throws index argument is out-of-bounds + * @throws target array lacks sufficient storage to accommodate source values + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 10 ); + * + * var z = arr.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 0.0 + * + * var im = imagf( z ); + * // returns 0.0 + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * + * z = arr.get( 0 ); + * // returns + * + * re = realf( z ); + * // returns 1.0 + * + * im = imagf( z ); + * // returns -1.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 10 ); + * + * var z = arr.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 0.0 + * + * var im = imag( z ); + * // returns 0.0 + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * + * z = arr.get( 0 ); + * // returns + * + * re = real( z ); + * // returns 1.0 + * + * im = imag( z ); + * // returns -1.0 + */ + set( value: ArrayLike | RealOrComplexTypedArray | ComplexLike, i?: number ): void; + + /** + * Copies a portion of a typed array to a new typed array. + * + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @throws indices must be integers + * @returns output array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var out = arr.slice(); + * // returns + * + * var len = out.length; + * // returns 5 + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns -1.0 + * + * z = out.get( len-1 ); + * // returns + * + * re = realf( z ); + * // returns 5.0 + * + * im = imagf( z ); + * // returns -5.0 + * + * out = arr.slice( 1, -2 ); + * // returns + * + * len = out.length; + * // returns 2 + * + * z = out.get( 0 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns -2.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var out = arr.slice(); + * // returns + * + * var len = out.length; + * // returns 5 + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -1.0 + * + * z = out.get( len-1 ); + * // returns + * + * re = real( z ); + * // returns 5.0 + * + * im = imag( z ); + * // returns -5.0 + * + * out = arr.slice( 1, -2 ); + * // returns + * + * len = out.length; + * // returns 2 + * + * z = out.get( 0 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns -2.0 + */ + slice( start?: number, end?: number ): ComplexTypedArray; + + /** + * Tests whether at least one element in an array passes a test implemented by a predicate function. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns boolean indicating whether at least one element passes a test + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function predicate( v ) { + * return ( realf( v ) === imagf( v ) ); + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var bool = arr.some( predicate ); + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function predicate( v ) { + * return ( real( v ) === imag( v ) ); + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * + * var bool = arr.some( predicate ); + * // returns true + */ + some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + + /** + * Sorts an array in-place. + * + * @param compareFcn - comparison function + * @returns sorted array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function compare( a, b ) { + * var re1 = realf( a ); + * var re2 = realf( b ); + * if ( re1 < re2 ) { + * return -1; + * } + * if ( re1 > re2 ) { + * return 1; + * } + * var im1 = imagf( a ); + * var im2 = imagf( b ); + * if ( im1 < im2 ) { + * return -1; + * } + * if ( im1 > im2 ) { + * return 1; + * } + * return 0; + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 3.0, -3.0 ], 0 ); + * arr.set( [ 1.0, -1.0 ], 1 ); + * arr.set( [ 2.0, -2.0 ], 2 ); + * + * var out = arr.sort( compare ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns -1.0 + * + * z = out.get( 1 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns -2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = realf( z ); + * // returns 3.0 + * + * im = imagf( z ); + * // returns -3.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function compare( a, b ) { + * var re1 = real( a ); + * var re2 = real( b ); + * if ( re1 < re2 ) { + * return -1; + * } + * if ( re1 > re2 ) { + * return 1; + * } + * var im1 = imag( a ); + * var im2 = imag( b ); + * if ( im1 < im2 ) { + * return -1; + * } + * if ( im1 > im2 ) { + * return 1; + * } + * return 0; + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 3.0, -3.0 ], 0 ); + * arr.set( [ 1.0, -1.0 ], 1 ); + * arr.set( [ 2.0, -2.0 ], 2 ); + * + * var out = arr.sort( compare ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -1.0 + * + * z = out.get( 1 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns -2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = real( z ); + * // returns 3.0 + * + * im = imag( z ); + * // returns -3.0 + */ + sort( compareFcn: CompareFcn ): ComplexTypedArray; + + /** + * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. + * + * @param begin - starting index (inclusive) + * @param end - ending index (exclusive) + * @throws indices must be integers + * @returns subarray + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var subarr = arr.subarray(); + * // returns + * + * var len = subarr.length; + * // returns 5 + * + * var z = subarr.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns -1.0 + * + * z = subarr.get( len-1 ); + * // returns + * + * re = realf( z ); + * // returns 5.0 + * + * im = imagf( z ); + * // returns -5.0 + * + * subarr = arr.subarray( 1, -2 ); + * // returns + * + * len = subarr.length; + * // returns 2 + * + * z = subarr.get( 0 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns -2.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 5 ); + * + * arr.set( [ 1.0, -1.0 ], 0 ); + * arr.set( [ 2.0, -2.0 ], 1 ); + * arr.set( [ 3.0, -3.0 ], 2 ); + * arr.set( [ 4.0, -4.0 ], 3 ); + * arr.set( [ 5.0, -5.0 ], 4 ); + * + * var subarr = arr.subarray(); + * // returns + * + * var len = subarr.length; + * // returns 5 + * + * var z = subarr.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -1.0 + * + * z = subarr.get( len-1 ); + * // returns + * + * re = real( z ); + * // returns 5.0 + * + * im = imag( z ); + * // returns -5.0 + * + * subarr = arr.subarray( 1, -2 ); + * // returns + * + * len = subarr.length; + * // returns 2 + * + * z = subarr.get( 0 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns -2.0 + */ + subarray( begin?: number, end?: number ): ComplexTypedArray; + + /** + * Serializes an array as a locale-specific string. + * + * @param locales - locale identifier(s) + * @param options - configuration options + * @returns string + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.toLocaleString(); + * // returns '1 + 1i,2 + 2i' + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.toLocaleString(); + * // returns '1 + 1i,2 + 2i' + */ + toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; + + /** + * Returns a new typed array containing the elements in reversed order. + * + * @returns reversed array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.toReversed(); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 3.0 + * + * var im = imagf( z ); + * // returns 3.0 + * + * z = out.get( 1 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns 2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = realf( z ); + * // returns 1.0 + * + * im = imagf( z ); + * // returns 1.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.toReversed(); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 3.0 + * + * var im = imag( z ); + * // returns 3.0 + * + * z = out.get( 1 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns 2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = real( z ); + * // returns 1.0 + * + * im = imag( z ); + * // returns 1.0 + */ + toReversed(): ComplexTypedArray; + + /** + * Returns a new typed array containing the elements in sorted order. + * + * @param compareFcn - comparison function + * @returns sorted array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function compare( a, b ) { + * var re1 = realf( a ); + * var re2 = realf( b ); + * if ( re1 < re2 ) { + * return -1; + * } + * if ( re1 > re2 ) { + * return 1; + * } + * var im1 = imagf( a ); + * var im2 = imagf( b ); + * if ( im1 < im2 ) { + * return -1; + * } + * if ( im1 > im2 ) { + * return 1; + * } + * return 0; + * } + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 3.0, -3.0 ], 0 ); + * arr.set( [ 1.0, -1.0 ], 1 ); + * arr.set( [ 2.0, -2.0 ], 2 ); + * + * var out = arr.toSorted( compare ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 1.0 + * + * var im = imagf( z ); + * // returns -1.0 + * + * z = out.get( 1 ); + * // returns + * + * re = realf( z ); + * // returns 2.0 + * + * im = imagf( z ); + * // returns -2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = realf( z ); + * // returns 3.0 + * + * im = imagf( z ); + * // returns -3.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function compare( a, b ) { + * var re1 = real( a ); + * var re2 = real( b ); + * if ( re1 < re2 ) { + * return -1; + * } + * if ( re1 > re2 ) { + * return 1; + * } + * var im1 = imag( a ); + * var im2 = imag( b ); + * if ( im1 < im2 ) { + * return -1; + * } + * if ( im1 > im2 ) { + * return 1; + * } + * return 0; + * } + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 3.0, -3.0 ], 0 ); + * arr.set( [ 1.0, -1.0 ], 1 ); + * arr.set( [ 2.0, -2.0 ], 2 ); + * + * var out = arr.toSorted( compare ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -1.0 + * + * z = out.get( 1 ); + * // returns + * + * re = real( z ); + * // returns 2.0 + * + * im = imag( z ); + * // returns -2.0 + * + * z = out.get( 2 ); + * // returns + * + * re = real( z ); + * // returns 3.0 + * + * im = imag( z ); + * // returns -3.0 + */ + toSorted( compareFcn: CompareFcn ): ComplexTypedArray; + + /** + * Serializes an array as a string. + * + * @returns string + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.toString(); + * // returns '1 + 1i,2 + 2i' + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 2 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * + * var str = arr.toString(); + * // returns '1 + 1i,2 + 2i' + */ + toString(): string; + + /** + * Returns an iterator for iterating over each value in a typed array. + * + * @returns iterator + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * 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 + * + * var re = realf( v ); + * // returns 1.0 + * + * var im = imagf( v ); + * // returns -1.0 + * + * v = iter.next().value; + * // returns + * + * re = realf( v ); + * // returns 2.0 + * + * im = imagf( v ); + * // returns -2.0 + * + * var bool = iter.next().done; + * // returns true + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 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 + * + * var re = real( v ); + * // returns 1.0 + * + * var im = imag( v ); + * // returns -1.0 + * + * v = iter.next().value; + * // returns + * + * re = real( v ); + * // returns 2.0 + * + * im = imag( v ); + * // returns -2.0 + * + * var bool = iter.next().done; + * // returns true + */ + values(): TypedIterator; + + /** + * Returns a new typed array with the element at a provided index replaced with a provided value. + * + * @param index - element index + * @param value - new value + * @throws first argument must be an integer + * @throws second argument must be a complex number + * @throws index argument is out-of-bounds + * @returns modified typed array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.with( 0, new Complex64( 4.0, 4.0 ) ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = realf( z ); + * // returns 4.0 + * + * var im = imagf( z ); + * // returns 4.0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 3 ); + * + * arr.set( [ 1.0, 1.0 ], 0 ); + * arr.set( [ 2.0, 2.0 ], 1 ); + * arr.set( [ 3.0, 3.0 ], 2 ); + * + * var out = arr.with( 0, new Complex128( 4.0, 4.0 ) ); + * // returns + * + * var z = out.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 4.0 + * + * var im = imag( z ); + * // returns 4.0 + */ + with( index: number, value: ComplexLike ): ComplexTypedArray; +} + +/** +* Interface describing a complex number typed array constructor. +*/ +interface ComplexTypedArrayConstructor { + /** + * Complex number array constructor. + * + * @param arg - length, typed array, array-like object, or buffer + * @param byteOffset - byte offset (default: 0) + * @param length - view length + * @returns complex number array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array(); + * // returns + * + * var len = arr.length; + * // returns 0 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = new Complex64Array( [ 1.0, -1.0 ] ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var buf = new ArrayBuffer( 16 ); + * var arr = new Complex64Array( buf ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var buf = new ArrayBuffer( 16 ); + * var arr = new Complex64Array( buf, 8 ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Complex64Array( buf, 8, 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array(); + * // returns + * + * var len = arr.length; + * // returns 0 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = new Complex128Array( [ 1.0, -1.0 ] ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Complex128Array( buf ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Complex128Array( buf, 16 ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var buf = new ArrayBuffer( 64 ); + * var arr = new Complex128Array( buf, 16, 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + */ + new( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): ComplexTypedArray; + + /** + * Complex number array constructor (callable without `new`). + * + * @param arg - length, typed array, array-like object, or buffer + * @param byteOffset - byte offset (default: 0) + * @param length - view length + * @returns complex number array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = Complex64Array( 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = Complex128Array( 2 ); + * // returns + * + * var len = arr.length; + * // returns 2 + */ + ( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): ComplexTypedArray; + + /** + * Constructor name. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var str = Complex64Array.name; + * // returns 'Complex64Array' + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var str = Complex128Array.name; + * // returns 'Complex128Array' + */ + readonly name: string; + + /** + * Size (in bytes) of each array element. + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var nbytes = Complex64Array.BYTES_PER_ELEMENT; + * // returns 8 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var nbytes = Complex128Array.BYTES_PER_ELEMENT; + * // returns 16 + */ + readonly BYTES_PER_ELEMENT: number; + + /** + * Creates a new complex number array from an array-like object or iterable. + * + * @param src - array-like object or iterable + * @param clbk - callback to invoke for each source element + * @param thisArg - callback execution context + * @throws array-like objects must have a length which is a multiple of two + * @throws an iterator must return either a two element array containing real and imaginary components or a complex number + * @throws when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number + * @returns complex number array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * function clbk( v ) { + * return new Complex64( realf( v ) * 2.0, imagf( v ) * 2.0 ); + * } + * + * var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); + * // returns + * + * var len = arr.length; + * // returns 1 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * function clbk( v ) { + * return new Complex128( real( v ) * 2.0, imag( v ) * 2.0 ); + * } + * + * var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk ); + * // returns + * + * var len = arr.length; + * // returns 1 + */ + from( src: ArrayLike | RealOrComplexTypedArray | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): ComplexTypedArray; + + /** + * Creates a new complex number array from a variable number of arguments. + * + * @param elements - array elements + * @returns complex number array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * var Complex64 = require( '@stdlib/complex/float32/ctor' ); + * var realf = require( '@stdlib/complex/float32/real' ); + * var imagf = require( '@stdlib/complex/float32/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * + * var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); + * // returns + * + * var len = arr.length; + * // returns 2 + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + * var complexFactory = require( '@stdlib/array/complex-factory' ); + * + * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * + * var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); + * // returns + * + * var len = arr.length; + * // returns 2 + */ + of( ...elements: Array ): ComplexTypedArray; +} + +/** +* Returns a complex number typed array constructor. +* +* @param dtype - complex number array data type (e.g., `'complex64'`) +* @param FloatArray - underlying float typed array constructor +* @param ComplexScalar - complex number scalar constructor +* @param getReal - function returning the real component of a complex number +* @param getImag - function returning the imaginary component of a complex number +* @param reinterpret - function reinterpreting a same-type complex array as its underlying float array +* @throws first argument must be a string +* @throws second argument must be a function +* @throws third argument must be a function +* @throws fourth argument must be a function +* @throws fifth argument must be a function +* @throws sixth argument must be a function +* @returns complex number array constructor +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +* +* var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +* // returns +*/ +declare function complexFactory( + dtype: string, + FloatArray: Function, + ComplexScalar: new ( ...args: Array ) => T, + getReal: GetReal, + getImag: GetImag, + reinterpret: Reinterpret +): ComplexTypedArrayConstructor; + + +// EXPORTS // + +export = complexFactory; diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts b/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts new file mode 100644 index 000000000000..caacd2a0a6bb --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts @@ -0,0 +1,104 @@ +/* +* @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. +*/ + +/* eslint-disable @typescript-eslint/no-unused-expressions */ + +import Float32Array = require( '@stdlib/array/float32' ); +import Float64Array = require( '@stdlib/array/float64' ); +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import realf = require( '@stdlib/complex/float32/real' ); +import imagf = require( '@stdlib/complex/float32/imag' ); +import real = require( '@stdlib/complex/float64/real' ); +import imag = require( '@stdlib/complex/float64/imag' ); +import reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +import reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +import complexArrayFactory = require( './index' ); + + +// TESTS // + +// The function returns a constructor function... +{ + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectType ComplexTypedArrayConstructor + complexArrayFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); // $ExpectType ComplexTypedArrayConstructor +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + complexArrayFactory( 5, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( true, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( null, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( [], Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( {}, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a function... +{ + complexArrayFactory( 'complex64', 5, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', 'abc', Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', true, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', null, Complex64, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', [], Complex64, realf, imagf, reinterpret64 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a constructor... +{ + complexArrayFactory( 'complex64', Float32Array, 5, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, 'abc', realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, true, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, null, realf, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, [], realf, imagf, reinterpret64 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a function... +{ + complexArrayFactory( 'complex64', Float32Array, Complex64, 5, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, 'abc', imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, true, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, null, imagf, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, [], imagf, reinterpret64 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a function... +{ + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, 5, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, 'abc', reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, true, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, null, reinterpret64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, [], reinterpret64 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a function... +{ + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, 5 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, 'abc' ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, true ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, null ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, [] ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + complexArrayFactory(); // $ExpectError + complexArrayFactory( 'complex64' ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64 ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf ); // $ExpectError + complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/complex-factory/examples/index.js b/lib/node_modules/@stdlib/array/complex-factory/examples/index.js new file mode 100644 index 000000000000..9e26313d5145 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/examples/index.js @@ -0,0 +1,81 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var logEach = require( '@stdlib/console/log-each' ); +var complexFactory = require( './../lib' ); + +var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); +var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + +// Create a Complex64Array by specifying a length: +var out = new Complex64Array( 3 ); +logEach( '%s', out ); + +// Create a Complex64Array from an array of complex numbers: +var arr = [ + new Complex64( 1.0, -1.0 ), + new Complex64( -3.14, 3.14 ), + new Complex64( 0.5, 0.5 ) +]; +out = new Complex64Array( arr ); +logEach( '%s', out ); + +// Create a Complex64Array from an interleaved typed array: +arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex64Array( arr ); +logEach( '%s', out ); + +// Create a Complex64Array from an array buffer: +arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex64Array( arr.buffer ); +logEach( '%s', out ); + +// Create a Complex128Array by specifying a length: +out = new Complex128Array( 3 ); +logEach( '%s', out ); + +// Create a Complex128Array from an array of complex numbers: +arr = [ + new Complex128( 1.0, -1.0 ), + new Complex128( -3.14, 3.14 ), + new Complex128( 0.5, 0.5 ) +]; +out = new Complex128Array( arr ); +logEach( '%s', out ); + +// Create a Complex128Array from an interleaved typed array: +arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex128Array( arr ); +logEach( '%s', out ); + +// Create a Complex128Array from an array buffer: +arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); +out = new Complex128Array( arr.buffer ); +logEach( '%s', out ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/from_array.js b/lib/node_modules/@stdlib/array/complex-factory/lib/from_array.js new file mode 100644 index 000000000000..8651590caedb --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/from_array.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 isComplexLike = require( '@stdlib/assert/is-complex-like' ); + + +// MAIN // + +/** +* Returns a function for filling a strided array with real and imaginary components from an array of complex-like objects. +* +* @private +* @param {Function} getReal - function to get the real component of a complex number +* @param {Function} getImag - function to get the imaginary component of a complex number +* @returns {Function} fromArray function +*/ +function makeFromArray( getReal, getImag ) { + return fromArray; + + /** + * Returns a strided array of real and imaginary components. + * + * @private + * @param {TypedArray} buf - output array + * @param {Array} arr - array containing complex numbers + * @returns {(TypedArray|null)} output array or null + */ + function fromArray( buf, arr ) { + var len; + var v; + var i; + var j; + + len = arr.length; + j = 0; + for ( i = 0; i < len; i++ ) { + v = arr[ i ]; + if ( !isComplexLike( v ) ) { + return null; + } + buf[ j ] = getReal( v ); + buf[ j+1 ] = getImag( v ); + j += 2; // stride + } + return buf; + } +} + + +// EXPORTS // + +module.exports = makeFromArray; diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator.js b/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator.js new file mode 100644 index 000000000000..26325a638384 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator.js @@ -0,0 +1,75 @@ +/** +* @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 isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Returns a function for consuming an iterator and collecting real/imaginary pairs. +* +* @private +* @param {Function} getReal - function to get the real component of a complex number +* @param {Function} getImag - function to get the imaginary component of a complex number +* @returns {Function} fromIterator function +*/ +function makeFromIterator( getReal, getImag ) { + return fromIterator; + + /** + * Returns an array of iterated values. + * + * @private + * @param {Object} it - iterator + * @returns {(Array|TypeError)} array or an error + */ + function fromIterator( it ) { + var out; + var v; + var z; + + out = []; + while ( true ) { + v = it.next(); + if ( v.done ) { + break; + } + z = v.value; + if ( isArrayLikeObject( z ) && z.length >= 2 ) { + out.push( z[ 0 ], z[ 1 ] ); + } else if ( isComplexLike( z ) ) { + out.push( getReal( z ), getImag( z ) ); + } else { + return new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); + } + } + return out; + } +} + + +// EXPORTS // + +module.exports = makeFromIterator; diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator_map.js b/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator_map.js new file mode 100644 index 000000000000..3e347a3eb997 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/from_iterator_map.js @@ -0,0 +1,80 @@ +/** +* @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 isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Returns a function for consuming a mapped iterator and collecting real/imaginary pairs. +* +* @private +* @param {Function} getReal - function to get the real component of a complex number +* @param {Function} getImag - function to get the imaginary component of a complex number +* @returns {Function} fromIteratorMap function +*/ +function makeFromIteratorMap( getReal, getImag ) { + return fromIteratorMap; + + /** + * Returns an array of iterated values. + * + * @private + * @param {Object} it - iterator + * @param {Function} clbk - callback to invoke for each iterated value + * @param {*} thisArg - invocation context + * @returns {(Array|TypeError)} array or an error + */ + function fromIteratorMap( it, clbk, thisArg ) { + var out; + var v; + var z; + var i; + + out = []; + i = -1; + while ( true ) { + v = it.next(); + if ( v.done ) { + break; + } + i += 1; + z = clbk.call( thisArg, v.value, i ); + if ( isArrayLikeObject( z ) && z.length >= 2 ) { + out.push( z[ 0 ], z[ 1 ] ); + } else if ( isComplexLike( z ) ) { + out.push( getReal( z ), getImag( z ) ); + } else { + return new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); + } + } + return out; + } +} + + +// EXPORTS // + +module.exports = makeFromIteratorMap; diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/index.js b/lib/node_modules/@stdlib/array/complex-factory/lib/index.js new file mode 100644 index 000000000000..a3e35bf6a067 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/index.js @@ -0,0 +1,66 @@ +/** +* @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'; + +/** +* Factory for creating complex number typed array constructors. +* +* @module @stdlib/array/complex-factory +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var realf = require( '@stdlib/complex/float32/real' ); +* var imagf = require( '@stdlib/complex/float32/imag' ); +* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +* var factory = require( '@stdlib/array/complex-factory' ); +* +* var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +* +* var arr = new Complex64Array( 2 ); +* // returns +* +* var len = arr.length; +* // returns 2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +* var factory = require( '@stdlib/array/complex-factory' ); +* +* var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); +* +* var arr = new Complex128Array( 2 ); +* // returns +* +* var len = arr.length; +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/main.js b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js new file mode 100644 index 000000000000..41341637b0ce --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js @@ -0,0 +1,2038 @@ +/** +* @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. +*/ + +/* eslint-disable max-lines, no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var isCollection = require( '@stdlib/assert/is-collection' ); +var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); +var isObject = require( '@stdlib/assert/is-object' ); +var isArray = require( '@stdlib/assert/is-array' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isFunction = require( '@stdlib/assert/is-function' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var isEven = require( '@stdlib/math/base/assert/is-even' ); +var isInteger = require( '@stdlib/math/base/assert/is-integer' ); +var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); +var getter = require( '@stdlib/array/base/getter' ); +var accessorGetter = require( '@stdlib/array/base/accessor-getter' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var makeFromIterator = require( './from_iterator.js' ); +var makeFromIteratorMap = require( './from_iterator_map.js' ); +var makeFromArray = require( './from_array.js' ); + + +// VARIABLES // + +var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); + + +// MAIN // + +/** +* Returns a complex number array constructor. +* +* @param {string} dtype - complex number array data type (e.g., 'complex64') +* @param {Function} FloatArray - underlying float typed array constructor (e.g., Float32Array) +* @param {Function} ComplexScalar - complex number scalar constructor (e.g., Complex64) +* @param {Function} getReal - function returning the real component of a complex number +* @param {Function} getImag - function returning the imaginary component of a complex number +* @param {Function} reinterpret - function reinterpreting a same-type complex array as its underlying float array +* @throws {TypeError} first argument must be a string +* @throws {TypeError} second argument must be a function +* @throws {TypeError} third argument must be a function +* @throws {TypeError} fourth argument must be a function +* @throws {TypeError} fifth argument must be a function +* @throws {TypeError} sixth argument must be a function +* @throws {Error} must provide valid arguments +* @throws {RangeError} must provide valid arguments +* @returns {Function} complex number array constructor +*/ +function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) { + var BYTES_PER_ELEMENT; + var fromIteratorMap; + var fromIterator; + var fromArray; + + if ( !isString( dtype ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', dtype ) ); + } + if ( !isFunction( FloatArray ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', FloatArray ) ); + } + if ( !isFunction( ComplexScalar ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', ComplexScalar ) ); + } + if ( !isFunction( getReal ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', getReal ) ); + } + if ( !isFunction( getImag ) ) { + throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', getImag ) ); + } + if ( !isFunction( reinterpret ) ) { + throw new TypeError( format( 'invalid argument. Sixth argument must be a function. Value: `%s`.', reinterpret ) ); + } + BYTES_PER_ELEMENT = FloatArray.BYTES_PER_ELEMENT * 2; + + fromIterator = makeFromIterator( getReal, getImag ); + fromIteratorMap = makeFromIteratorMap( getReal, getImag ); + fromArray = makeFromArray( getReal, getImag ); + + + // FUNCTIONS // + + /** + * Returns a boolean indicating if a value is a complex typed array. + * + * @private + * @param {*} value - value to test + * @returns {boolean} boolean indicating if a value is a complex typed array + */ + function isComplexArray( value ) { + return ( + value instanceof ComplexArray || + ( + typeof value === 'object' && + value !== null && + typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle + typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle + ) + ); + } + + /** + * Returns a boolean indicating if a value is a complex typed array constructor. + * + * @private + * @param {*} value - value to test + * @returns {boolean} boolean indicating if a value is a complex typed array constructor + */ + function isComplexArrayConstructor( value ) { + return ( + value === ComplexArray || + ( + typeof value === 'function' && + typeof value.BYTES_PER_ELEMENT === 'number' && + value.BYTES_PER_ELEMENT > 0 + ) + ); + } + + /** + * Retrieves a complex number from a complex number array buffer. + * + * @private + * @param {TypedArray} buf - array buffer + * @param {NonNegativeInteger} idx - element index + * @returns {ComplexLike} complex number + */ + function getComplex( buf, idx ) { + idx *= 2; + return new ComplexScalar( buf[ idx ], buf[ idx+1 ] ); + } + + + // CONSTRUCTOR // + + /** + * Complex number array constructor. + * + * @constructor + * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable + * @param {NonNegativeInteger} [byteOffset=0] - byte offset + * @param {NonNegativeInteger} [length] - view length + * @throws {RangeError} ArrayBuffer byte length must be a multiple of `BYTES_PER_ELEMENT` + * @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two + * @throws {TypeError} if provided only a single argument, must provide a valid argument + * @throws {TypeError} byte offset must be a nonnegative integer + * @throws {RangeError} byte offset must be a multiple of `BYTES_PER_ELEMENT` + * @throws {TypeError} view length must be a positive multiple of `BYTES_PER_ELEMENT` + * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements + * @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number + * @returns {ComplexArray} complex number array + */ + function ComplexArray() { + var byteOffset; + var nargs; + var buf; + var len; + + nargs = arguments.length; + if ( !(this instanceof ComplexArray) ) { + if ( nargs === 0 ) { + return new ComplexArray(); + } + if ( nargs === 1 ) { + return new ComplexArray( arguments[0] ); + } + if ( nargs === 2 ) { + return new ComplexArray( arguments[0], arguments[1] ); + } + return new ComplexArray( arguments[0], arguments[1], arguments[2] ); + } + // Create the underlying data buffer... + if ( nargs === 0 ) { + buf = new FloatArray( 0 ); // backward-compatibility + } else if ( nargs === 1 ) { + if ( isNonNegativeInteger( arguments[0] ) ) { + buf = new FloatArray( arguments[0]*2 ); + } else if ( isCollection( arguments[0] ) ) { + buf = arguments[ 0 ]; + len = buf.length; + + // If provided a "generic" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to "normal" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number... + if ( len && isArray( buf ) && isComplexLike( buf[0] ) ) { + buf = fromArray( new FloatArray( len*2 ), buf ); + if ( buf === null ) { + // We failed and we are now forced to allocate a new array :-( + if ( !isEven( len ) ) { + throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); + } + // We failed, so fall back to directly setting values... + buf = new FloatArray( arguments[0] ); + } + } else if ( isComplexArray( buf ) ) { + // If the source is any complex typed array, extract its underlying float buffer and convert element-wise... + buf = new FloatArray( reinterpret( buf, 0 ) ); + } else if ( isEven( len ) ) { + buf = new FloatArray( buf ); + } else { + throw new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); + } + } else if ( isArrayBuffer( arguments[0] ) ) { + buf = arguments[ 0 ]; + if ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) { + throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) ); + } + buf = new FloatArray( buf ); + } else if ( isObject( arguments[0] ) ) { + buf = arguments[ 0 ]; + if ( HAS_ITERATOR_SYMBOL === false ) { + throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) ); + } + if ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) { + throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); + } + buf = buf[ ITERATOR_SYMBOL ](); + if ( !isFunction( buf.next ) ) { + // eslint-disable-next-line no-warning-comments + // FIXME: `buf` is what is returned from above, NOT the original value + throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); + } + buf = fromIterator( buf ); + if ( buf instanceof Error ) { + throw buf; + } + buf = new FloatArray( buf ); + } else { + throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) ); + } + } else { + buf = arguments[ 0 ]; + if ( !isArrayBuffer( buf ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + } + byteOffset = arguments[ 1 ]; + if ( !isNonNegativeInteger( byteOffset ) ) { + throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + } + if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { + throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + } + if ( nargs === 2 ) { + len = buf.byteLength - byteOffset; + if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { + throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + } + buf = new FloatArray( buf, byteOffset ); + } else { + len = arguments[ 2 ]; + if ( !isNonNegativeInteger( len ) ) { + throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + } + if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { + throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + } + buf = new FloatArray( buf, byteOffset, len*2 ); + } + } + setReadOnly( this, '_buffer', buf ); + setReadOnly( this, '_length', buf.length/2 ); + + return this; + } + + // STATIC PROPERTIES // + + /** + * Size (in bytes) of each array element. + * + * @name BYTES_PER_ELEMENT + * @memberof ComplexArray + * @readonly + * @type {PositiveInteger} + */ + setReadOnly( ComplexArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); + + /** + * Constructor name. + * + * @name name + * @memberof ComplexArray + * @readonly + * @type {string} + */ + setReadOnly( ComplexArray, 'name', dtype[ 0 ].toUpperCase() + dtype.slice( 1 ) + 'Array' ); + + // STATIC METHODS // + + /** + * Creates a new complex number array from an array-like object or an iterable. + * + * @name from + * @memberof ComplexArray + * @type {Function} + * @param {(Collection|Iterable)} src - array-like object or iterable + * @param {Function} [clbk] - callback to invoke for each source element + * @param {*} [thisArg] - context + * @throws {TypeError} `this` context must be a constructor + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be an array-like object or an iterable + * @throws {TypeError} second argument must be a function + * @throws {RangeError} array-like objects must have a length which is a multiple of two + * @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number + * @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number + * @returns {ComplexArray} complex number array + */ + setReadOnly( ComplexArray, 'from', function from( src ) { + var thisArg; + var nargs; + var clbk; + var out; + var buf; + var tmp; + var get; + var len; + var flg; + var v; + var i; + var j; + if ( !isFunction( this ) ) { + throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + } + if ( !isComplexArrayConstructor( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + nargs = arguments.length; + if ( nargs > 1 ) { + clbk = arguments[ 1 ]; + if ( !isFunction( clbk ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + } + if ( nargs > 2 ) { + thisArg = arguments[ 2 ]; + } + } + if ( isComplexArray( src ) ) { + len = src.length; + if ( clbk ) { + out = new this( len ); + buf = out._buffer; // eslint-disable-line no-underscore-dangle + j = 0; + for ( i = 0; i < len; i++ ) { + v = clbk.call( thisArg, src.get( i ), i ); + if ( isComplexLike( v ) ) { + buf[ j ] = getReal( v ); + buf[ j+1 ] = getImag( v ); + } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { + buf[ j ] = v[ 0 ]; + buf[ j+1 ] = v[ 1 ]; + } else { + throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); + } + j += 2; // stride + } + return out; + } + return new this( src ); + } + if ( isCollection( src ) ) { + if ( clbk ) { + // Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component. + + len = src.length; + if ( src.get && src.set ) { + get = accessorGetter( 'default' ); + } else { + get = getter( 'default' ); + } + // Detect whether we've been provided an array which returns complex number objects... + for ( i = 0; i < len; i++ ) { + if ( !isComplexLike( get( src, i ) ) ) { + flg = true; + break; + } + } + // If an array does not contain only complex number objects, then we assume interleaved real and imaginary components... + if ( flg ) { + if ( !isEven( len ) ) { + throw new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) ); + } + out = new this( len/2 ); + buf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < len; i++ ) { + buf[ i ] = clbk.call( thisArg, get( src, i ), i ); + } + return out; + } + // If an array contains only complex number objects, then we need to extract real and imaginary components... + out = new this( len ); + buf = out._buffer; // eslint-disable-line no-underscore-dangle + j = 0; + for ( i = 0; i < len; i++ ) { + v = clbk.call( thisArg, get( src, i ), i ); + if ( isComplexLike( v ) ) { + buf[ j ] = getReal( v ); + buf[ j+1 ] = getImag( v ); + } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { + buf[ j ] = v[ 0 ]; + buf[ j+1 ] = v[ 1 ]; + } else { + throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); + } + j += 2; // stride + } + return out; + } + return new this( src ); + } + if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len + buf = src[ ITERATOR_SYMBOL ](); + if ( !isFunction( buf.next ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + } + if ( clbk ) { + tmp = fromIteratorMap( buf, clbk, thisArg ); + } else { + tmp = fromIterator( buf ); + } + if ( tmp instanceof Error ) { + throw tmp; + } + len = tmp.length / 2; + out = new this( len ); + buf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < len; i++ ) { + buf[ i ] = tmp[ i ]; + } + return out; + } + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + }); + + /** + * Creates a new complex number array from a variable number of arguments. + * + * @name of + * @memberof ComplexArray + * @type {Function} + * @param {...*} element - array elements + * @throws {TypeError} `this` context must be a constructor + * @throws {TypeError} `this` must be a complex number array + * @returns {ComplexArray} complex number array + */ + setReadOnly( ComplexArray, 'of', function of() { + var args; + var i; + if ( !isFunction( this ) ) { + throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + } + if ( !isComplexArrayConstructor( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + args = []; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + return new this( args ); + }); + + // PROTOTYPE METHODS // + + /** + * Returns an array element with support for both nonnegative and negative integer indices. + * + * @name at + * @memberof ComplexArray.prototype + * @type {Function} + * @param {integer} idx - element index + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} must provide an integer + * @returns {(ComplexLike|void)} array element + */ + setReadOnly( ComplexArray.prototype, 'at', function at( idx ) { + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isInteger( idx ) ) { + throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + } + if ( idx < 0 ) { + idx += this._length; + } + if ( idx < 0 || idx >= this._length ) { + return; + } + return getComplex( this._buffer, idx ); + }); + + /** + * Pointer to the underlying data buffer. + * + * @name buffer + * @memberof ComplexArray.prototype + * @readonly + * @type {ArrayBuffer} + */ + setReadOnlyAccessor( ComplexArray.prototype, 'buffer', function get() { + return this._buffer.buffer; + }); + + /** + * Size (in bytes) of the array. + * + * @name byteLength + * @memberof ComplexArray.prototype + * @readonly + * @type {NonNegativeInteger} + */ + setReadOnlyAccessor( ComplexArray.prototype, 'byteLength', function get() { + return this._buffer.byteLength; + }); + + /** + * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. + * + * @name byteOffset + * @memberof ComplexArray.prototype + * @readonly + * @type {NonNegativeInteger} + */ + setReadOnlyAccessor( ComplexArray.prototype, 'byteOffset', function get() { + return this._buffer.byteOffset; + }); + + /** + * Size (in bytes) of each array element. + * + * @name BYTES_PER_ELEMENT + * @memberof ComplexArray.prototype + * @readonly + * @type {PositiveInteger} + */ + setReadOnly( ComplexArray.prototype, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); + + /** + * Copies a sequence of elements within the array to the position starting at `target`. + * + * @name copyWithin + * @memberof ComplexArray.prototype + * @type {Function} + * @param {integer} target - index at which to start copying elements + * @param {integer} start - source index at which to copy elements from + * @param {integer} [end] - source index at which to stop copying elements from + * @throws {TypeError} `this` must be a complex number array + * @returns {ComplexArray} modified array + */ + setReadOnly( ComplexArray.prototype, 'copyWithin', function copyWithin( target, start ) { + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + // eslint-disable-next-line no-warning-comments + // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled + if ( arguments.length === 2 ) { + this._buffer.copyWithin( target*2, start*2 ); + } else { + this._buffer.copyWithin( target*2, start*2, arguments[2]*2 ); + } + return this; + }); + + /** + * Returns an iterator for iterating over array key-value pairs. + * + * @name entries + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {Iterator} iterator + */ + setReadOnly( ComplexArray.prototype, 'entries', function entries() { + var self; + var iter; + var len; + var buf; + var FLG; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + self = this; + buf = this._buffer; + len = this._length; + + // Initialize an iteration index: + i = -1; + + // Create an iterator protocol-compliant object: + iter = {}; + setReadOnly( iter, 'next', next ); + setReadOnly( iter, 'return', end ); + + if ( ITERATOR_SYMBOL ) { + setReadOnly( iter, ITERATOR_SYMBOL, iteratorFactory ); + } + return iter; + + /** + * Returns the next iterator value. + * + * @private + * @returns {Object} iterator protocol-compliant object + */ + function next() { + i += 1; + if ( FLG || i >= len ) { + return { + 'done': true + }; + } + return { + 'value': [ i, getComplex( buf, i ) ], + 'done': false + }; + } + + /** + * Finishes an iterator. + * + * @private + * @param {*} [value] - value to return + * @returns {Object} iterator protocol-compliant object + */ + function end( value ) { + FLG = true; + if ( arguments.length ) { + return { + 'value': value, + 'done': true + }; + } + return { + 'done': true + }; + } + + /** + * Returns a new iterator. + * + * @private + * @returns {Iterator} iterator + */ + function iteratorFactory() { + return self.entries(); + } + }); + + /** + * Tests whether all elements in an array pass a test implemented by a predicate function. + * + * @name every + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {boolean} boolean indicating whether all elements pass a test + */ + setReadOnly( ComplexArray.prototype, 'every', function every( predicate, thisArg ) { + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + if ( !predicate.call( thisArg, getComplex( buf, i ), i, this ) ) { + return false; + } + } + return true; + }); + + /** + * Returns a modified typed array filled with a fill value. + * + * @name fill + * @memberof ComplexArray.prototype + * @type {Function} + * @param {ComplexLike} value - fill value + * @param {integer} [start=0] - starting index (inclusive) + * @param {integer} [end] - ending index (exclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a complex number + * @throws {TypeError} second argument must be an integer + * @throws {TypeError} third argument must be an integer + * @returns {ComplexArray} modified array + */ + setReadOnly( ComplexArray.prototype, 'fill', function fill( value, start, end ) { + var buf; + var len; + var idx; + var re; + var im; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isComplexLike( value ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length > 1 ) { + if ( !isInteger( start ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + } + if ( start < 0 ) { + start += len; + if ( start < 0 ) { + start = 0; + } + } + if ( arguments.length > 2 ) { + if ( !isInteger( end ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + } + if ( end < 0 ) { + end += len; + if ( end < 0 ) { + end = 0; + } + } + if ( end > len ) { + end = len; + } + } else { + end = len; + } + } else { + start = 0; + end = len; + } + re = getReal( value ); + im = getImag( value ); + for ( i = start; i < end; i++ ) { + idx = 2*i; + buf[ idx ] = re; + buf[ idx+1 ] = im; + } + return this; + }); + + /** + * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + * + * @name filter + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {ComplexArray} complex number array + */ + setReadOnly( ComplexArray.prototype, 'filter', function filter( predicate, thisArg ) { + var buf; + var out; + var i; + var z; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + out = []; + for ( i = 0; i < this._length; i++ ) { + z = getComplex( buf, i ); + if ( predicate.call( thisArg, z, i, this ) ) { + out.push( z ); + } + } + return new this.constructor( out ); + }); + + /** + * Returns the first element in an array for which a predicate function returns a truthy value. + * + * @name find + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {(ComplexLike|void)} array element or undefined + */ + setReadOnly( ComplexArray.prototype, 'find', function find( predicate, thisArg ) { + var buf; + var i; + var z; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + z = getComplex( buf, i ); + if ( predicate.call( thisArg, z, i, this ) ) { + return z; + } + } + }); + + /** + * Returns the index of the first element in an array for which a predicate function returns a truthy value. + * + * @name findIndex + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {integer} index or -1 + */ + setReadOnly( ComplexArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) { + var buf; + var i; + var z; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + z = getComplex( buf, i ); + if ( predicate.call( thisArg, z, i, this ) ) { + return i; + } + } + return -1; + }); + + /** + * Returns the last element in an array for which a predicate function returns a truthy value. + * + * @name findLast + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {(ComplexLike|void)} array element or undefined + */ + setReadOnly( ComplexArray.prototype, 'findLast', function findLast( predicate, thisArg ) { + var buf; + var i; + var z; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = this._length-1; i >= 0; i-- ) { + z = getComplex( buf, i ); + if ( predicate.call( thisArg, z, i, this ) ) { + return z; + } + } + }); + + /** + * Returns the index of the last element in an array for which a predicate function returns a truthy value. + * + * @name findLastIndex + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {integer} index or -1 + */ + setReadOnly( ComplexArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { + var buf; + var i; + var z; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = this._length-1; i >= 0; i-- ) { + z = getComplex( buf, i ); + if ( predicate.call( thisArg, z, i, this ) ) { + return i; + } + } + return -1; + }); + + /** + * Invokes a function once for each array element. + * + * @name forEach + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} fcn - function to invoke + * @param {*} [thisArg] - function invocation context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + */ + setReadOnly( ComplexArray.prototype, 'forEach', function forEach( fcn, thisArg ) { + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( fcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + fcn.call( thisArg, getComplex( buf, i ), i, this ); + } + }); + + /** + * Returns an array element. + * + * @name get + * @memberof ComplexArray.prototype + * @type {Function} + * @param {NonNegativeInteger} idx - element index + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} must provide a nonnegative integer + * @returns {(ComplexLike|void)} array element + */ + setReadOnly( ComplexArray.prototype, 'get', function get( idx ) { + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isNonNegativeInteger( idx ) ) { + throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + } + if ( idx >= this._length ) { + return; + } + return getComplex( this._buffer, idx ); + }); + + /** + * Returns a boolean indicating whether an array includes a provided value. + * + * @name includes + * @memberof ComplexArray.prototype + * @type {Function} + * @param {ComplexLike} searchElement - search element + * @param {integer} [fromIndex=0] - starting index (inclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a complex number + * @throws {TypeError} second argument must be an integer + * @returns {boolean} boolean indicating whether an array includes a provided value + */ + setReadOnly( ComplexArray.prototype, 'includes', function includes( searchElement, fromIndex ) { + var buf; + var idx; + var re; + var im; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isComplexLike( searchElement ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); + } + if ( arguments.length > 1 ) { + if ( !isInteger( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex < 0 ) { + fromIndex += this._length; + if ( fromIndex < 0 ) { + fromIndex = 0; + } + } + } else { + fromIndex = 0; + } + re = getReal( searchElement ); + im = getImag( searchElement ); + buf = this._buffer; + for ( i = fromIndex; i < this._length; i++ ) { + idx = 2 * i; + if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { + return true; + } + } + return false; + }); + + /** + * Returns the first index at which a given element can be found. + * + * @name indexOf + * @memberof ComplexArray.prototype + * @type {Function} + * @param {ComplexLike} searchElement - element to find + * @param {integer} [fromIndex=0] - starting index (inclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a complex number + * @throws {TypeError} second argument must be an integer + * @returns {integer} index or -1 + */ + setReadOnly( ComplexArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { + var buf; + var idx; + var re; + var im; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isComplexLike( searchElement ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); + } + if ( arguments.length > 1 ) { + if ( !isInteger( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex < 0 ) { + fromIndex += this._length; + if ( fromIndex < 0 ) { + fromIndex = 0; + } + } + } else { + fromIndex = 0; + } + re = getReal( searchElement ); + im = getImag( searchElement ); + buf = this._buffer; + for ( i = fromIndex; i < this._length; i++ ) { + idx = 2 * i; + if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { + return i; + } + } + return -1; + }); + + /** + * Returns a new string by concatenating all array elements. + * + * @name join + * @memberof ComplexArray.prototype + * @type {Function} + * @param {string} [separator=','] - element separator + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a string + * @returns {string} string representation + */ + setReadOnly( ComplexArray.prototype, 'join', function join( separator ) { + var out; + var buf; + var sep; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( arguments.length === 0 ) { + sep = ','; + } else if ( isString( separator ) ) { + sep = separator; + } else { + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + } + out = []; + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + out.push( getComplex( buf, i ).toString() ); + } + return out.join( sep ); + }); + + /** + * Returns an iterator for iterating over each index key in a typed array. + * + * @name keys + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {Iterator} iterator + */ + setReadOnly( ComplexArray.prototype, 'keys', function keys() { + var self; + var iter; + var len; + var FLG; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + self = this; + len = this._length; + + // Initialize an iteration index: + i = -1; + + // Create an iterator protocol-compliant object: + iter = {}; + setReadOnly( iter, 'next', next ); + setReadOnly( iter, 'return', end ); + + if ( ITERATOR_SYMBOL ) { + setReadOnly( iter, ITERATOR_SYMBOL, iteratorFactory ); + } + return iter; + + /** + * Returns the next iterator value. + * + * @private + * @returns {Object} iterator protocol-compliant object + */ + function next() { + i += 1; + if ( FLG || i >= len ) { + return { + 'done': true + }; + } + return { + 'value': i, + 'done': false + }; + } + + /** + * Finishes an iterator. + * + * @private + * @param {*} [value] - value to return + * @returns {Object} iterator protocol-compliant object + */ + function end( value ) { + FLG = true; + if ( arguments.length ) { + return { + 'value': value, + 'done': true + }; + } + return { + 'done': true + }; + } + + /** + * Returns a new iterator. + * + * @private + * @returns {Iterator} iterator + */ + function iteratorFactory() { + return self.keys(); + } + }); + + /** + * Returns the last index at which a given element can be found. + * + * @name lastIndexOf + * @memberof ComplexArray.prototype + * @type {Function} + * @param {ComplexLike} searchElement - element to find + * @param {integer} [fromIndex] - index at which to start searching backward (inclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a complex number + * @throws {TypeError} second argument must be an integer + * @returns {integer} index or -1 + */ + setReadOnly( ComplexArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { + var buf; + var idx; + var re; + var im; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isComplexLike( searchElement ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); + } + if ( arguments.length > 1 ) { + if ( !isInteger( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex >= this._length ) { + fromIndex = this._length - 1; + } else if ( fromIndex < 0 ) { + fromIndex += this._length; + } + } else { + fromIndex = this._length - 1; + } + re = getReal( searchElement ); + im = getImag( searchElement ); + buf = this._buffer; + for ( i = fromIndex; i >= 0; i-- ) { + idx = 2 * i; + if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { + return i; + } + } + return -1; + }); + + /** + * Number of array elements. + * + * @name length + * @memberof ComplexArray.prototype + * @readonly + * @type {NonNegativeInteger} + */ + setReadOnlyAccessor( ComplexArray.prototype, 'length', function get() { + return this._length; + }); + + /** + * Returns a new array with each element being the result of a provided callback function. + * + * @name map + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} fcn - callback function + * @param {*} [thisArg] - callback function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {ComplexArray} complex number array + */ + setReadOnly( ComplexArray.prototype, 'map', function map( fcn, thisArg ) { + var outbuf; + var buf; + var out; + var i; + var v; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( fcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + } + buf = this._buffer; + out = new this.constructor( this._length ); + outbuf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < this._length; i++ ) { + v = fcn.call( thisArg, getComplex( buf, i ), i, this ); + if ( isComplexLike( v ) ) { + outbuf[ 2*i ] = getReal( v ); + outbuf[ (2*i)+1 ] = getImag( v ); + } else if ( isArrayLikeObject( v ) && v.length === 2 ) { + outbuf[ 2*i ] = v[ 0 ]; + outbuf[ (2*i)+1 ] = v[ 1 ]; + } else { + throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); + } + } + return out; + }); + + /** + * Applies a provided callback function to each element of the array, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. + * + * @name reduce + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} reducer - callback function + * @param {*} [initialValue] - initial value + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @throws {Error} if not provided an initial value, the array must have at least one element + * @returns {*} accumulated result + */ + setReadOnly( ComplexArray.prototype, 'reduce', function reduce( reducer, initialValue ) { + var buf; + var acc; + var len; + var v; + var i; + + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( reducer ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length > 1 ) { + acc = initialValue; + i = 0; + } else { + if ( len === 0 ) { + throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); + } + acc = getComplex( buf, 0 ); + i = 1; + } + for ( ; i < len; i++ ) { + v = getComplex( buf, i ); + acc = reducer( acc, v, i, this ); + } + return acc; + }); + + /** + * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. + * + * @name reduceRight + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} reducer - callback function + * @param {*} [initialValue] - initial value + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @throws {Error} if not provided an initial value, the array must have at least one element + * @returns {*} accumulated result + */ + setReadOnly( ComplexArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { + var buf; + var acc; + var len; + var v; + var i; + + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( reducer ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length > 1 ) { + acc = initialValue; + i = len-1; + } else { + if ( len === 0 ) { + throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); + } + acc = getComplex( buf, len-1 ); + i = len-2; + } + for ( ; i >= 0; i-- ) { + v = getComplex( buf, i ); + acc = reducer( acc, v, i, this ); + } + return acc; + }); + + /** + * Reverses an array in-place. + * + * @name reverse + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {ComplexArray} reversed array + */ + setReadOnly( ComplexArray.prototype, 'reverse', function reverse() { + var buf; + var tmp; + var len; + var N; + var i; + var j; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + len = this._length; + buf = this._buffer; + N = floor( len / 2 ); + for ( i = 0; i < N; i++ ) { + j = len - i - 1; + tmp = buf[ (2*i) ]; + buf[ (2*i) ] = buf[ (2*j) ]; + buf[ (2*j) ] = tmp; + tmp = buf[ (2*i)+1 ]; + buf[ (2*i)+1 ] = buf[ (2*j)+1 ]; + buf[ (2*j)+1 ] = tmp; + } + return this; + }); + + /** + * Sets an array element. + * + * @name set + * @memberof ComplexArray.prototype + * @type {Function} + * @param {(Collection|ComplexLike|ComplexArray)} value - value(s) + * @param {NonNegativeInteger} [i=0] - element index at which to start writing values + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array + * @throws {TypeError} index argument must be a nonnegative integer + * @throws {RangeError} array-like objects must have a length which is a multiple of two + * @throws {RangeError} index argument is out-of-bounds + * @throws {RangeError} target array lacks sufficient storage to accommodate source values + * @returns {void} + */ + setReadOnly( ComplexArray.prototype, 'set', function set( value ) { + /* eslint-disable no-underscore-dangle */ + var sbuf; + var idx; + var buf; + var tmp; + var flg; + var N; + var v; + var i; + var j; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + buf = this._buffer; + if ( arguments.length > 1 ) { + idx = arguments[ 1 ]; + if ( !isNonNegativeInteger( idx ) ) { + throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + } + } else { + idx = 0; + } + if ( isComplexLike( value ) ) { + if ( idx >= this._length ) { + throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); + } + idx *= 2; + buf[ idx ] = getReal( value ); + buf[ idx+1 ] = getImag( value ); + return; + } + if ( isComplexArray( value ) ) { + N = value._length; + if ( idx+N > this._length ) { + throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + } + sbuf = reinterpret( value, 0 ); + + // Check for overlapping memory... + j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); + if ( + sbuf.buffer === buf.buffer && + ( + sbuf.byteOffset < j && + sbuf.byteOffset+sbuf.byteLength > j + ) + ) { + // We need to copy source values... + tmp = new FloatArray( sbuf.length ); + for ( i = 0; i < sbuf.length; i++ ) { + tmp[ i ] = sbuf[ i ]; + } + sbuf = tmp; + } + idx *= 2; + j = 0; + for ( i = 0; i < N; i++ ) { + buf[ idx ] = sbuf[ j ]; + buf[ idx+1 ] = sbuf[ j+1 ]; + idx += 2; // stride + j += 2; // stride + } + return; + } + if ( isCollection( value ) ) { + // Detect whether we've been provided an array of complex numbers... + N = value.length; + for ( i = 0; i < N; i++ ) { + if ( !isComplexLike( value[ i ] ) ) { + flg = true; + break; + } + } + // If an array does not contain only complex numbers, then we assume interleaved real and imaginary components... + if ( flg ) { + if ( !isEven( N ) ) { + throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) ); + } + if ( idx+(N/2) > this._length ) { + throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + } + sbuf = value; + + // Check for overlapping memory... + j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); + if ( + sbuf.buffer === buf.buffer && + ( + sbuf.byteOffset < j && + sbuf.byteOffset+sbuf.byteLength > j + ) + ) { + // We need to copy source values... + tmp = new FloatArray( N ); + for ( i = 0; i < N; i++ ) { + tmp[ i ] = sbuf[ i ]; // eslint-disable-line no-warning-comments + } + sbuf = tmp; + } + idx *= 2; + N /= 2; + j = 0; + for ( i = 0; i < N; i++ ) { + buf[ idx ] = sbuf[ j ]; + buf[ idx+1 ] = sbuf[ j+1 ]; + idx += 2; // stride + j += 2; // stride + } + return; + } + // If an array contains only complex numbers, then we need to extract real and imaginary components... + if ( idx+N > this._length ) { + throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + } + idx *= 2; + for ( i = 0; i < N; i++ ) { + v = value[ i ]; + buf[ idx ] = getReal( v ); + buf[ idx+1 ] = getImag( v ); + idx += 2; // stride + } + return; + } + throw new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) ); + + /* eslint-enable no-underscore-dangle */ + }); + + /** + * Copies a portion of a typed array to a new typed array. + * + * @name slice + * @memberof ComplexArray.prototype + * @type {Function} + * @param {integer} [start=0] - starting index (inclusive) + * @param {integer} [end] - ending index (exclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be an integer + * @throws {TypeError} second argument must be an integer + * @returns {ComplexArray} complex number array + */ + setReadOnly( ComplexArray.prototype, 'slice', function slice( start, end ) { + var outlen; + var outbuf; + var out; + var idx; + var buf; + var len; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length === 0 ) { + start = 0; + end = len; + } else { + if ( !isInteger( start ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) ); + } + if ( start < 0 ) { + start += len; + if ( start < 0 ) { + start = 0; + } + } + if ( arguments.length === 1 ) { + end = len; + } else { + if ( !isInteger( end ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + } + if ( end < 0 ) { + end += len; + if ( end < 0 ) { + end = 0; + } + } else if ( end > len ) { + end = len; + } + } + } + if ( start < end ) { + outlen = end - start; + } else { + outlen = 0; + } + out = new this.constructor( outlen ); + outbuf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < outlen; i++ ) { + idx = 2*(i+start); + outbuf[ 2*i ] = buf[ idx ]; + outbuf[ (2*i)+1 ] = buf[ idx+1 ]; + } + return out; + }); + + /** + * Tests whether at least one element in an array passes a test implemented by a predicate function. + * + * @name some + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} predicate - test function + * @param {*} [thisArg] - predicate function execution context + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {boolean} boolean indicating whether at least one element passes a test + */ + setReadOnly( ComplexArray.prototype, 'some', function some( predicate, thisArg ) { + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + if ( predicate.call( thisArg, getComplex( buf, i ), i, this ) ) { + return true; + } + } + return false; + }); + + /** + * Sorts an array in-place. + * + * @name sort + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} compareFcn - comparison function + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {ComplexArray} sorted array + */ + setReadOnly( ComplexArray.prototype, 'sort', function sort( compareFcn ) { + var tmp; + var buf; + var len; + var i; + var j; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( compareFcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + } + buf = this._buffer; + len = this._length; + tmp = []; + for ( i = 0; i < len; i++ ) { + tmp.push( getComplex( buf, i ) ); + } + tmp.sort( compareFcn ); + for ( i = 0; i < len; i++ ) { + j = 2 * i; + buf[ j ] = getReal( tmp[i] ); + buf[ j+1 ] = getImag( tmp[i] ); + } + return this; + }); + + /** + * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. + * + * @name subarray + * @memberof ComplexArray.prototype + * @type {Function} + * @param {integer} [begin=0] - starting index (inclusive) + * @param {integer} [end] - ending index (exclusive) + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be an integer + * @throws {TypeError} second argument must be an integer + * @returns {ComplexArray} subarray + */ + setReadOnly( ComplexArray.prototype, 'subarray', function subarray( begin, end ) { + var offset; + var buf; + var len; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length === 0 ) { + begin = 0; + end = len; + } else { + if ( !isInteger( begin ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + } + if ( begin < 0 ) { + begin += len; + if ( begin < 0 ) { + begin = 0; + } + } + if ( arguments.length === 1 ) { + end = len; + } else { + if ( !isInteger( end ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + } + if ( end < 0 ) { + end += len; + if ( end < 0 ) { + end = 0; + } + } else if ( end > len ) { + end = len; + } + } + } + if ( begin >= len ) { + len = 0; + offset = buf.byteLength; + } else if ( begin >= end ) { + len = 0; + offset = buf.byteOffset + (begin*BYTES_PER_ELEMENT); + } else { + len = end - begin; + offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); + } + return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); // eslint-disable-line max-len + }); + + /** + * Serializes an array as a locale-specific string. + * + * @name toLocaleString + * @memberof ComplexArray.prototype + * @type {Function} + * @param {(string|Array)} [locales] - locale identifier(s) + * @param {Object} [options] - configuration options + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a string or an array of strings + * @throws {TypeError} options argument must be an object + * @returns {string} string representation + */ + setReadOnly( ComplexArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) { + var opts; + var loc; + var out; + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( arguments.length === 0 ) { + loc = []; + } else if ( isString( locales ) || isStringArray( locales ) ) { + loc = locales; + } else { + throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); + } + if ( arguments.length < 2 ) { + opts = {}; + } else if ( isObject( options ) ) { + opts = options; + } else { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + buf = this._buffer; + out = []; + for ( i = 0; i < this._length; i++ ) { + out.push( getComplex( buf, i ).toLocaleString( loc, opts ) ); + } + return out.join( ',' ); + }); + + /** + * Returns a new typed array containing the elements in reversed order. + * + * @name toReversed + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {ComplexArray} reversed array + */ + setReadOnly( ComplexArray.prototype, 'toReversed', function toReversed() { + var outbuf; + var out; + var len; + var buf; + var i; + var j; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + len = this._length; + out = new this.constructor( len ); + buf = this._buffer; + outbuf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < len; i++ ) { + j = len - i - 1; + outbuf[ (2*i) ] = buf[ (2*j) ]; + outbuf[ (2*i)+1 ] = buf[ (2*j)+1 ]; + } + return out; + }); + + /** + * Returns a new typed array containing the elements in sorted order. + * + * @name toSorted + * @memberof ComplexArray.prototype + * @type {Function} + * @param {Function} compareFcn - comparison function + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be a function + * @returns {ComplexArray} sorted array + */ + setReadOnly( ComplexArray.prototype, 'toSorted', function toSorted( compareFcn ) { + var tmp; + var buf; + var len; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isFunction( compareFcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + } + buf = this._buffer; + len = this._length; + tmp = []; + for ( i = 0; i < len; i++ ) { + tmp.push( getComplex( buf, i ) ); + } + tmp.sort( compareFcn ); + return new ComplexArray( tmp ); + }); + + /** + * Serializes an array as a string. + * + * @name toString + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {string} string representation + */ + setReadOnly( ComplexArray.prototype, 'toString', function toString() { + var out; + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + out = []; + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + out.push( getComplex( buf, i ).toString() ); + } + return out.join( ',' ); + }); + + /** + * Returns an iterator for iterating over each value in a typed array. + * + * @name values + * @memberof ComplexArray.prototype + * @type {Function} + * @throws {TypeError} `this` must be a complex number array + * @returns {Iterator} iterator + */ + setReadOnly( ComplexArray.prototype, 'values', function values() { + var iter; + var self; + var len; + var FLG; + var buf; + var i; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + self = this; + buf = this._buffer; + len = this._length; + + // Initialize an iteration index: + i = -1; + + // Create an iterator protocol-compliant object: + iter = {}; + setReadOnly( iter, 'next', next ); + setReadOnly( iter, 'return', end ); + + if ( ITERATOR_SYMBOL ) { + setReadOnly( iter, ITERATOR_SYMBOL, iteratorFactory ); + } + return iter; + + /** + * Returns the next iterator value. + * + * @private + * @returns {Object} iterator protocol-compliant object + */ + function next() { + i += 1; + if ( FLG || i >= len ) { + return { + 'done': true + }; + } + return { + 'value': getComplex( buf, i ), + 'done': false + }; + } + + /** + * Finishes an iterator. + * + * @private + * @param {*} [value] - value to return + * @returns {Object} iterator protocol-compliant object + */ + function end( value ) { + FLG = true; + if ( arguments.length ) { + return { + 'value': value, + 'done': true + }; + } + return { + 'done': true + }; + } + + /** + * Returns a new iterator. + * + * @private + * @returns {Iterator} iterator + */ + function iteratorFactory() { + return self.values(); + } + }); + + /** + * Returns a new typed array with the element at a provided index replaced with a provided value. + * + * @name with + * @memberof ComplexArray.prototype + * @type {Function} + * @param {integer} index - element index + * @param {ComplexLike} value - new value + * @throws {TypeError} `this` must be a complex number array + * @throws {TypeError} first argument must be an integer + * @throws {RangeError} index argument is out-of-bounds + * @throws {TypeError} second argument must be a complex number + * @returns {ComplexArray} new typed array + */ + setReadOnly( ComplexArray.prototype, 'with', function copyWith( index, value ) { + var buf; + var out; + var len; + if ( !isComplexArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); + } + if ( !isInteger( index ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + } + len = this._length; + if ( index < 0 ) { + index += len; + } + if ( index < 0 || index >= len ) { + throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + } + if ( !isComplexLike( value ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) ); + } + out = new this.constructor( this._buffer ); + buf = out._buffer; // eslint-disable-line no-underscore-dangle + buf[ 2*index ] = getReal( value ); + buf[ (2*index)+1 ] = getImag( value ); + return out; + }); + + return ComplexArray; +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/array/complex-factory/package.json b/lib/node_modules/@stdlib/array/complex-factory/package.json new file mode 100644 index 000000000000..307e22e2da49 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/package.json @@ -0,0 +1,76 @@ +{ + "name": "@stdlib/array/complex-factory", + "version": "0.0.0", + "description": "Factory for creating complex number typed array constructors.", + "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": { + "doc": "./docs", + "example": "./examples", + "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", + "stdtypes", + "types", + "data", + "structure", + "array", + "typed", + "typed array", + "typed-array", + "complex64array", + "complex128array", + "complex64", + "complex128", + "complex", + "cmplx", + "real", + "imaginary", + "imag", + "float", + "float64", + "float32", + "single-precision", + "double-precision", + "ieee754" + ] +} diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js new file mode 100644 index 000000000000..3ec5dd7380db --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js @@ -0,0 +1,281 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `at` method for returning an array element (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'at' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.at ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `at` method for returning an array element (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'at' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.at ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.at.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.at.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.at( value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.at( value ); + }; + } +}); + +tape( 'the method returns `undefined` if provided an index which exceeds array dimensions (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + for ( i = -arr.length; i < arr.length; i++ ) { + if ( i < 0 ) { + v = arr.at( i-arr.length ); + t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); + } else { + v = arr.at( arr.length+i ); + t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); + } + } + t.end(); +}); + +tape( 'the method returns `undefined` if provided an index which exceeds array dimensions (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + for ( i = -arr.length; i < arr.length; i++ ) { + if ( i < 0 ) { + v = arr.at( i-arr.length ); + t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); + } else { + v = arr.at( arr.length+i ); + t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); + } + } + t.end(); +}); + +tape( 'the method returns an array element (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr = new Complex128Array( arr ); + + for ( i = -arr.length; i < arr.length; i++ ) { + v = arr.at( i ); + if ( i < 0 ) { + t.strictEqual( real( v ), arr.length + i, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), -arr.length - i, 'returns expected imaginary component for index '+i ); + } else { + t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); + } + } + t.end(); +}); + +tape( 'the method returns an array element (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, -i ) ); + } + arr = new Complex64Array( arr ); + + for ( i = -arr.length; i < arr.length; i++ ) { + v = arr.at( i ); + if ( i < 0 ) { + t.strictEqual( realf( v ), arr.length + i, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), -arr.length - i, 'returns expected imaginary component for index '+i ); + } else { + t.strictEqual( realf( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), -i, 'returns expected imaginary component for index '+i ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js new file mode 100644 index 000000000000..5e09b8914df9 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js @@ -0,0 +1,769 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ).isPrimitive; +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ).isPrimitive; +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `copyWithin` method for copying a sequence of array elements within a complex number array (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'copyWithin' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.copyWithin ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `copyWithin` method for copying a sequence of array elements within a complex number array (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'copyWithin' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.copyWithin ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.copyWithin.call( value, 3, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.copyWithin.call( value, 3, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (end) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.copyWithin.call( value, 3, 0, 5 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (end) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.copyWithin.call( value, 3, 0, 5 ); + }; + } +}); + +tape( 'the method copies a sequence of elements within an array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 0, 3 ); + + buf = new Float64Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 0, 3 ); + + buf = new Float32Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative target) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( -arr.length, 3 ); + + buf = new Float64Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative target) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( -arr.length, 3 ); + + buf = new Float32Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative start) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 0, -2 ); + + buf = new Float64Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative start) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 0, -2 ); + + buf = new Float32Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (end=length) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 0, 3, arr.length ); + + buf = new Float64Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (end=length) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 0, 3, arr.length ); + + buf = new Float32Array( arr.buffer ); + + // Overwritten: + t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); + t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); + + // Remain the same: + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (non-inclusive end) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 2, 0, 2 ); + + buf = new Float64Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + + // Remain the same: + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (non-inclusive end) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 2, 0, 2 ); + + buf = new Float32Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + + // Remain the same: + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative end) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 2, 0, -3 ); + + buf = new Float64Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + + // Remain the same: + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative end) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 2, 0, -3 ); + + buf = new Float32Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + + // Remain the same: + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target >= length) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( arr.length, 3 ); + + buf = new Float64Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target >= length) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( arr.length, 3 ); + + buf = new Float32Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); + t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target > start) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = [ + new Complex128( 0.0, -0.0 ), + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ), + new Complex128( 3.0, -3.0 ), + new Complex128( 4.0, -4.0 ) + ]; + arr = new Complex128Array( arr ); + + arr.copyWithin( 2, 0 ); + + buf = new Float64Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 2.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -2.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target > start) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = [ + new Complex64( 0.0, -0.0 ), + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ), + new Complex64( 3.0, -3.0 ), + new Complex64( 4.0, -4.0 ) + ]; + arr = new Complex64Array( arr ); + + arr.copyWithin( 2, 0 ); + + buf = new Float32Array( arr.buffer ); + + // Remain the same: + t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); + t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); + t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); + t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); + + // Overwritten: + t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); + t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); + t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); + t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); + t.strictEqual( buf[ 8 ], 2.0, 'returns expected real for complex number 4' ); + t.strictEqual( buf[ 9 ], -2.0, 'returns expected imag for complex number 4' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js new file mode 100644 index 000000000000..89b107616399 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js @@ -0,0 +1,451 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isArray = require( '@stdlib/assert/is-array' ); +var isComplex128 = require( '@stdlib/assert/is-complex128' ); +var isComplex64 = require( '@stdlib/assert/is-complex64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `entries` method for returning an iterator for iterating over array key-value pairs (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'entries' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.entries ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `entries` method for returning an iterator for iterating over array key-value pairs (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'entries' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.entries ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.entries.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.entries.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object (complex128)', function test( t ) { + var Complex128Array; + var buf; + var arr; + var it; + var v; + var i; + var j; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it = arr.entries(); + t.strictEqual( it.next.length, 0, 'has zero arity' ); + + j = 0; + for ( i = 0; i < arr.length; i++ ) { + v = it.next(); + t.strictEqual( isArray( v.value ), true, 'returns expected value' ); + t.strictEqual( v.value[ 0 ], i, 'returns an index' ); + t.strictEqual( isComplex128( v.value[ 1 ] ), true, 'returns a complex number' ); + t.strictEqual( real( v.value[ 1 ] ), buf[ j ], 'returns expected real component' ); + t.strictEqual( imag( v.value[ 1 ] ), buf[ j+1 ], 'returns expected imaginary component' ); + t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); + + j += 2; // stride + } + t.end(); +}); + +tape( 'the method returns an iterator protocol-compliant object (complex64)', function test( t ) { + var Complex64Array; + var buf; + var arr; + var it; + var v; + var i; + var j; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it = arr.entries(); + t.strictEqual( it.next.length, 0, 'has zero arity' ); + + j = 0; + for ( i = 0; i < arr.length; i++ ) { + v = it.next(); + t.strictEqual( isArray( v.value ), true, 'returns expected value' ); + t.strictEqual( v.value[ 0 ], i, 'returns an index' ); + t.strictEqual( isComplex64( v.value[ 1 ] ), true, 'returns a complex number' ); + t.strictEqual( realf( v.value[ 1 ] ), buf[ j ], 'returns expected real component' ); + t.strictEqual( imagf( v.value[ 1 ] ), buf[ j+1 ], 'returns expected imaginary component' ); + t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); + + j += 2; // stride + } + t.end(); +}); + +tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument) (complex128)', function test( t ) { + var Complex128Array; + var buf; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it = arr.entries(); + + v = it.next(); + t.strictEqual( real( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); + t.strictEqual( imag( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( real( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); + t.strictEqual( imag( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument) (complex64)', function test( t ) { + var Complex64Array; + var buf; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it = arr.entries(); + + v = it.next(); + t.strictEqual( realf( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); + t.strictEqual( imagf( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( realf( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); + t.strictEqual( imagf( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument) (complex128)', function test( t ) { + var Complex128Array; + var buf; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it = arr.entries(); + + v = it.next(); + t.strictEqual( real( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); + t.strictEqual( imag( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( real( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); + t.strictEqual( imag( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'finished' ); + t.strictEqual( v.value, 'finished', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument) (complex64)', function test( t ) { + var Complex64Array; + var buf; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it = arr.entries(); + + v = it.next(); + t.strictEqual( realf( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); + t.strictEqual( imagf( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( realf( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); + t.strictEqual( imagf( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'finished' ); + t.strictEqual( v.value, 'finished', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it1 = arr.entries(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); + t.strictEqual( real( v1[ 1 ] ), real( v2[ 1 ] ), 'returns expected value' ); + t.strictEqual( imag( v1[ 1 ] ), imag( v2[ 1 ] ), 'returns expected value' ); + } + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it1 = arr.entries(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); + t.strictEqual( realf( v1[ 1 ] ), realf( v2[ 1 ] ), 'returns expected value' ); + t.strictEqual( imagf( v1[ 1 ] ), imagf( v2[ 1 ] ), 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js new file mode 100644 index 000000000000..820112c83dc3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js @@ -0,0 +1,345 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `every` method for returning boolean indicating whether all elements pass a test (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'every' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.every ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `every` method for returning boolean indicating whether all elements pass a test (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'every' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.every ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.every.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.every.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.every( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.every( value ); + }; + } +}); + +tape( 'the method returns `true` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if all elements pass a test (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `true` if all elements pass a test (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method returns `false` if one or more elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `false` if one or more elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var bool; + var ctx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + bool = arr.every( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var bool; + var ctx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + bool = arr.every( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js new file mode 100644 index 000000000000..a5a9af57eb67 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js @@ -0,0 +1,589 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `fill` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'fill' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.fill ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `fill` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'fill' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.fill ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.fill.call( value, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.fill.call( value, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.fill( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.fill( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.fill( new Complex128( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.fill( new Complex64( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a third argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.fill( new Complex128( 1.0, 1.0 ), 0, value ); + }; + } +}); + +tape( 'the method throws an error if provided a third argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.fill( new Complex64( 1.0, 1.0 ), 0, value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.fill( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.fill( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + out = arr.fill( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + out = arr.fill( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method sets each array element to the provided value (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ) ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method sets each array element to the provided value (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ) ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), 1 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), 1 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), 0, 2 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), 0, 2 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), -3, -1 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), -3, -1 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), -10 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), -10 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), 1, 10 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), 1, 10 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 3 ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + arr.fill( new Complex128( 1.0, 1.0 ), 2, 1 ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 3 ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + arr.fill( new Complex64( 1.0, 1.0 ), 2, 1 ); + + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js new file mode 100644 index 000000000000..79ddfc599b3c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js @@ -0,0 +1,372 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `filter` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'filter' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.filter ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `filter` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'filter' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.filter ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.filter.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.filter.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.filter( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.filter( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.filter( predicate ); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.filter( predicate ); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } +}); + +tape( 'the method returns a new complex number array containing only those elements which satisfy a test condition (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } +}); + +tape( 'the method returns a new complex number array containing only those elements which satisfy a test condition (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } +}); + +tape( 'the method copies all elements to a new array if all elements satisfy a test condition (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } +}); + +tape( 'the method copies all elements to a new array if all elements satisfy a test condition (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.filter( predicate ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + var ctx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.filter( predicate, ctx ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( real( v ) > 0 && imag( v ) < 0 ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + var ctx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.filter( predicate, ctx ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js new file mode 100644 index 000000000000..7ec0a870d4fc --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js @@ -0,0 +1,349 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `find` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'find' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.find ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `find` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'find' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.find ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.find.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.find.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.find( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.find( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + z = arr.find( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `undefined` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + z = arr.find( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the first element which passes a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + z = arr.find( predicate ); + + t.strictEqual( real( z ), 2.0, 'returns expected value' ); + t.strictEqual( imag( z ), -2.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === -imag( v ) ); + } +}); + +tape( 'the method returns the first element which passes a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + z = arr.find( predicate ); + + t.strictEqual( realf( z ), 2.0, 'returns expected value' ); + t.strictEqual( imagf( z ), -2.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === -imagf( v ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + z = arr.find( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + z = arr.find( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var ctx; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + z = arr.find( predicate, ctx ); + + t.strictEqual( real( z ), 3.0, 'returns expected value' ); + t.strictEqual( imag( z ), 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var ctx; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + z = arr.find( predicate, ctx ); + + t.strictEqual( realf( z ), 3.0, 'returns expected value' ); + t.strictEqual( imagf( z ), 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js new file mode 100644 index 000000000000..14a27f6c6767 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js @@ -0,0 +1,345 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findIndex` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.findIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findIndex` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.findIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findIndex.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findIndex.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findIndex( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the first element which passes a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === -imag( v ) ); + } +}); + +tape( 'the method returns the index of the first element which passes a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === -imagf( v ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var ctx; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + idx = arr.findIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var ctx; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + idx = arr.findIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js new file mode 100644 index 000000000000..03c6da1267db --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js @@ -0,0 +1,349 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findLast` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLast' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.findLast ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findLast` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLast' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.findLast ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findLast.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findLast.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findLast( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findLast( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + z = arr.findLast( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `undefined` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + z = arr.findLast( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the last element which passes a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + z = arr.findLast( predicate ); + + t.strictEqual( real( z ), 2.0, 'returns expected value' ); + t.strictEqual( imag( z ), -2.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === -imag( v ) ); + } +}); + +tape( 'the method returns the last element which passes a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + z = arr.findLast( predicate ); + + t.strictEqual( realf( z ), 2.0, 'returns expected value' ); + t.strictEqual( imagf( z ), -2.0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === -imagf( v ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + z = arr.findLast( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + z = arr.findLast( predicate ); + + t.strictEqual( z, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var ctx; + var arr; + var z; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + z = arr.findLast( predicate, ctx ); + + t.strictEqual( real( z ), 3.0, 'returns expected value' ); + t.strictEqual( imag( z ), 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var ctx; + var arr; + var z; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + z = arr.findLast( predicate, ctx ); + + t.strictEqual( realf( z ), 3.0, 'returns expected value' ); + t.strictEqual( imagf( z ), 3.0, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js new file mode 100644 index 000000000000..5e7fb855a4d1 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js @@ -0,0 +1,345 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findLastIndex` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLastIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.findLastIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `findLastIndex` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLastIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.findLastIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex.call( value, predicate ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findLastIndex( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.findLastIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the last element which passes a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === -imag( v ) ); + } +}); + +tape( 'the method returns the index of the last element which passes a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === -imagf( v ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var ctx; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, 3.0 ] ); + idx = arr.findLastIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var ctx; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, 3.0 ] ); + idx = arr.findLastIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js new file mode 100644 index 000000000000..0d90ad84b7a8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js @@ -0,0 +1,349 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isComplex128 = require( '@stdlib/assert/is-complex128' ); +var isComplex64 = require( '@stdlib/assert/is-complex64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `forEach` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'forEach' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.forEach ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `forEach` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'forEach' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.forEach ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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 fcn( v ) { + if ( !isComplex128( v ) ) { + t.fail( 'should be a complex number' ); + } + } + + function badValue( value ) { + return function badValue() { + return arr.forEach.call( value, fcn ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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 fcn( v ) { + if ( !isComplex64( v ) ) { + t.fail( 'should be a complex number' ); + } + } + + function badValue( value ) { + return function badValue() { + return arr.forEach.call( value, fcn ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.forEach( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.forEach( value ); + }; + } +}); + +tape( 'the method should not invoke a provided callback function if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + arr.forEach( fcn ); + + t.end(); + + function fcn() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method should not invoke a provided callback function if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + arr.forEach( fcn ); + + t.end(); + + function fcn() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `undefined` (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = arr.forEach( fcn ); + + t.strictEqual( out, void 0, 'returns expected value' ); + t.end(); + + function fcn( v ) { + if ( !isComplex128( v ) ) { + t.fail( 'should be a complex number' ); + } + } +}); + +tape( 'the method returns `undefined` (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = arr.forEach( fcn ); + + t.strictEqual( out, void 0, 'returns expected value' ); + t.end(); + + function fcn( v ) { + if ( !isComplex64( v ) ) { + t.fail( 'should be a complex number' ); + } + } +}); + +tape( 'the method invokes a provided function for each element in an array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + expected = []; + arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + arr.forEach( fcn ); + expected = new Complex128Array( expected ); + + t.deepEqual( reinterpret128( expected, 0 ), reinterpret128( arr, 0 ), 'returns expected value' ); + t.end(); + + function fcn( v ) { + expected.push( v ); + } +}); + +tape( 'the method invokes a provided function for each element in an array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + expected = []; + arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); + arr.forEach( fcn ); + expected = new Complex64Array( expected ); + + t.deepEqual( reinterpret64( expected, 0 ), reinterpret64( arr, 0 ), 'returns expected value' ); + t.end(); + + function fcn( v ) { + expected.push( v ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var ctx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + arr.forEach( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var ctx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + arr.forEach( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js new file mode 100644 index 000000000000..08cf324181af --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js @@ -0,0 +1,1530 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the returned constructor is a `from` method for creating a complex number array from an array-like object or iterable (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + t.strictEqual( hasOwnProp( Complex128Array, 'from' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.from ), true, 'has method' ); + + arr = Complex128Array.from( [] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'attached to the returned constructor is a `from` method for creating a complex number array from an array-like object or iterable (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + t.strictEqual( hasOwnProp( Complex64Array, 'from' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.from ), true, 'has method' ); + + arr = Complex64Array.from( [] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a constructor (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex128Array.from.call( value, [] ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a constructor (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex64Array.from.call( value, [] ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + Complex128, + 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() { + return Complex128Array.from.call( value, [] ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + Complex64, + 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() { + return Complex64Array.from.call( value, [] ); + }; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + 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() { + return Complex128Array.from( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + 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() { + return Complex64Array.from( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (callback) (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + 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() { + return Complex128Array.from( value, clbk ); + }; + } + + function clbk() { + return [ 1.0, 1.0 ]; + } +}); + +tape( 'the method throws an error if not provided an iterable or array-like object (callback) (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + 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() { + return Complex64Array.from( value, clbk ); + }; + } + + function clbk() { + return [ 1.0, 1.0 ]; + } +}); + +tape( 'the method throws an error if provided a second argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex128Array.from( [], value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex64Array.from( [], value ); + }; + } +}); + +tape( 'the method returns a complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + // Generic array: + arr = Complex128Array.from( [] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Generic array containing complex numbers: + arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex128( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex128Array.from( [ z, 1.0 ] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + // Typed array: + arr = Complex128Array.from( new Float64Array( 0 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex128Array.from( new Float64Array( [ 1.0, 1.0 ] ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return real( z ); + }; + } +}); + +tape( 'the method returns a complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + // Generic array: + arr = Complex64Array.from( [] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Generic array containing complex numbers: + arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex64( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex64Array.from( [ z, 1.0 ] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + // Typed array: + arr = Complex64Array.from( new Float32Array( 0 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex64Array.from( new Float32Array( [ 1.0, 1.0 ] ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return realf( z ); + }; + } +}); + +tape( 'the method returns a complex number array (iterable) (complex128)', function test( t ) { + var Complex128Array; + var iter1; + var iter2; + var arr; + var v; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = Complex128Array.from( createIterable( iter1 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = Complex128Array.from( createIterable( iter2 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex128( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } +}); + +tape( 'the method returns a complex number array (iterable) (complex64)', function test( t ) { + var Complex64Array; + var iter1; + var iter2; + var arr; + var v; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = Complex64Array.from( createIterable( iter1 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = Complex64Array.from( createIterable( iter2 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex64( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } +}); + +tape( 'the method supports providing a "map" function which is invoked for each source element (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + // Generic array: + arr = Complex128Array.from( [], clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Generic array containing complex numbers: + arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk2 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk3a ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex128( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex128Array.from( [ z, 1.0 ], clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + // Typed array: + arr = Complex128Array.from( new Float64Array( 0 ), clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex128Array.from( new Float64Array( [ 1.0, 1.0 ] ), clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return real( z ); + }; + } + + function clbk1( v ) { + return v; + } + + function clbk2() { + return [ 1.0, 1.0 ]; + } + + function clbk3a( v ) { + return new Complex128( real(v)*2.0, imag(v)*2.0 ); + } +}); + +tape( 'the method supports providing a "map" function which is invoked for each source element (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + // Generic array: + arr = Complex64Array.from( [], clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Generic array containing complex numbers: + arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk2 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk3a ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex64( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex64Array.from( [ z, 1.0 ], clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + // Typed array: + arr = Complex64Array.from( new Float32Array( 0 ), clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = Complex64Array.from( new Float32Array( [ 1.0, 1.0 ] ), clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return realf( z ); + }; + } + + function clbk1( v ) { + return v; + } + + function clbk2() { + return [ 1.0, 1.0 ]; + } + + function clbk3a( v ) { + return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); + } +}); + +tape( 'the method supports providing a "map" function which is invoked for each iterated value (complex128)', function test( t ) { + var Complex128Array; + var iter1; + var iter2; + var arr; + var v; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = Complex128Array.from( createIterable( iter1 ), clbk1 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = Complex128Array.from( createIterable( iter2 ), clbk2 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function clbk1( v ) { + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex128( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } + + function clbk2( v ) { + return new Complex128( real(v)*2.0, imag(v)*2.0 ); + } +}); + +tape( 'the method supports providing a "map" function which is invoked for each iterated value (complex64)', function test( t ) { + var Complex64Array; + var iter1; + var iter2; + var arr; + var v; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = Complex64Array.from( createIterable( iter1 ), clbk1 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = Complex64Array.from( createIterable( iter2 ), clbk2 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function clbk1( v ) { + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex64( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } + + function clbk2( v ) { + return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); + } +}); + +tape( 'the method supports providing a `this` context for a provided map function (complex128)', function test( t ) { + var Complex128Array; + var arr; + var ctx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + ctx = { + 'count': 0 + }; + arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + ctx = { + 'count': 0 + }; + arr = [ new Complex128( 1.0, 1.0 ), new Complex128( -1.0, -1.0 ) ]; + arr = Complex128Array.from( arr, clbk2, ctx ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + + t.end(); + + function clbk1( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v; + } + + function clbk2( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return new Complex128( real(v)*2.0, imag(v)*2.0 ); + } +}); + +tape( 'the method supports providing a `this` context for a provided map function (complex64)', function test( t ) { + var Complex64Array; + var arr; + var ctx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + ctx = { + 'count': 0 + }; + arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + ctx = { + 'count': 0 + }; + arr = [ new Complex64( 1.0, 1.0 ), new Complex64( -1.0, -1.0 ) ]; + arr = Complex64Array.from( arr, clbk2, ctx ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + + t.end(); + + function clbk1( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return v; + } + + function clbk2( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); + } +}); + +tape( 'the method supports providing a `this` context for a provided map function (iterable) (complex128)', function test( t ) { + var Complex128Array; + var iter; + var ctx; + var arr; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + iter = { + 'next': next, + 'i': 0, + 'N': 4 + }; + ctx = { + 'count': 0 + }; + + arr = Complex128Array.from( createIterable( iter ), clbk, ctx ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next() { + iter.i += 1; + if ( iter.i <= iter.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } +}); + +tape( 'the method supports providing a `this` context for a provided map function (iterable) (complex64)', function test( t ) { + var Complex64Array; + var iter; + var ctx; + var arr; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + iter = { + 'next': next, + 'i': 0, + 'N': 4 + }; + ctx = { + 'count': 0 + }; + + arr = Complex64Array.from( createIterable( iter ), clbk, ctx ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.strictEqual( ctx.count, 4, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next() { + iter.i += 1; + if ( iter.i <= iter.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function clbk( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + v[ 0 ] += 1.0; + v[ 1 ] += 1.0; + return v; + } +}); + +tape( 'the method throws an error if provided a generic array-like object having an odd length (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + [ 1, 2, 3 ], + new Float64Array( [ 1, 2, 3 ] ), + { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }, + [ new Complex128( 1.0, 1.0 ), 1.0, 1.0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return Complex128Array.from( value ); + }; + } +}); + +tape( 'the method throws an error if provided a generic array-like object having an odd length (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + [ 1, 2, 3 ], + new Float32Array( [ 1, 2, 3 ] ), + { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + }, + [ new Complex64( 1.0, 1.0 ), 1.0, 1.0 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return Complex64Array.from( value ); + }; + } +}); + +tape( 'the method throws an error if provided a non-iterable object (ES2015+) (complex128)', function test( t ) { + var Complex128Array; + var values; + var obj3; + var obj4; + var obj5; + var obj6; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + obj3 = {}; + obj3[ ITERATOR_SYMBOL ] = null; + + obj4 = {}; + obj4[ ITERATOR_SYMBOL ] = 'beep'; + + obj5 = {}; + obj5[ ITERATOR_SYMBOL ] = nonIterable1; + + obj6 = {}; + obj6[ ITERATOR_SYMBOL ] = nonIterable2; + + values = [ + {}, + { + '0': 1, + '1': 2, + '2': 3 + }, + obj3, + obj4, + obj5, + obj6 + ]; + 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() { + return Complex128Array.from( value ); + }; + } + + function nonIterable1() { + return null; + } + + function nonIterable2() { + return {}; + } +}); + +tape( 'the method throws an error if provided a non-iterable object (ES2015+) (complex64)', function test( t ) { + var Complex64Array; + var values; + var obj3; + var obj4; + var obj5; + var obj6; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + obj3 = {}; + obj3[ ITERATOR_SYMBOL ] = null; + + obj4 = {}; + obj4[ ITERATOR_SYMBOL ] = 'beep'; + + obj5 = {}; + obj5[ ITERATOR_SYMBOL ] = nonIterable1; + + obj6 = {}; + obj6[ ITERATOR_SYMBOL ] = nonIterable2; + + values = [ + {}, + { + '0': 1, + '1': 2, + '2': 3 + }, + obj3, + obj4, + obj5, + obj6 + ]; + 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() { + return Complex64Array.from( value ); + }; + } + + function nonIterable1() { + return null; + } + + function nonIterable2() { + return {}; + } +}); + +tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (collection) (complex128)', function test( t ) { + var Complex128Array; + var values; + var clbks; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + [ new Complex128( 1.0, 1.0 ) ], + [ new Complex128( 1.0, 1.0 ), new Complex128( -1.0, -1.0 ) ] + ]; + clbks = [ + clbk1, + clbk2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( value, clbk ) { + return function badValue() { + return Complex128Array.from( value, clbk ); + }; + } + + function clbk1() { + return 1.0; + } + + function clbk2() { + return {}; + } +}); + +tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (collection) (complex64)', function test( t ) { + var Complex64Array; + var values; + var clbks; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + [ new Complex64( 1.0, 1.0 ) ], + [ new Complex64( 1.0, 1.0 ), new Complex64( -1.0, -1.0 ) ] + ]; + clbks = [ + clbk1, + clbk2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( value, clbk ) { + return function badValue() { + return Complex64Array.from( value, clbk ); + }; + } + + function clbk1() { + return 1.0; + } + + function clbk2() { + return {}; + } +}); + +tape( 'the method throws an error if provided a "map" function which does not return complex numbers or arrays of real and imaginary components (iterable) (complex128)', function test( t ) { + var Complex128Array; + var values; + var clbks; + var obj1; + var obj2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + obj1 = {}; + obj1[ ITERATOR_SYMBOL ] = createIterable( next1 ); + + obj2 = {}; + obj2[ ITERATOR_SYMBOL ] = createIterable( next2 ); + + values = [ + obj1, + obj2 + ]; + clbks = [ + clbk1, + clbk2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( value, clbk ) { + return function badValue() { + return Complex128Array.from( value, clbk ); + }; + } + + function createIterable( next ) { + return iterable; + + function iterable() { + return { + 'next': next + }; + } + } + + function next1() { + return { + 'value': [ 1.0, 1.0 ] + }; + } + + function clbk1() { + return 1.0; + } + + function next2() { + return { + 'value': new Complex128( 1.0, 1.0 ) + }; + } + + function clbk2() { + return '1.0 - 1.0j'; + } +}); + +tape( 'the method throws an error if provided a "map" function which does not return complex numbers or arrays of real and imaginary components (iterable) (complex64)', function test( t ) { + var Complex64Array; + var values; + var clbks; + var obj1; + var obj2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + obj1 = {}; + obj1[ ITERATOR_SYMBOL ] = createIterable( next1 ); + + obj2 = {}; + obj2[ ITERATOR_SYMBOL ] = createIterable( next2 ); + + values = [ + obj1, + obj2 + ]; + clbks = [ + clbk1, + clbk2 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( value, clbk ) { + return function badValue() { + return Complex64Array.from( value, clbk ); + }; + } + + function createIterable( next ) { + return iterable; + + function iterable() { + return { + 'next': next + }; + } + } + + function next1() { + return { + 'value': [ 1.0, 1.0 ] + }; + } + + function clbk1() { + return 1.0; + } + + function next2() { + return { + 'value': new Complex64( 1.0, 1.0 ) + }; + } + + function clbk2() { + return '1.0 - 1.0j'; + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js new file mode 100644 index 000000000000..ed80ff4c83e9 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js @@ -0,0 +1,263 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `get` method for returning an array element (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.get ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `get` method for returning an array element (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'get' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.get ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.get.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.get.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not a nonnegative integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + 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() { + return arr.get( value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not a nonnegative integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + 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() { + return arr.get( value ); + }; + } +}); + +tape( 'the method returns `undefined` if provided an index which exceeds array dimensions (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( arr.length+i ); + t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); + } + t.end(); +}); + +tape( 'the method returns `undefined` if provided an index which exceeds array dimensions (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( arr.length+i ); + t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); + } + t.end(); +}); + +tape( 'the method returns an array element (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex128( i, -i ) ); + } + arr = new Complex128Array( arr ); + + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); + } + t.end(); +}); + +tape( 'the method returns an array element (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = []; + for ( i = 0; i < 10; i++ ) { + arr.push( new Complex64( i, -i ) ); + } + arr = new Complex64Array( arr ); + + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( realf( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), -i, 'returns expected imaginary component for index '+i ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js new file mode 100644 index 000000000000..2ae142bceac3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js @@ -0,0 +1,499 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `includes` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'includes' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.includes ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `includes` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'includes' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.includes ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.includes.call( value, new Complex128( 10.0, 10.0 ) ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.includes.call( value, new Complex64( 10.0, 10.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.includes( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.includes( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.includes( new Complex128( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.includes( new Complex64( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method returns `false` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + bool = arr.includes( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + bool = arr.includes( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if a complex number is not found (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + bool = arr.includes( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if a complex number is not found (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + bool = arr.includes( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `true` if an array contains a specified complex number (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + bool = arr.includes( new Complex128( 2.0, 2.0 ) ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `true` if an array contains a specified complex number (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + bool = arr.includes( new Complex64( 2.0, 2.0 ) ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if provided a second argument which exceeds the input array length (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + bool = arr.includes( new Complex128( 1.0, 1.0 ), 20 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if provided a second argument which exceeds the input array length (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + bool = arr.includes( new Complex64( 1.0, 1.0 ), 20 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + + bool = arr.includes( new Complex128( 2.0, 2.0 ), 0 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex128( 2.0, 2.0 ), 2 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex128( 3.0, 3.0 ), 3 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + + bool = arr.includes( new Complex64( 2.0, 2.0 ), 0 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex64( 2.0, 2.0 ), 2 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex64( 3.0, 3.0 ), 3 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + bool = arr.includes( new Complex128( 2.0, 2.0 ), -5 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex128( 4.0, 4.0 ), -2 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + bool = arr.includes( new Complex64( 2.0, 2.0 ), -5 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex64( 4.0, 4.0 ), -2 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + bool = arr.includes( new Complex128( 2.0, 2.0 ), -10 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex128( 4.0, 4.0 ), -10 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + bool = arr.includes( new Complex64( 2.0, 2.0 ), -10 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Complex64( 4.0, 4.0 ), -10 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js new file mode 100644 index 000000000000..630eacad8bdf --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js @@ -0,0 +1,503 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `indexOf` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'indexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.indexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is an `indexOf` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'indexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.indexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.indexOf.call( value, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.indexOf.call( value, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.indexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.indexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.indexOf( new Complex128( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.indexOf( new Complex64( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a complex number is not found (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a complex number is not found (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match if a complex number is found (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 5.0, 5.0 ], 4 ); + idx = arr.indexOf( new Complex128( 2.0, 2.0 ) ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match if a complex number is found (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 5.0, 5.0 ], 4 ); + idx = arr.indexOf( new Complex64( 2.0, 2.0 ) ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if provided a second argument which exceeds the input array length (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + idx = arr.indexOf( new Complex128( 1.0, 1.0 ), 20 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if provided a second argument which exceeds the input array length (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + idx = arr.indexOf( new Complex64( 1.0, 1.0 ), 20 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 4.0, 4.0 ], 4 ); + + idx = arr.indexOf( new Complex128( 2.0, 2.0 ), 0 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex128( 2.0, 2.0 ), 2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.indexOf( new Complex128( 3.0, 3.0 ), 3 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 4.0, 4.0 ], 4 ); + + idx = arr.indexOf( new Complex64( 2.0, 2.0 ), 0 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex64( 2.0, 2.0 ), 2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.indexOf( new Complex64( 3.0, 3.0 ), 3 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.indexOf( new Complex128( 2.0, 2.0 ), -5 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex128( 4.0, 4.0 ), -2 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.indexOf( new Complex64( 2.0, 2.0 ), -5 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex64( 4.0, 4.0 ), -2 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.indexOf( new Complex128( 2.0, 2.0 ), -10 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex128( 4.0, 4.0 ), -10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.indexOf( new Complex64( 2.0, 2.0 ), -10 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Complex64( 4.0, 4.0 ), -10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js new file mode 100644 index 000000000000..1f60e5623868 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js @@ -0,0 +1,321 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `join` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'join' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.join ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `join` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'join' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.join ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.join.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.join.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `separator` argument which is not a string (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + 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() { + return arr.join( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `separator` argument which is not a string (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + 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() { + return arr.join( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex128)', function test( t ) { + var Complex128Array; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + str = arr.join(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex64)', function test( t ) { + var Complex64Array; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + str = arr.join(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array with elements separated by a separator (complex128)', function test( t ) { + var Complex128Array; + var expected; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i@-3 - 4i'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array with elements separated by a separator (complex64)', function test( t ) { + var Complex64Array; + var expected; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i@-3 - 4i'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array with elements separated by a separator (single element) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = new Complex128Array( [ 1, 2 ] ); + expected = '1 + 2i'; + str = arr.join(); + t.strictEqual( str, expected, 'returns expected value' ); + + arr = new Complex128Array( [ 1, 2 ] ); + expected = '1 + 2i'; + str = arr.join( '@' ); + t.strictEqual( str, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array with elements separated by a separator (single element) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = new Complex64Array( [ 1, 2 ] ); + expected = '1 + 2i'; + str = arr.join(); + t.strictEqual( str, expected, 'returns expected value' ); + + arr = new Complex64Array( [ 1, 2 ] ); + expected = '1 + 2i'; + str = arr.join( '@' ); + t.strictEqual( str, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if method invoked without a separator argument, the method returns a string representation of a complex number array with elements separated by a comma (complex128)', function test( t ) { + var Complex128Array; + var expected; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if method invoked without a separator argument, the method returns a string representation of a complex number array with elements separated by a comma (complex64)', function test( t ) { + var Complex64Array; + var expected; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.js new file mode 100644 index 000000000000..5fda8a3eecf8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.js @@ -0,0 +1,1331 @@ +/** +* @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 ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a string', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( value, Float32Array, Complex64, realf, imagf, reinterpret64 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( 'complex64', value, Complex64, realf, imagf, reinterpret64 ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( 'complex64', Float32Array, value, realf, imagf, reinterpret64 ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( 'complex64', Float32Array, Complex64, value, imagf, reinterpret64 ); + }; + } +}); + +tape( 'the function throws an error if provided a fifth argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( 'complex64', Float32Array, Complex64, realf, value, reinterpret64 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + factory( 'complex64', Float32Array, Complex64, realf, imagf, value ); + }; + } +}); + +tape( 'the function returns a function (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( typeof Complex64Array, 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the function returns a function (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( typeof Complex128Array, 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the returned constructor has the correct name (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( Complex64Array.name, 'Complex64Array', 'has correct name' ); + t.end(); +}); + +tape( 'the returned constructor has the correct name (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( Complex128Array.name, 'Complex128Array', 'has correct name' ); + t.end(); +}); + +tape( 'the returned constructor has the correct BYTES_PER_ELEMENT (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( Complex64Array.BYTES_PER_ELEMENT, 8, 'has correct BYTES_PER_ELEMENT' ); + t.end(); +}); + +tape( 'the returned constructor has the correct BYTES_PER_ELEMENT (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( Complex128Array.BYTES_PER_ELEMENT, 16, 'has correct BYTES_PER_ELEMENT' ); + t.end(); +}); + +tape( 'the returned constructor creates an empty array by default', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array(); + t.strictEqual( arr.length, 0, 'has length 0' ); + t.end(); +}); + +tape( 'the returned constructor creates an array of a specified length', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( 10 ); + t.strictEqual( arr.length, 10, 'has length 10' ); + t.end(); +}); + +tape( 'the returned constructor is a constructor (no new) (complex128)', function test( t ) { + var Complex128Array; + var ctor; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctor = Complex128Array; + + arr = ctor( 0 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor is a constructor (no new) (complex64)', function test( t ) { + var Complex64Array; + var ctor; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctor = Complex64Array; + + arr = ctor( 0 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (no argument) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array(); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (no argument) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array(); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (length) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( 10 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (length) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( 10 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (array) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( [] ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (array) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( [] ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (typed array) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( new Float64Array( 0 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (typed array) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( new Float32Array( 0 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (complex typed array) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( new Complex128Array( 0 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (complex typed array) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( new Complex64Array( 0 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (iterable) (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( createIterable() ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); + + function createIterable() { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +tape( 'the returned constructor returns an array (iterable) (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( createIterable() ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); + + function createIterable() { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return { + 'next': next + }; + } + + function next() { + return { + 'done': true + }; + } + } +}); + +tape( 'the returned constructor returns an array (ArrayBuffer) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( new ArrayBuffer( 0 ) ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (ArrayBuffer) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( new ArrayBuffer( 0 ) ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (ArrayBuffer, byte offset) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( new ArrayBuffer( 32 ), 16 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (ArrayBuffer, byte offset) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( new ArrayBuffer( 16 ), 8 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (ArrayBuffer, byte offset, length) (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var arr = new Complex128Array( new ArrayBuffer( 32 ), 16, 0 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor returns an array (ArrayBuffer, byte offset, length) (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var arr = new Complex64Array( new ArrayBuffer( 16 ), 8, 0 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor has a BYTES_PER_ELEMENT property (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( Complex128Array.BYTES_PER_ELEMENT, 16, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor has a BYTES_PER_ELEMENT property (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( Complex64Array.BYTES_PER_ELEMENT, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a BYTES_PER_ELEMENT property (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( Complex128Array.prototype.BYTES_PER_ELEMENT, 16, 'returns expected value' ); + + arr = new Complex128Array( 0 ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 16, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a BYTES_PER_ELEMENT property (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); + t.strictEqual( Complex64Array.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); + + arr = new Complex64Array( 0 ); + t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `buffer` property (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 0 ); + t.strictEqual( isArrayBuffer( arr.buffer ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `buffer` property (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 0 ); + t.strictEqual( isArrayBuffer( arr.buffer ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `byteLength` property (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = new Complex128Array( 0 ); + v = arr.byteLength; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 16 ); + v = arr.byteLength; + t.strictEqual( v, 112, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 128 ); + v = arr.byteLength; + t.strictEqual( v, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `byteLength` property (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = new Complex64Array( 0 ); + v = arr.byteLength; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 8 ); + v = arr.byteLength; + t.strictEqual( v, 56, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 64 ); + v = arr.byteLength; + t.strictEqual( v, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `byteOffset` property (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = new Complex128Array( 0 ); + v = arr.byteOffset; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 64 ); + v = arr.byteOffset; + t.strictEqual( v, 64, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 128 ); + v = arr.byteOffset; + t.strictEqual( v, 128, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `byteOffset` property (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = new Complex64Array( 0 ); + v = arr.byteOffset; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 32 ); + v = arr.byteOffset; + t.strictEqual( v, 32, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 64 ); + v = arr.byteOffset; + t.strictEqual( v, 64, 'returns expected value' ); + t.end(); +}); + +tape( 'the returned constructor instance has a `length` property (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = new Complex128Array(); + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex128Array( 10 ); + v = arr.length; + t.strictEqual( v, 10, 'returns expected value' ); + + arr = new Complex128Array( [] ); + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ) ] ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex128( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = new Complex128Array( [ z, 1.0 ] ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex128Array( new Float64Array( [ 1.0, 1.0 ] ) ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex128Array( new Complex128Array( [ 1.0, 1.0 ] ) ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 64 ); + v = arr.length; + t.strictEqual( v, 4, 'returns expected value' ); + + arr = new Complex128Array( new ArrayBuffer( 128 ), 64, 2 ); + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return real( z ); + }; + } +}); + +tape( 'the returned constructor instance has a `length` property (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = new Complex64Array(); + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex64Array( 10 ); + v = arr.length; + t.strictEqual( v, 10, 'returns expected value' ); + + arr = new Complex64Array( [] ); + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ) ] ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex64( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = new Complex64Array( [ z, 1.0 ] ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex64Array( new Float32Array( [ 1.0, 1.0 ] ) ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex64Array( new Complex64Array( [ 1.0, 1.0 ] ) ); + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 32 ); + v = arr.length; + t.strictEqual( v, 4, 'returns expected value' ); + + arr = new Complex64Array( new ArrayBuffer( 64 ), 32, 2 ); + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return realf( z ); + }; + } +}); + +tape( 'the returned constructor instance has a `length` property (iterable) (complex128)', function test( t ) { + var Complex128Array; + var iter1; + var iter2; + var arr; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = new Complex128Array( createIterable( iter1 ) ); + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = new Complex128Array( createIterable( iter2 ) ); + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex128( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } +}); + +tape( 'the returned constructor instance has a `length` property (iterable) (complex64)', function test( t ) { + var Complex64Array; + var iter1; + var iter2; + var arr; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + iter1 = { + 'next': next1, + 'i': 0, + 'N': 4 + }; + arr = new Complex64Array( createIterable( iter1 ) ); + v = arr.length; + t.strictEqual( v, iter1.N, 'returns expected value' ); + + iter2 = { + 'next': next2, + 'i': 0, + 'N': 4 + }; + arr = new Complex64Array( createIterable( iter2 ) ); + v = arr.length; + t.strictEqual( v, iter2.N, 'returns expected value' ); + + t.end(); + + function createIterable( iterator ) { + var it = {}; + it[ ITERATOR_SYMBOL ] = iterable; + return it; + + function iterable() { + return iterator; + } + } + + function next1() { + iter1.i += 1; + if ( iter1.i <= iter1.N ) { + return { + 'value': [ 1.0, 1.0 ] + }; + } + return { + 'done': true + }; + } + + function next2() { + iter2.i += 1; + if ( iter2.i <= iter2.N ) { + return { + 'value': new Complex64( 1.0, 1.0 ) + }; + } + return { + 'done': true + }; + } +}); + +tape( 'the returned constructor throws an error if provided an ArrayBuffer whose byte length is not a multiple of BYTES_PER_ELEMENT (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ 1, 2, 3, 4, 5, 6, 7, 9, 24, 74, 801 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex128Array( new ArrayBuffer( value ) ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided an ArrayBuffer whose byte length is not a multiple of BYTES_PER_ELEMENT (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ 1, 2, 3, 5, 6, 7, 9, 13, 801 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex64Array( new ArrayBuffer( value ) ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided an array-like object having an odd length (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + [ 1, 2, 3 ], + new Float64Array( [ 1, 2, 3 ] ), + { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + } + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having odd length' ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex128Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided an array-like object having an odd length (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + [ 1, 2, 3 ], + new Float32Array( [ 1, 2, 3 ] ), + { + 'length': 3, + '0': 1, + '1': 2, + '2': 3 + } + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having odd length' ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex64Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a non-iterable object (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + {}, + { + '0': 1, + '1': 2, + '2': 3 + } + ]; + 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() { + return new Complex128Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a non-iterable object (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + {}, + { + '0': 1, + '1': 2, + '2': 3 + } + ]; + 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() { + return new Complex64Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + 3.14, + -1, + 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() { + return new Complex128Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + 3.14, + -1, + 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() { + return new Complex64Array( value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + 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() { + return new Complex128Array( value, 0 ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + 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() { + return new Complex64Array( value, 0 ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a byte offset which is not a nonnegative integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + -1, + 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() { + return new Complex128Array( new ArrayBuffer( 128 ), value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a byte offset which is not a nonnegative integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + -1, + 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() { + return new Complex64Array( new ArrayBuffer( 64 ), value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a byte offset which is not a multiple of BYTES_PER_ELEMENT (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ 1, 2, 3, 4, 5, 6, 7, 9, 24, 65, 78, 801 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex128Array( new ArrayBuffer( 1024 ), value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a byte offset which is not a multiple of BYTES_PER_ELEMENT (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ 1, 2, 3, 5, 6, 7, 9, 13, 801 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex64Array( new ArrayBuffer( 1024 ), value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a length argument which is not a nonnegative integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + -1, + 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() { + return new Complex128Array( new ArrayBuffer( 128 ), 0, value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided a length argument which is not a nonnegative integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + -1, + 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() { + return new Complex64Array( new ArrayBuffer( 64 ), 0, value ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ 16, 24, 32, 48 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex128Array( new ArrayBuffer( 100 ), value, 1e3 ); + }; + } +}); + +tape( 'the returned constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ 8, 16, 24, 32 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Complex64Array( new ArrayBuffer( 50 ), value, 1e3 ); + }; + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js new file mode 100644 index 000000000000..d19b00c8003c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js @@ -0,0 +1,472 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `keys` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'keys' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.keys ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `keys` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'keys' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.keys ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.keys.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.keys.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var it; + var i; + var r; + var e; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + expected = [ + { + 'value': 0, + 'done': false + }, + { + 'value': 1, + 'done': false + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( r.value, e.value, 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + t.end(); +}); + +tape( 'the method returns an iterator protocol-compliant object (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var it; + var i; + var r; + var e; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + expected = [ + { + 'value': 0, + 'done': false + }, + { + 'value': 1, + 'done': false + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( r.value, e.value, 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var it; + var i; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [] ); + expected = [ + { + 'done': true + }, + { + 'done': true + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var it; + var i; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [] ); + expected = [ + { + 'done': true + }, + { + 'done': true + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'beep' ); + t.strictEqual( v.value, 'beep', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'beep' ); + t.strictEqual( v.value, 'beep', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it1 = arr.keys(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( v1, v2, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it1 = arr.keys(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( v1, v2, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js new file mode 100644 index 000000000000..8705e8b5d739 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js @@ -0,0 +1,475 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `lastIndexOf` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'lastIndexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.lastIndexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `lastIndexOf` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'lastIndexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.lastIndexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.lastIndexOf.call( value, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.lastIndexOf.call( value, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.lastIndexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.lastIndexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.lastIndexOf( new Complex128( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.lastIndexOf( new Complex64( 1.0, 1.0 ), value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var idx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var idx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a complex number is not found (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a complex number is not found (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ) ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ) ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 3.0, 3.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 4 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 2 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex128( 3.0, 3.0 ), 1 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 3.0, 3.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 4 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 2 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex64( 3.0, 3.0 ), 1 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), -3 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex128( 3.0, 3.0 ), -1 ); + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative) (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), -3 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex64( 3.0, 3.0 ), -1 ); + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element (complex128)', function test( t ) { + var Complex128Array; + var idx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 10 ); + t.strictEqual( idx, 4, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex128( 4.0, 4.0 ), 10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element (complex64)', function test( t ) { + var Complex64Array; + var idx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + arr.set( [ 1.0, 1.0 ], 0 ); + arr.set( [ 2.0, 2.0 ], 1 ); + arr.set( [ 3.0, 3.0 ], 2 ); + arr.set( [ 2.0, 2.0 ], 3 ); + arr.set( [ 2.0, 2.0 ], 4 ); + + idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 10 ); + t.strictEqual( idx, 4, 'returns expected value' ); + + idx = arr.lastIndexOf( new Complex64( 4.0, 4.0 ), 10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js new file mode 100644 index 000000000000..ac3e92e517eb --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js @@ -0,0 +1,455 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var identity = require( '@stdlib/utils/identity-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `map` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'map' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.map ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `map` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'map' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.map ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.map.call( value, identity ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.map.call( value, identity ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.map( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.map( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.map( identity ); + + t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.map( identity ); + + t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.end(); +}); + +tape( 'the method returns a new complex number array containing elements which are the result of a callback function (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function scale( v ) { + return new Complex128( real( v )*2.0, imag( v )*2.0 ); + } +}); + +tape( 'the method returns a new complex number array containing elements which are the result of a callback function (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function scale( v ) { + return new Complex64( realf( v )*2.0, imagf( v )*2.0 ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + var ctx; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.map( scale, ctx ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function scale( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return new Complex128( real( v )*3.0, imag( v )*3.0 ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + var ctx; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); + ctx = { + 'count': 0 + }; + actual = arr.map( scale, ctx ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function scale( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return new Complex64( realf( v )*3.0, imagf( v )*3.0 ); + } +}); + +tape( 'the method supports a map function which returns a two-element array containing a real and an imaginary component (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function scale( v ) { + return [ real( v )*2.0, imag( v )*2.0 ]; + } +}); + +tape( 'the method supports a map function which returns a two-element array containing a real and an imaginary component (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); + + function scale( v ) { + return [ realf( v )*2.0, imagf( v )*2.0 ]; + } +}); + +tape( 'the method throws an error if provided a map function which does not return a complex number or an array of length 2 containing real and imaginary components (complex128)', function test( t ) { + var Complex128Array; + var clbks; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + clbks = [ + clbk1, + clbk2, + clbk3, + clbk4, + clbk5 + ]; + for ( i = 0; i < clbks.length; i++ ) { + t.throws( badValue( clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( clbk ) { + return function badValue() { + return arr.map( clbk ); + }; + } + + function clbk1() { + return 1.0; + } + + function clbk2() { + return {}; + } + + function clbk3() { + return [ 1.0, 2.0, 3.0 ]; + } + + function clbk4() { + return []; + } + + function clbk5() { + return [ 1.0 ]; + } +}); + +tape( 'the method throws an error if provided a map function which does not return a complex number or an array of length 2 containing real and imaginary components (complex64)', function test( t ) { + var Complex64Array; + var clbks; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + clbks = [ + clbk1, + clbk2, + clbk3, + clbk4, + clbk5 + ]; + for ( i = 0; i < clbks.length; i++ ) { + t.throws( badValue( clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( clbk ) { + return function badValue() { + return arr.map( clbk ); + }; + } + + function clbk1() { + return 1.0; + } + + function clbk2() { + return {}; + } + + function clbk3() { + return [ 1.0, 2.0, 3.0 ]; + } + + function clbk4() { + return []; + } + + function clbk5() { + return [ 1.0 ]; + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js new file mode 100644 index 000000000000..8591c0de9e75 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js @@ -0,0 +1,293 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the returned constructor is an `of` method for creating a complex number array from a variable number of arguments (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + t.strictEqual( hasOwnProp( Complex128Array, 'of' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.of ), true, 'has method' ); + + arr = Complex128Array.of(); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'attached to the returned constructor is an `of` method for creating a complex number array from a variable number of arguments (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + t.strictEqual( hasOwnProp( Complex64Array, 'of' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.of ), true, 'has method' ); + + arr = Complex64Array.of(); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a constructor (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex128Array.of.call( value, 1.0, 1.0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a constructor (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return Complex64Array.of.call( value, 1.0, 1.0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor (complex128)', function test( t ) { + var Complex128Array; + var values; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + values = [ + Complex128, + 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() { + return Complex128Array.of.call( value, 1.0, 1.0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor (complex64)', function test( t ) { + var Complex64Array; + var values; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + values = [ + Complex64, + 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() { + return Complex64Array.of.call( value, 1.0, 1.0 ); + }; + } +}); + +tape( 'the method returns a complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var z; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + // No arguments: + arr = Complex128Array.of(); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + // Interleaved real and imaginary components: + arr = Complex128Array.of( 1.0, 2.0, 3.0, 4.0 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Complex numbers: + z = new Complex128( 1.0, 1.0 ); + arr = Complex128Array.of( z, z, z, z, z ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 5, 'returns expected value' ); + + // Mixed arguments: + z = new Complex128( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex128Array.of( z, 1.0 ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex128( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex128Array.of( 1.0, z ); + t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return real( z ); + }; + } +}); + +tape( 'the method returns a complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var z; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + // No arguments: + arr = Complex64Array.of(); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 0, 'returns expected value' ); + + // Interleaved real and imaginary components: + arr = Complex64Array.of( 1.0, 2.0, 3.0, 4.0 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 2, 'returns expected value' ); + + // Complex numbers: + z = new Complex64( 1.0, 1.0 ); + arr = Complex64Array.of( z, z, z, z, z ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 5, 'returns expected value' ); + + // Mixed arguments: + z = new Complex64( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex64Array.of( z, 1.0 ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + z = new Complex64( 1.0, 0.0 ); + z.valueOf = valueOf( z ); + arr = Complex64Array.of( 1.0, z ); + t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); + + v = arr.length; + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); + + function valueOf( z ) { + return function valueOf() { + return realf( z ); + }; + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js new file mode 100644 index 000000000000..d582a034f670 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js @@ -0,0 +1,422 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var cadd128 = require( '@stdlib/complex/float64/base/add' ); +var cadd64 = require( '@stdlib/complex/float32/base/add' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reduce` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduce' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.reduce ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reduce` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduce' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.reduce ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.reduce.call( value, cadd128 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.reduce.call( value, cadd64 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.reduce( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.reduce( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 0 ); + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + arr.reduce( cadd128 ); + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 0 ); + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + arr.reduce( cadd64 ); + } +}); + +tape( 'the method uses the first element of the array as the initial value when an initial value is not provided (complex128)', function test( t ) { + var Complex128Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + accArray = [ 1.0, -1.0, 3.0, -3.0 ]; + valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; + expected = new Complex128( 6.0, -6.0 ); + actual = arr.reduce( reducer ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(index-1); + t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd128( acc, value ); + } +}); + +tape( 'the method uses the first element of the array as the initial value when an initial value is not provided (complex64)', function test( t ) { + var Complex64Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + accArray = [ 1.0, -1.0, 3.0, -3.0 ]; + valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; + expected = new Complex64( 6.0, -6.0 ); + actual = arr.reduce( reducer ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(index-1); + t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd64( acc, value ); + } +}); + +tape( 'the method supports providing an initial value as the second argument (complex128)', function test( t ) { + var Complex128Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; + valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + expected = new Complex128( 8.0, -8.0 ); + actual = arr.reduce( reducer, new Complex128( 2.0, -2.0 ) ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( acc ), accArray[ 2*index ], 'returns expected value' ); + t.strictEqual( imag( acc ), accArray[ (2*index)+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( value ), valueArray[ 2*index ], 'returns expected value' ); + t.strictEqual( imag( value ), valueArray[ (2*index)+1 ], 'returns expected value' ); + return cadd128( acc, value ); + } +}); + +tape( 'the method supports providing an initial value as the second argument (complex64)', function test( t ) { + var Complex64Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; + valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + expected = new Complex64( 8.0, -8.0 ); + actual = arr.reduce( reducer, new Complex64( 2.0, -2.0 ) ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( acc ), accArray[ 2*index ], 'returns expected value' ); + t.strictEqual( imagf( acc ), accArray[ (2*index)+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( value ), valueArray[ 2*index ], 'returns expected value' ); + t.strictEqual( imagf( value ), valueArray[ (2*index)+1 ], 'returns expected value' ); + return cadd64( acc, value ); + } +}); + +tape( 'the method returns the accumulated result (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Complex128( 6.0, -6.0 ); + actual = arr.reduce( cadd128 ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the accumulated result (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Complex64( 6.0, -6.0 ); + actual = arr.reduce( cadd64 ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports returning real-valued results (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = 6.0; + actual = arr.reduce( reducer, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); + + function reducer( acc, value ) { + return acc + real( value ); + } +}); + +tape( 'the method supports returning real-valued results (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = 6.0; + actual = arr.reduce( reducer, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); + + function reducer( acc, value ) { + return acc + realf( value ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js new file mode 100644 index 000000000000..e820e5659608 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js @@ -0,0 +1,432 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var cadd128 = require( '@stdlib/complex/float64/base/add' ); +var cadd64 = require( '@stdlib/complex/float32/base/add' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reduceRight` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduceRight' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.reduceRight ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reduceRight` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduceRight' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.reduceRight ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.reduceRight.call( value, cadd128 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.reduceRight.call( value, cadd64 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.reduceRight( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.reduceRight( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 0 ); + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + arr.reduceRight( cadd128 ); + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 0 ); + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + arr.reduceRight( cadd64 ); + } +}); + +tape( 'the method uses the last element of the array as the initial value when an initial value is not provided (complex128)', function test( t ) { + var Complex128Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + var len; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + len = arr.length; + accArray = [ 3.0, -3.0, 5.0, -5.0 ]; + valueArray = [ 2.0, -2.0, 1.0, -1.0 ]; + expected = new Complex128( 6.0, -6.0 ); + actual = arr.reduceRight( reducer ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(len-index-2); + t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd128( acc, value ); + } +}); + +tape( 'the method uses the last element of the array as the initial value when an initial value is not provided (complex64)', function test( t ) { + var Complex64Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + var len; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + len = arr.length; + accArray = [ 3.0, -3.0, 5.0, -5.0 ]; + valueArray = [ 2.0, -2.0, 1.0, -1.0 ]; + expected = new Complex64( 6.0, -6.0 ); + actual = arr.reduceRight( reducer ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(len-index-2); + t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd64( acc, value ); + } +}); + +tape( 'the method supports providing an initial value as the second argument (complex128)', function test( t ) { + var Complex128Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + var len; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + len = arr.length; + accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; + valueArray = [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ]; + expected = new Complex128( 8.0, -8.0 ); + actual = arr.reduceRight( reducer, new Complex128( 2.0, -2.0 ) ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(len-index-1); + t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd128( acc, value ); + } +}); + +tape( 'the method supports providing an initial value as the second argument (complex64)', function test( t ) { + var Complex64Array; + var valueArray; + var accArray; + var expected; + var actual; + var arr; + var len; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + len = arr.length; + accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; + valueArray = [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ]; + expected = new Complex64( 8.0, -8.0 ); + actual = arr.reduceRight( reducer, new Complex64( 2.0, -2.0 ) ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = 2*(len-index-1); + t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); + t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); + t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); + return cadd64( acc, value ); + } +}); + +tape( 'the method returns the accumulated result (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Complex128( 6.0, -6.0 ); + actual = arr.reduceRight( cadd128 ); + + t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); + t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); + t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the accumulated result (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Complex64( 6.0, -6.0 ); + actual = arr.reduceRight( cadd64 ); + + t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); + t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); + t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports returning real-valued results (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = 6.0; + actual = arr.reduceRight( reducer, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); + + function reducer( acc, value ) { + return acc + real( value ); + } +}); + +tape( 'the method supports returning real-valued results (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = 6.0; + actual = arr.reduceRight( reducer, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); + + function reducer( acc, value ) { + return acc + realf( value ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js new file mode 100644 index 000000000000..eb915cd4fcc1 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js @@ -0,0 +1,216 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reverse` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reverse' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.reverse ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `reverse` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reverse' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.reverse ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.reverse.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.reverse.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.reverse(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.reverse(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method reverses elements of a complex number array in-place (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); + out = arr.reverse(); + + t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method reverses elements of a complex number array in-place (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); + out = arr.reverse(); + + t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + out = arr.reverse(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + out = arr.reverse(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js new file mode 100644 index 000000000000..2c21bc1aeb2c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js @@ -0,0 +1,1464 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `set` method for setting one or more array elements (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.set ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `set` method for setting one or more array elements (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'set' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.set ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.set.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.set.call( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + 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() { + return arr.set( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + 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() { + return arr.set( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (index argument) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + 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() { + return arr.set( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (index argument) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + 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() { + return arr.set( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not a nonnegative integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + 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() { + return arr.set( new Complex128( 1.0, -1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is not a nonnegative integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + 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() { + return arr.set( new Complex64( 1.0, -1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex number) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + arr.length, + arr.length + 1, + arr.length + 2, + arr.length + 3 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( new Complex128( 1.0, -1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex number) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + arr.length, + arr.length + 1, + arr.length + 2, + arr.length + 3 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( new Complex64( 1.0, -1.0 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex typed array) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr1; + var arr2; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr1 = new Complex128Array( 10 ); + arr2 = new Complex128Array( 10 ); + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex typed array) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr1; + var arr2; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr1 = new Complex64Array( 10 ); + arr2 = new Complex64Array( 10 ); + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing complex numbers) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr1; + var arr2; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr1 = new Complex128Array( 10 ); + arr2 = []; + for ( i = 0; i < arr1.length; i++ ) { + arr2.push( new Complex128( i, -i ) ); + } + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing complex numbers) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr1; + var arr2; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr1 = new Complex64Array( 10 ); + arr2 = []; + for ( i = 0; i < arr1.length; i++ ) { + arr2.push( new Complex64( i, -i ) ); + } + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing interleaved components) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr1; + var arr2; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr1 = new Complex128Array( 10 ); + arr2 = []; + for ( i = 0; i < arr1.length; i++ ) { + arr2.push( i ); + arr2.push( -i ); + } + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing interleaved components) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr1; + var arr2; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr1 = new Complex64Array( 10 ); + arr2 = []; + for ( i = 0; i < arr1.length; i++ ) { + arr2.push( i ); + arr2.push( -i ); + } + + values = [ + 1, + 2, + 3, + 4, + 5 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr1.set( arr2, value ); + }; + } +}); + +tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + [ 1 ], + [ 1, 2, 3 ], + [ 1, 2, 3, 4, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( value ); + }; + } +}); + +tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + [ 1 ], + [ 1, 2, 3 ], + [ 1, 2, 3, 4, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( value ); + }; + } +}); + +tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (index argument) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + [ 1 ], + [ 1, 2, 3 ], + [ 1, 2, 3, 4, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( value, 0 ); + }; + } +}); + +tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (index argument) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + [ 1 ], + [ 1, 2, 3 ], + [ 1, 2, 3, 4, 5 ], + [ 1, 2, 3, 4, 5, 6, 7 ] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.set( value, 0 ); + }; + } +}); + +tape( 'the method sets an array element (complex number) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + arr.set( new Complex128( 20.0, -20.0 ) ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), 20.0, 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), -20.0, 'returns expected imaginary component for index '+0 ); + + arr.set( new Complex128( 0.0, 0.0 ) ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); + + arr.set( new Complex128( i, -i ), i ); + + v = arr.get( i ); + t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); + } + t.end(); +}); + +tape( 'the method sets an array element (complex number) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + arr.set( new Complex64( 20.0, -20.0 ) ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), 20.0, 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), -20.0, 'returns expected imaginary component for index '+0 ); + + arr.set( new Complex64( 0.0, 0.0 ) ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+i ); + + arr.set( new Complex64( i, -i ), i ); + + v = arr.get( i ); + t.strictEqual( realf( v ), i, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), -i, 'returns expected imaginary component for index '+i ); + } + t.end(); +}); + +tape( 'the method sets an array element (complex typed array) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( new Complex128Array( buf ) ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( new Complex128Array( buf ) ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( new Complex128Array( buf ), i ); + + v = arr.get( i ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( new Complex128Array( buf ) ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( new Complex128Array( buf ), 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (complex typed array) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( new Complex64Array( buf ) ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( new Complex64Array( buf ) ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( new Complex64Array( buf ), i ); + + v = arr.get( i ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( new Complex64Array( buf ) ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( new Complex64Array( buf ), 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (array-like object containing complex numbers) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( [ new Complex128( buf[0], buf[1] ) ] ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( [ new Complex128( buf[0], buf[1] ) ] ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( [ new Complex128( buf[ 0 ], buf[ 1 ] ) ], i ); + + v = arr.get( i ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( [ new Complex128( buf[0], buf[1] ), new Complex128( buf[2], buf[3] ) ] ); // eslint-disable-line max-len + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( [ new Complex128( buf[0], buf[1] ), new Complex128( buf[2], buf[3] ) ], 2 ); // eslint-disable-line max-len + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (array-like object containing complex numbers) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( [ new Complex64( buf[0], buf[1] ) ] ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( [ new Complex64( buf[0], buf[1] ) ] ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( [ new Complex64( buf[ 0 ], buf[ 1 ] ) ], i ); + + v = arr.get( i ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( [ new Complex64( buf[0], buf[1] ), new Complex64( buf[2], buf[3] ) ] ); // eslint-disable-line max-len + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( [ new Complex64( buf[0], buf[1] ), new Complex64( buf[2], buf[3] ) ], 2 ); // eslint-disable-line max-len + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (array-like object containing interleaved components) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( buf ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( buf ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( buf, i ); + + v = arr.get( i ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( buf ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( buf, 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (array-like object containing interleaved components) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+0 ); + + // No index argument: + buf = [ 20.0, -20.0 ]; + arr.set( buf ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + buf = [ 0.0, 0.0 ]; + arr.set( buf ); + + // Index argument: + for ( i = 0; i < arr.length; i++ ) { + v = arr.get( i ); + t.strictEqual( realf( v ), 0.0, 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), 0.0, 'returns expected imaginary component for index '+i ); + + buf = [ i, -i ]; + arr.set( buf, i ); + + v = arr.get( i ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+i ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); + } + + // Multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + arr.set( buf ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + arr.set( buf, 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (complex typed array; shared buffer) (complex128)', function test( t ) { + var Complex128Array; + var byteOffset; + var arr; + var src; + var buf; + var ab; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + byteOffset = 224; // 14 * 16 + + ab = new ArrayBuffer( 480 ); // 30 * 16 + arr = new Complex128Array( ab, byteOffset, 10 ); + + // Overlapping (requires copy), multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + src = new Complex128Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (requires copy), multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + src = new Complex128Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + // Overlapping (no copy), multiple values, no index argument: + buf = [ 25.0, -25.0, -45.0, 45.0 ]; + src = new Complex128Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (no copy), multiple values, index argument: + buf = [ -105.0, -205.0, -305.0, -405.0 ]; + src = new Complex128Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (complex typed array; shared buffer) (complex64)', function test( t ) { + var Complex64Array; + var byteOffset; + var arr; + var src; + var buf; + var ab; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + byteOffset = 112; // 14 * 8 + + ab = new ArrayBuffer( 240 ); // 30 * 8 + arr = new Complex64Array( ab, byteOffset, 10 ); + + // Overlapping (requires copy), multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + src = new Complex64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (requires copy), multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + src = new Complex64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + // Overlapping (no copy), multiple values, no index argument: + buf = [ 25.0, -25.0, -45.0, 45.0 ]; + src = new Complex64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (no copy), multiple values, index argument: + buf = [ -105.0, -205.0, -305.0, -405.0 ]; + src = new Complex64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); + src.set( buf ); + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (typed array; shared buffer) (complex128)', function test( t ) { + var Complex128Array; + var byteOffset; + var arr; + var src; + var buf; + var ab; + var v; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + byteOffset = 224; // 14 * 16 + + ab = new ArrayBuffer( 480 ); // 30 * 16 + arr = new Complex128Array( ab, byteOffset, 10 ); + + // Overlapping (requires copy), multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + src = new Float64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (requires copy), multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + // Overlapping (no copy), multiple values, no index argument: + buf = [ 25.0, -25.0, -45.0, 45.0 ]; + src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (no copy), multiple values, index argument: + buf = [ -105.0, -205.0, -305.0, -405.0 ]; + src = new Float64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); + +tape( 'the method sets an array element (typed array; shared buffer) (complex64)', function test( t ) { + var Complex64Array; + var byteOffset; + var arr; + var src; + var buf; + var ab; + var v; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + byteOffset = 112; // 14 * 8 + + ab = new ArrayBuffer( 240 ); // 30 * 8 + arr = new Complex64Array( ab, byteOffset, 10 ); + + // Overlapping (requires copy), multiple values, no index argument: + buf = [ 20.0, -20.0, -40.0, 40.0 ]; + src = new Float32Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (requires copy), multiple values, index argument: + buf = [ -100.0, -200.0, -300.0, -400.0 ]; + src = new Float32Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + // Overlapping (no copy), multiple values, no index argument: + buf = [ 25.0, -25.0, -45.0, 45.0 ]; + src = new Float32Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src ); + + v = arr.get( 0 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+0 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); + + v = arr.get( 1 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+1 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); + + // Overlapping (no copy), multiple values, index argument: + buf = [ -105.0, -205.0, -305.0, -405.0 ]; + src = new Float32Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 4 ); + for ( i = 0; i < buf.length; i++ ) { + src[ i ] = buf[ i ]; + } + arr.set( src, 2 ); + + v = arr.get( 2 ); + t.strictEqual( realf( v ), buf[ 0 ], 'returns expected real component for index '+2 ); + t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); + + v = arr.get( 3 ); + t.strictEqual( realf( v ), buf[ 2 ], 'returns expected real component for index '+3 ); + t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js new file mode 100644 index 000000000000..72143acec4fc --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js @@ -0,0 +1,560 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `slice` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'slice' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.slice ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `slice` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'slice' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.slice ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.slice.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.slice.call( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.slice( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.slice( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.slice( 0, value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.slice( 0, value ); + }; + } +}); + +tape( 'the method returns an empty typed array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.slice(); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.slice(); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice(); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice(); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( 1 ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( 1 ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( 1, 3 ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + actual = arr.slice( 1, 30 ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( 1, 3 ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + actual = arr.slice( 1, 30 ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method resolves negative indices relative to the last element (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( -3, -1 ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + actual = arr.slice( -30, -2 ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method resolves negative indices relative to the last element (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.slice( -3, -1 ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + actual = arr.slice( -30, -2 ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + actual = arr.slice( 2, 0 ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + actual = arr.slice( 2, 0 ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + actual = arr.slice( 5 ); + + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + actual = arr.slice( 5 ); + + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + + actual = arr.slice( 2, -8 ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + + actual = arr.slice( 1, 0 ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + + actual = arr.slice( 2, -8 ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + + actual = arr.slice( 1, 0 ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js new file mode 100644 index 000000000000..21c5d52750e7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js @@ -0,0 +1,391 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `some` method for returning a boolean indicating whether at least one element passes a test (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'some' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.some ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `some` method for returning a boolean indicating whether at least one element passes a test (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'some' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.some ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.some.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( real( v ) > 0 && imag( v ) < 0 ); + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.some.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( realf( v ) > 0 && imagf( v ) < 0 ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.some( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.some( value ); + }; + } +}); + +tape( 'the method returns `false` if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `false` if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if at least one element passes a test (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 1.0, 2.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `true` if at least one element passes a test (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 1.0, 2.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method returns `false` if all elements fail a test (complex128)', function test( t ) { + var Complex128Array; + var bool; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( real( v ) === imag( v ) ); + } +}); + +tape( 'the method returns `false` if all elements fail a test (complex64)', function test( t ) { + var Complex64Array; + var bool; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + bool = arr.some( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( realf( v ) === imagf( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex128)', function test( t ) { + var Complex128Array; + var bool; + var ctx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + bool = arr.some( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method supports providing an execution context (complex64)', function test( t ) { + var Complex64Array; + var bool; + var ctx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); + bool = arr.some( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); + +tape( 'the method stops executing upon encountering the first element which passes a test (complex128)', function test( t ) { + var Complex128Array; + var bool; + var ctx; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + ctx = { + 'count': 0 + }; + arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + bool = arr.some( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imag( v ) === real( v ) ); + } +}); + +tape( 'the method stops executing upon encountering the first element which passes a test (complex64)', function test( t ) { + var Complex64Array; + var bool; + var ctx; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + ctx = { + 'count': 0 + }; + arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + bool = arr.some( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( imagf( v ) === realf( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js new file mode 100644 index 000000000000..b4dba214873b --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js @@ -0,0 +1,347 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128 values. +* +* @private +* @param {Complex128} a - first value for comparison +* @param {Complex128} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64 values. +* +* @private +* @param {Complex64} a - first value for comparison +* @param {Complex64} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `sort` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'sort' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.sort ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `sort` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'sort' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.sort ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.sort.call( value, compareFcn128 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.sort.call( value, compareFcn64 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.sort( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.sort( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.sort( compareFcn128 ); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.sort( compareFcn64 ); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method sorts elements of a complex number array in-place (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.sort( compareFcn128 ); + + t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method sorts elements of a complex number array in-place (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.sort( compareFcn64 ); + + t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.sort( compareFcn128 ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.sort( compareFcn64 ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js new file mode 100644 index 000000000000..806702b3522b --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js @@ -0,0 +1,560 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `subarray` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'subarray' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.subarray ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `subarray` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'subarray' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.subarray ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.subarray.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.subarray.call( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.subarray( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.subarray( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.subarray( 0, value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.subarray( 0, value ); + }; + } +}); + +tape( 'the method returns empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.subarray(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.subarray(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'if called without arguments, the method returns a view containing the same elements as the original array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray(); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called without arguments, the method returns a view containing the same elements as the original array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray(); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( 1 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( 1 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive) (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( 1, 3 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive) (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( 1, 3 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method resolves negative indices relative to the last element (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + + expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( -3, -1 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + actual = arr.subarray( -30, -2 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method resolves negative indices relative to the last element (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + + expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); + actual = arr.subarray( -3, -1 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + actual = arr.subarray( -30, -2 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + actual = arr.subarray( 2, 0 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + actual = arr.subarray( 2, 0 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + actual = arr.subarray( 5 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + actual = arr.subarray( 5 ); + + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero (complex128)', function test( t ) { + var Complex128Array; + var expected; + var actual; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float64Array( [] ); + + actual = arr.subarray( 2, -8 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + + actual = arr.subarray( 1, 0 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero (complex64)', function test( t ) { + var Complex64Array; + var expected; + var actual; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); + expected = new Float32Array( [] ); + + actual = arr.subarray( 2, -8 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + + actual = arr.subarray( 1, 0 ); + t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js new file mode 100644 index 000000000000..c171f9b0c8bc --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js @@ -0,0 +1,375 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toLocaleString` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toLocaleString' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.toLocaleString ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toLocaleString` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toLocaleString' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.toLocaleString ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.toLocaleString.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.toLocaleString.call( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [ 1, 2, 3 ], + 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() { + return arr.toLocaleString( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [ 1, 2, 3 ], + 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() { + return arr.toLocaleString( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options) (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [ 1, 2, 3 ], + 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() { + return arr.toLocaleString( value, {} ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options) (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [ 1, 2, 3 ], + 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() { + return arr.toLocaleString( value, {} ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an object (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + 'beep', + [], + 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() { + return arr.toLocaleString( 'en-GB', value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an object (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + 'beep', + [], + 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() { + return arr.toLocaleString( 'en-GB', value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex128)', function test( t ) { + var Complex128Array; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + str = arr.toLocaleString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex64)', function test( t ) { + var Complex64Array; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + str = arr.toLocaleString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.toLocaleString(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.toLocaleString(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js new file mode 100644 index 000000000000..adeb1f0f5709 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js @@ -0,0 +1,214 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toReversed` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toReversed' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.toReversed ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toReversed` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toReversed' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.toReversed ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.toReversed.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.toReversed.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.toReversed(); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.toReversed(); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in reverse order (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); + out = arr.toReversed(); + + t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in reverse order (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); + out = arr.toReversed(); + + t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + out = arr.toReversed(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + out = arr.toReversed(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js new file mode 100644 index 000000000000..28a690f01e1c --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js @@ -0,0 +1,345 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Comparison function for complex128 values. +* +* @private +* @param {Complex128} a - first value for comparison +* @param {Complex128} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn128( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = real( a ); + re2 = real( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imag( a ); + im2 = imag( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + +/** +* Comparison function for complex64 values. +* +* @private +* @param {Complex64} a - first value for comparison +* @param {Complex64} b - second value for comparison +* @returns {number} comparison result +*/ +function compareFcn64( a, b ) { + var re1; + var re2; + var im1; + var im2; + re1 = realf( a ); + re2 = realf( b ); + if ( re1 < re2 ) { + return -1; + } + if ( re1 > re2 ) { + return 1; + } + im1 = imagf( a ); + im2 = imagf( b ); + if ( im1 < im2 ) { + return -1; + } + if ( im1 > im2 ) { + return 1; + } + return 0; +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toSorted` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toSorted' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.toSorted ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toSorted` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toSorted' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.toSorted ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.toSorted.call( value, compareFcn128 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.toSorted.call( value, compareFcn64 ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.toSorted( value ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + 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() { + return arr.toSorted( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + out = arr.toSorted( compareFcn128 ); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty array if operating on an empty complex number array (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + out = arr.toSorted( compareFcn64 ); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in sorted order (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); + expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.toSorted( compareFcn128 ); + + t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in sorted order (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); + expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.toSorted( compareFcn64 ); + + t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, expected.length/2, 'returns expected value' ); + t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.toSorted( compareFcn128 ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + out = arr.toSorted( compareFcn64 ); + + t.strictEqual( out.length, arr.length, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js new file mode 100644 index 000000000000..b458f55ace04 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js @@ -0,0 +1,183 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toString` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.toString ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `toString` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toString' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.toString ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.toString.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.toString.call( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex128)', function test( t ) { + var Complex128Array; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array(); + str = arr.toString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns an empty string if invoked on an empty array (complex64)', function test( t ) { + var Complex64Array; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array(); + str = arr.toString(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array (complex128)', function test( t ) { + var Complex128Array; + var expected; + var str; + var arr; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.toString(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a complex number array (complex64)', function test( t ) { + var Complex64Array; + var expected; + var str; + var arr; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1, 2, -3, -4 ] ); + expected = '1 + 2i,-3 - 4i'; + + str = arr.toString(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js new file mode 100644 index 000000000000..71e8279147b0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js @@ -0,0 +1,498 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isComplex128 = require( '@stdlib/assert/is-complex128' ); +var isComplex64 = require( '@stdlib/assert/is-complex64' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `values` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'values' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.values ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `values` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'values' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.values ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.values.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.values.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var it; + var i; + var r; + var e; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + expected = [ + { + 'value': new Complex128( 1.0, -1.0 ), + 'done': false + }, + { + 'value': new Complex128( 2.0, -2.0 ), + 'done': false + }, + { + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( isComplex128( r.value ), true, 'returns expected value' ); + t.strictEqual( real( r.value ), real( e.value ), 'returns expected value' ); + t.strictEqual( imag( r.value ), imag( e.value ), 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + t.end(); +}); + +tape( 'the method returns an iterator protocol-compliant object (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var it; + var i; + var r; + var e; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + expected = [ + { + 'value': new Complex64( 1.0, -1.0 ), + 'done': false + }, + { + 'value': new Complex64( 2.0, -2.0 ), + 'done': false + }, + { + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( isComplex64( r.value ), true, 'returns expected value' ); + t.strictEqual( realf( r.value ), realf( e.value ), 'returns expected value' ); + t.strictEqual( imagf( r.value ), imagf( e.value ), 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var it; + var i; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [] ); + expected = [ + { + 'done': true + }, + { + 'done': true + }, + { + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var it; + var i; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [] ); + expected = [ + { + 'done': true + }, + { + 'done': true + }, + { + 'done': true + } + ]; + it = arr.values(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.values(); + + v = it.next(); + t.strictEqual( real( v.value ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v.value ), -1.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( real( v.value ), 2.0, 'returns expected value' ); + t.strictEqual( imag( v.value ), -2.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.values(); + + v = it.next(); + t.strictEqual( realf( v.value ), 1.0, 'returns expected value' ); + t.strictEqual( imagf( v.value ), -1.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( realf( v.value ), 2.0, 'returns expected value' ); + t.strictEqual( imagf( v.value ), -2.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument) (complex128)', function test( t ) { + var Complex128Array; + var arr; + var it; + var v; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.values(); + + v = it.next(); + t.strictEqual( real( v.value ), 1.0, 'returns expected value' ); + t.strictEqual( imag( v.value ), -1.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( real( v.value ), 2.0, 'returns expected value' ); + t.strictEqual( imag( v.value ), -2.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'beep' ); + t.strictEqual( v.value, 'beep', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument) (complex64)', function test( t ) { + var Complex64Array; + var arr; + var it; + var v; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); + it = arr.values(); + + v = it.next(); + t.strictEqual( realf( v.value ), 1.0, 'returns expected value' ); + t.strictEqual( imagf( v.value ), -1.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( realf( v.value ), 2.0, 'returns expected value' ); + t.strictEqual( imagf( v.value ), -2.0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'beep' ); + t.strictEqual( v.value, 'beep', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex128)', function test( t ) { + var Complex128Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex128Array( buf ); + + it1 = arr.values(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( real( v1 ), real( v2 ), 'returns expected value' ); + t.strictEqual( imag( v1 ), imag( v2 ), 'returns expected value' ); + } + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable (complex64)', function test( t ) { + var Complex64Array; + var arr; + var buf; + var it1; + var it2; + var v1; + var v2; + var i; + + if ( !ITERATOR_SYMBOL ) { + t.ok( true, 'environment does not support Symbol.iterator' ); + t.end(); + return; + } + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + + buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + arr = new Complex64Array( buf ); + + it1 = arr.values(); + t.strictEqual( typeof it1[ ITERATOR_SYMBOL ], 'function', 'has method' ); + t.strictEqual( it1[ ITERATOR_SYMBOL ].length, 0, 'has zero arity' ); + + it2 = it1[ ITERATOR_SYMBOL ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( realf( v1 ), realf( v2 ), 'returns expected value' ); + t.strictEqual( imagf( v1 ), imagf( v2 ), 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js new file mode 100644 index 000000000000..1de3fa4f0d7e --- /dev/null +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js @@ -0,0 +1,405 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); +var factory = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `with` method (complex128)', function test( t ) { + var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + t.strictEqual( hasOwnProp( Complex128Array.prototype, 'with' ), true, 'has property' ); + t.strictEqual( isFunction( Complex128Array.prototype.with ), true, 'has method' ); + t.end(); +}); + +tape( 'attached to the prototype of the returned constructor is a `with` method (complex64)', function test( t ) { + var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + t.strictEqual( hasOwnProp( Complex64Array.prototype, 'with' ), true, 'has property' ); + t.strictEqual( isFunction( Complex64Array.prototype.with ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + 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() { + return arr.with.call( value, 0, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + 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() { + return arr.with.call( value, 0, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 5 ); + + values = [ + '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() { + return arr.with( value, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not an integer (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 5 ); + + values = [ + '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() { + return arr.with( value, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not in bounds (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + -11, + -12, + 11, + 12 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.with( value, new Complex128( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not in bounds (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + -11, + -12, + 11, + 12 + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.with( value, new Complex64( 1.0, 1.0 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not a complex number (complex128)', function test( t ) { + var Complex128Array; + var values; + var arr; + var i; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + + values = [ + '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() { + return arr.with( 0, value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not a complex number (complex64)', function test( t ) { + var Complex64Array; + var values; + var arr; + var i; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + + values = [ + '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() { + return arr.with( 0, value ); + }; + } +}); + +tape( 'the method does not change the array length (complex128)', function test( t ) { + var Complex128Array; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( 10 ); + out = arr.with( 5, new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length (complex64)', function test( t ) { + var Complex64Array; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( 10 ); + out = arr.with( 5, new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new complex number array with the element at a provided index replaced with a provided value (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Float64Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); + out = arr.with( 1, new Complex128( 5.0, 5.0 ) ); + + t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); + t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); + t.notEqual( out, arr, 'returns new instance' ); + t.end(); +}); + +tape( 'the method returns a new complex number array with the element at a provided index replaced with a provided value (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); + out = arr.with( 1, new Complex64( 5.0, 5.0 ) ); + + t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); + t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); + t.notEqual( out, arr, 'returns new instance' ); + t.end(); +}); + +tape( 'the method supports negative indices (complex128)', function test( t ) { + var Complex128Array; + var expected; + var arr; + var out; + + Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + expected = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); + + out = arr.with( -1, new Complex128( 1.0, 1.0 ) ); + + t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); + t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports negative indices (complex64)', function test( t ) { + var Complex64Array; + var expected; + var arr; + var out; + + Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); + expected = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); + + out = arr.with( -1, new Complex64( 1.0, 1.0 ) ); + + t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); + t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); From 722d4cb44d47118eea5d9964a0fdbf37843d7698 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Thu, 2 Apr 2026 19:43:48 +0000 Subject: [PATCH 02/12] chore: update copyright years --- .../@stdlib/array/complex-factory/benchmark/benchmark.reduce.js | 2 +- .../complex-factory/benchmark/benchmark.reduce_right.length.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js index 6e312e9dfb97..72467a52365a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js index 2a485a079e96..8b3bf87f8d6f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. From bec6d0fdc1cfc3e3c6a0489ad763d3d6decc051c Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Fri, 3 Apr 2026 09:43:25 +0530 Subject: [PATCH 03/12] fix license header format in spellcheck rules Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- etc/eslint/rules/spellcheck.js | 238 ++++++++++++++++----------------- 1 file changed, 118 insertions(+), 120 deletions(-) diff --git a/etc/eslint/rules/spellcheck.js b/etc/eslint/rules/spellcheck.js index 22a05f08bca0..c09f8251ad9d 100644 --- a/etc/eslint/rules/spellcheck.js +++ b/etc/eslint/rules/spellcheck.js @@ -1,130 +1,128 @@ /** - * @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. - */ +* @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"; +'use strict'; /** - * ESLint rules for spellchecking. - * - * @namespace rules - */ +* ESLint rules for spellchecking. +* +* @namespace rules +*/ var rules = {}; /** - * Warn when encountering potentially misspelled words in comments and strings. - * - * @name @cspell/spellchecker - * @memberof rules - * @type {Array} - * @see [spellchecker]{@link https://www.npmjs.com/package/@cspell/eslint-plugin} - * - * @example - * // Bad... - * var str = 'Functionl programming is a paradigm...'; - * - * @example - * // Good... - * var str = 'Functional programming is a paradigm...'; - */ -rules["@cspell/spellchecker"] = [ - "warn", - { - checkComments: true, - checkStrings: true, - autoFix: false, - checkIdentifiers: false, - cspell: { - allowCompoundWords: true, - ignoreRegExpList: [ - "/[a-z0-9.]+\\(/gi", // ignore functions or methods invoked in comments - "/var [a-zA-Z0-9]+/g", // ignore variable declarations - "/[A-Z][a-z]+/g", // ignore proper nouns - "/[A-Z]+/g", // ignore acronyms - "/@stdlib\\/[a-z0-9/-]+/g", // ignore stdlib package paths - "/@name [a-zA-Z0-9]+/g", // ignore identifier names in JSDoc - "/\\/\\/ returns '[^']+'/g", // ignore return value annotations - "/setReadOnly\\( [.a-z0-9]+, '[^']+?'/gi", // ignore namespace or prototype assignments - "/```[\\s\\S]+?```/g", // ignore code blocks - "/(? Date: Fri, 3 Apr 2026 09:49:42 +0530 Subject: [PATCH 04/12] remove the unused eslint-disable on line 1539 in lib/main.js Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- lib/node_modules/@stdlib/array/complex-factory/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/main.js b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js index 41341637b0ce..2197fd758b71 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/lib/main.js +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js @@ -1536,7 +1536,7 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre // We need to copy source values... tmp = new FloatArray( N ); for ( i = 0; i < N; i++ ) { - tmp[ i ] = sbuf[ i ]; // eslint-disable-line no-warning-comments + tmp[ i ] = sbuf[ i ]; } sbuf = tmp; } From 84bfdeb91fc5fa59c11a8807cf2bfa6397d27853 Mon Sep 17 00:00:00 2001 From: Uday Kakade Date: Fri, 3 Apr 2026 11:10:32 +0530 Subject: [PATCH 05/12] Fix Lint errors in README.md file --- .../@stdlib/array/complex-factory/README.md | 407 +++++++++++++++++- 1 file changed, 393 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/README.md b/lib/node_modules/@stdlib/array/complex-factory/README.md index a0e8149717af..2c19d8240e9a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/README.md +++ b/lib/node_modules/@stdlib/array/complex-factory/README.md @@ -86,6 +86,13 @@ The returned constructor (referred to below as `ComplexArray`) supports the foll Creates a complex number array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array(); @@ -108,6 +115,13 @@ arr = new Complex128Array(); Creates a complex number array having a specified `length`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -136,6 +150,13 @@ len = arr.length; Creates a complex number array from another complex number array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] @@ -170,7 +191,13 @@ len = arr4.length; Creates a complex number array from a [typed array][@stdlib/array/typed] containing interleaved real and imaginary components. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] @@ -205,7 +232,13 @@ len = arr.length; Creates a complex number array from an array-like object or iterable. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); // From an array of interleaved real and imaginary components: @@ -250,7 +283,14 @@ len = arr4.length; Returns a complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer]. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var buf = new ArrayBuffer( 240 ); @@ -313,6 +353,13 @@ len = arr6.length; Static property returning the size (in bytes) of each array element. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var nbytes = Complex64Array.BYTES_PER_ELEMENT; @@ -337,6 +384,13 @@ nbytes = Complex128Array.BYTES_PER_ELEMENT; Static property returning the constructor name. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var str = Complex64Array.name; @@ -361,6 +415,13 @@ str = Complex128Array.name; Pointer to the underlying data buffer. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 2 ); @@ -391,6 +452,13 @@ buf = arr.buffer; Size (in bytes) of the array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -421,7 +489,14 @@ nbytes = arr.byteLength; Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -466,6 +541,13 @@ offset = arr.byteOffset; Size (in bytes) of each array element. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -496,6 +578,13 @@ nbytes = arr.BYTES_PER_ELEMENT; Number of array elements. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -530,7 +619,13 @@ len = arr.length; Creates a new complex number array from an array-like object or an iterable. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); // Create an array from interleaved real and imaginary components: @@ -573,7 +668,13 @@ len = arr.length; To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like object containing complex numbers, the callback must return either a complex number or an array-like object containing real and imaginary components. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function map64( z ) { @@ -624,7 +725,13 @@ im = imag( z ); If `src` is an array-like object containing interleaved real and imaginary components, the callback is invoked for each component and should return the transformed component value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function map( v ) { @@ -678,7 +785,13 @@ To set the callback execution context, provide a `thisArg`. Creates a new complex number array from a variable number of arguments. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 ); @@ -727,6 +840,13 @@ len = arr.length; Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -785,7 +905,13 @@ If provided an out-of-bounds index, the method returns `undefined`. Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 4 ); @@ -844,7 +970,13 @@ When a `target`, `start`, and/or `end` index is negative, the respective index i Returns an iterator for iterating over array key-value pairs. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); @@ -901,7 +1033,13 @@ bool = it.next().done; Returns a boolean indicating whether all elements pass a test implemented by a predicate function. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -940,7 +1078,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Returns a modified typed array filled with a fill value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -987,7 +1131,13 @@ By default, the method fills the entire array. To fill a sub-range, provide `sta Returns a new array containing the elements of an array which pass a test implemented by a predicate function. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -1032,7 +1182,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Returns the first element in an array for which a predicate function returns a truthy value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -1083,7 +1239,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Returns the index of the first element in an array for which a predicate function returns a truthy value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -1122,7 +1284,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Returns the last element in an array for which a predicate function returns a truthy value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -1167,7 +1335,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Returns the index of the last element in an array for which a predicate function returns a truthy value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -1206,7 +1380,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Invokes a function once for each array element. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); @@ -1239,7 +1419,13 @@ The invoked function is provided three arguments: **value**, **index**, and **ar Returns an array element. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -1286,7 +1472,13 @@ If provided an out-of-bounds index, the method returns `undefined`. Returns a boolean indicating whether an array includes a provided value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 5 ); @@ -1339,7 +1531,13 @@ bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); Returns the first index at which a given element can be found. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 5 ); @@ -1388,7 +1586,13 @@ idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 ); If `searchElement` is not present in the array, the method returns `-1`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 5 ); @@ -1429,6 +1633,13 @@ idx = arr.indexOf( new Complex128( 1.0, -1.0 ), 1 ); Returns a new string by concatenating all array elements. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -1461,6 +1672,13 @@ str = arr.join(); By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -1497,6 +1715,13 @@ str = arr.join( '/' ); Returns an iterator for iterating over each index key in a typed array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 2 ); @@ -1547,7 +1772,13 @@ bool = iter.next().done; Returns the last index at which a given element can be found. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 5 ); @@ -1596,7 +1827,13 @@ idx = arr.lastIndexOf( new Complex128( 4.0, -4.0 ), -1 ); If `searchElement` is not present in the array, the method returns `-1`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 5 ); @@ -1637,7 +1874,13 @@ idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), 0 ); Returns a new array with each element being the result of a provided callback function. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function scale64( v ) { @@ -1708,9 +1951,14 @@ To set the function execution context, provide a `thisArg`. Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); var caddf = require( '@stdlib/complex/float32/base/add' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -1763,7 +2011,13 @@ The reducer function is provided four arguments: By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function reducer64( acc, v ) { @@ -1810,9 +2064,14 @@ z = arr.reduce( reducer128, 0.0 ); Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); var caddf = require( '@stdlib/complex/float32/base/add' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -1865,7 +2124,13 @@ The reducer function is provided four arguments: By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function reducer64( acc, v ) { @@ -1912,6 +2177,13 @@ z = arr.reduceRight( reducer128, 0.0 ); Reverses an array in-place. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -1984,7 +2256,13 @@ im = imag( z ); Sets one or more array elements. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -2029,7 +2307,13 @@ im = imag( z ); By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -2074,7 +2358,13 @@ im = imag( z ); In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -2131,7 +2421,13 @@ im = imag( z ); or interleaved real and imaginary components ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 10 ); @@ -2190,6 +2486,13 @@ A few notes: Copies a portion of a typed array to a new typed array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2256,6 +2559,13 @@ im = imag( z ); By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive). ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2304,6 +2614,13 @@ im = imag( z ); By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive). ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2374,6 +2691,13 @@ im = imag( z ); Returns a boolean indicating whether at least one element passes a test. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function predicate64( v ) { @@ -2420,6 +2744,13 @@ The `predicate` function is provided three arguments: **value**, **index**, and Sorts an array in-place. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function compare64( a, b ) { @@ -2527,6 +2858,13 @@ In contrast to real numbers, one cannot define a default order relation which is 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. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2593,6 +2931,13 @@ im = imag( z ); 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). ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2641,6 +2986,13 @@ im = imag( z ); 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). ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2711,6 +3063,13 @@ im = imag( z ); Serializes an array as a locale-specific string. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 2 ); @@ -2750,6 +3109,13 @@ The method supports the following arguments: Returns a new typed array containing the elements in reversed order. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -2822,6 +3188,13 @@ im = imag( z ); Returns a new typed array containing the elements in sorted order. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); function compare64( a, b ) { @@ -2947,6 +3320,13 @@ In contrast to real numbers, one cannot define a default order relation which is Serializes an array as a string. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -2983,6 +3363,13 @@ str = arr.toString(); Returns an iterator for iterating over each value in a typed array. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 2 ); @@ -3057,7 +3444,13 @@ bool = iter.next().done; Returns a new typed array with the element at a provided index replaced with a provided value. ```javascript +var complexFactory = require( '@stdlib/array/complex-factory' ); +var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); + var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); var arr = new Complex64Array( 3 ); @@ -3244,20 +3637,6 @@ logEach( '%s', out ); [@stdlib/array/buffer]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/buffer -[@stdlib/array/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float64 - -[@stdlib/complex/float64/real]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/real - -[@stdlib/complex/float64/imag]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/imag - -[@stdlib/strided/base/reinterpret-complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/strided/base/reinterpret-complex64 - -[@stdlib/strided/base/reinterpret-complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/strided/base/reinterpret-complex128 - -[@stdlib/complex/float32/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/base/add - -[@stdlib/complex/float64/base/add]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base/add - [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol From 225b72eda027a8935685489ace2d98fda98ed039 Mon Sep 17 00:00:00 2001 From: Uday Kakade Date: Sat, 4 Apr 2026 14:16:37 +0530 Subject: [PATCH 06/12] refactor factory function to factory('dtype') --- etc/eslint/rules/spellcheck.js | 2 - .../@stdlib/array/complex-factory/README.md | 679 ++++-------------- .../complex-factory/benchmark/benchmark.at.js | 16 +- .../benchmark/benchmark.copy_within.js | 12 +- .../benchmark/benchmark.copy_within.length.js | 12 +- .../benchmark/benchmark.entries.js | 12 +- .../benchmark/benchmark.every.js | 14 +- .../benchmark/benchmark.every.length.js | 8 +- .../benchmark/benchmark.fill.js | 12 +- .../benchmark/benchmark.fill.length.js | 12 +- .../benchmark/benchmark.filter.js | 14 +- .../benchmark/benchmark.filter.length.js | 8 +- .../benchmark/benchmark.find.js | 14 +- .../benchmark/benchmark.find.length.js | 8 +- .../benchmark/benchmark.find_index.js | 14 +- .../benchmark/benchmark.find_index.length.js | 8 +- .../benchmark/benchmark.find_last.js | 14 +- .../benchmark/benchmark.find_last.length.js | 8 +- .../benchmark/benchmark.find_last_index.js | 14 +- .../benchmark.find_last_index.length.js | 8 +- .../benchmark/benchmark.for_each.js | 14 +- .../benchmark/benchmark.for_each.length.js | 8 +- .../benchmark/benchmark.from.js | 56 +- .../benchmark/benchmark.get.js | 12 +- .../benchmark/benchmark.includes.js | 12 +- .../benchmark/benchmark.includes.length.js | 12 +- .../benchmark/benchmark.index_of.js | 12 +- .../benchmark/benchmark.index_of.length.js | 12 +- .../benchmark/benchmark.join.js | 14 +- .../benchmark/benchmark.join.length.js | 12 +- .../complex-factory/benchmark/benchmark.js | 64 +- .../benchmark/benchmark.keys.js | 14 +- .../benchmark/benchmark.keys.length.js | 12 +- .../benchmark/benchmark.last_index_of.js | 12 +- .../benchmark.last_index_of.length.js | 12 +- .../benchmark/benchmark.length.js | 14 +- .../benchmark/benchmark.map.js | 8 +- .../benchmark/benchmark.map.length.js | 12 +- .../complex-factory/benchmark/benchmark.of.js | 20 +- .../benchmark/benchmark.reduce.js | 14 +- .../benchmark/benchmark.reduce.length.js | 12 +- .../benchmark/benchmark.reduce_right.js | 14 +- .../benchmark.reduce_right.length.js | 12 +- .../benchmark/benchmark.reverse.js | 14 +- .../benchmark/benchmark.reverse.length.js | 12 +- .../benchmark/benchmark.set.js | 22 +- .../benchmark/benchmark.set.length.js | 12 +- .../benchmark/benchmark.slice.js | 14 +- .../benchmark/benchmark.slice.length.js | 12 +- .../benchmark/benchmark.some.js | 14 +- .../benchmark/benchmark.some.length.js | 8 +- .../benchmark/benchmark.sort.js | 10 +- .../benchmark/benchmark.sort.length.js | 8 +- .../benchmark/benchmark.subarray.js | 14 +- .../benchmark/benchmark.subarray.length.js | 12 +- .../benchmark/benchmark.to_locale_string.js | 14 +- .../benchmark.to_locale_string.length.js | 12 +- .../benchmark/benchmark.to_reversed.js | 14 +- .../benchmark/benchmark.to_reversed.length.js | 12 +- .../benchmark/benchmark.to_sorted.js | 10 +- .../benchmark/benchmark.to_sorted.length.js | 8 +- .../benchmark/benchmark.to_string.js | 14 +- .../benchmark/benchmark.to_string.length.js | 12 +- .../benchmark/benchmark.values.js | 14 +- .../benchmark/benchmark.values.length.js | 12 +- .../benchmark/benchmark.with.js | 12 +- .../benchmark/benchmark.with.length.js | 12 +- .../array/complex-factory/docs/repl.txt | 33 +- .../complex-factory/docs/types/index.d.ts | 459 +++--------- .../array/complex-factory/docs/types/test.ts | 72 +- .../array/complex-factory/examples/index.js | 10 +- .../array/complex-factory/lib/index.js | 14 +- .../@stdlib/array/complex-factory/lib/main.js | 106 +-- .../array/complex-factory/test/test.at.js | 24 +- .../complex-factory/test/test.copy_within.js | 50 +- .../complex-factory/test/test.entries.js | 30 +- .../array/complex-factory/test/test.every.js | 34 +- .../array/complex-factory/test/test.fill.js | 60 +- .../array/complex-factory/test/test.filter.js | 30 +- .../array/complex-factory/test/test.find.js | 34 +- .../complex-factory/test/test.find_index.js | 34 +- .../complex-factory/test/test.find_last.js | 34 +- .../test/test.find_last_index.js | 34 +- .../complex-factory/test/test.for_each.js | 36 +- .../array/complex-factory/test/test.from.js | 66 +- .../array/complex-factory/test/test.get.js | 24 +- .../complex-factory/test/test.includes.js | 52 +- .../complex-factory/test/test.index_of.js | 52 +- .../array/complex-factory/test/test.join.js | 38 +- .../array/complex-factory/test/test.js | 264 ++----- .../array/complex-factory/test/test.keys.js | 38 +- .../test/test.last_index_of.js | 48 +- .../array/complex-factory/test/test.map.js | 32 +- .../array/complex-factory/test/test.of.js | 22 +- .../array/complex-factory/test/test.reduce.js | 36 +- .../complex-factory/test/test.reduce_right.js | 36 +- .../complex-factory/test/test.reverse.js | 26 +- .../array/complex-factory/test/test.set.js | 70 +- .../array/complex-factory/test/test.slice.js | 54 +- .../array/complex-factory/test/test.some.js | 38 +- .../array/complex-factory/test/test.sort.js | 26 +- .../complex-factory/test/test.subarray.js | 54 +- .../test/test.to_locale_string.js | 38 +- .../complex-factory/test/test.to_reversed.js | 26 +- .../complex-factory/test/test.to_sorted.js | 26 +- .../complex-factory/test/test.to_string.js | 26 +- .../array/complex-factory/test/test.values.js | 32 +- .../array/complex-factory/test/test.with.js | 36 +- 108 files changed, 1124 insertions(+), 2701 deletions(-) diff --git a/etc/eslint/rules/spellcheck.js b/etc/eslint/rules/spellcheck.js index c09f8251ad9d..0bed591c1b08 100644 --- a/etc/eslint/rules/spellcheck.js +++ b/etc/eslint/rules/spellcheck.js @@ -85,7 +85,6 @@ rules[ '@cspell/spellchecker' ] = [ 'warn', { 'evalrational', 'hommel', 'iget', - 'imagf', 'iset', 'logcdf', 'logit', @@ -106,7 +105,6 @@ rules[ '@cspell/spellchecker' ] = [ 'warn', { 'pvalues', 'randn', 'randu', - 'realf', 'rpad', 'rtrim', 'significand', diff --git a/lib/node_modules/@stdlib/array/complex-factory/README.md b/lib/node_modules/@stdlib/array/complex-factory/README.md index 2c19d8240e9a..63ee3a7c461b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/README.md +++ b/lib/node_modules/@stdlib/array/complex-factory/README.md @@ -42,38 +42,21 @@ var complexFactory = require( '@stdlib/array/complex-factory' ); -#### complexFactory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) +#### complexFactory( dtype ) Returns a complex number typed array constructor. ```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); - -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); +var Complex64Array = complexFactory( 'complex64' ); // returns -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); // returns ``` The function accepts the following arguments: - **dtype**: complex number array data type (e.g., `'complex64'` or `'complex128'`). -- **FloatArray**: underlying float typed array constructor (e.g., `Float32Array` or `Float64Array`). -- **ComplexScalar**: complex number scalar constructor (e.g., `Complex64` or `Complex128`). -- **getReal**: function returning the real component of a complex number. -- **getImag**: function returning the imaginary component of a complex number. -- **reinterpret**: function reinterpreting a same-type complex array as its underlying float array. The returned constructor (referred to below as `ComplexArray`) supports the following signatures: @@ -87,24 +70,13 @@ Creates a complex number array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array(); // returns -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array(); // returns @@ -116,13 +88,8 @@ Creates a complex number array having a specified `length`. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); // returns @@ -130,13 +97,7 @@ var arr = new Complex64Array( 10 ); var len = arr.length; // returns 10 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); // returns @@ -151,13 +112,8 @@ Creates a complex number array from another complex number array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] // returns @@ -168,13 +124,7 @@ var arr2 = new Complex64Array( arr1 ); var len = arr2.length; // returns 2 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); var arr3 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] // returns @@ -193,12 +143,8 @@ Creates a complex number array from a [typed array][@stdlib/array/typed] contain ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] // returns [ 1.0, -1.0, 2.0, -2.0 ] @@ -210,12 +156,8 @@ var len = arr.length; // returns 2 var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); buf = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] // returns [ 1.0, -1.0, 2.0, -2.0 ] @@ -233,13 +175,9 @@ Creates a complex number array from an array-like object or iterable. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); // From an array of interleaved real and imaginary components: var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); @@ -255,13 +193,10 @@ var arr2 = new Complex64Array( buf ); len = arr2.length; // returns 2 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); // From an array of interleaved real and imaginary components: var arr3 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); @@ -285,13 +220,8 @@ Returns a complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer]. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var buf = new ArrayBuffer( 240 ); @@ -313,13 +243,7 @@ var arr3 = new Complex64Array( buf, 8, 20 ); len = arr3.length; // returns 20 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); buf = new ArrayBuffer( 480 ); @@ -354,24 +278,13 @@ Static property returning the size (in bytes) of each array element. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var nbytes = Complex64Array.BYTES_PER_ELEMENT; // returns 8 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); nbytes = Complex128Array.BYTES_PER_ELEMENT; // returns 16 @@ -385,24 +298,13 @@ Static property returning the constructor name. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var str = Complex64Array.name; // returns 'Complex64Array' -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); str = Complex128Array.name; // returns 'Complex128Array' @@ -416,13 +318,8 @@ Pointer to the underlying data buffer. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 2 ); // returns @@ -430,13 +327,7 @@ var arr = new Complex64Array( 2 ); var buf = arr.buffer; // returns -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 2 ); // returns @@ -453,13 +344,8 @@ Size (in bytes) of the array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); // returns @@ -467,13 +353,7 @@ var arr = new Complex64Array( 10 ); var nbytes = arr.byteLength; // returns 80 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); // returns @@ -491,13 +371,8 @@ Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); // returns @@ -512,13 +387,7 @@ arr = new Complex64Array( buf, 64 ); offset = arr.byteOffset; // returns 64 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); // returns @@ -542,13 +411,8 @@ Size (in bytes) of each array element. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); // returns @@ -556,13 +420,7 @@ var arr = new Complex64Array( 10 ); var nbytes = arr.BYTES_PER_ELEMENT; // returns 8 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); // returns @@ -579,13 +437,8 @@ Number of array elements. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); // returns @@ -593,13 +446,7 @@ var arr = new Complex64Array( 10 ); var len = arr.length; // returns 10 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); // returns @@ -620,13 +467,9 @@ Creates a new complex number array from an array-like object or an iterable. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); // Create an array from interleaved real and imaginary components: var arr = Complex64Array.from( [ 1.0, -1.0 ] ); @@ -642,13 +485,10 @@ arr = Complex64Array.from( [ new Complex64( 1.0, -1.0 ) ] ); len = arr.length; // returns 1 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); // Create an array from interleaved real and imaginary components: arr = Complex128Array.from( [ 1.0, -1.0 ] ); @@ -669,13 +509,11 @@ To invoke a function for each `src` value, provide a callback function. If `src` ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function map64( z ) { return new Complex64( realf(z)*2.0, imagf(z)*2.0 ); @@ -695,13 +533,11 @@ var re = realf( z ); var im = imagf( z ); // returns -2.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function map128( z ) { return new Complex128( real(z)*2.0, imag(z)*2.0 ); @@ -730,9 +566,8 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function map( v ) { return v * 2.0; @@ -754,9 +589,8 @@ var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = Complex128Array.from( new Float64Array( [ 1.0, -1.0 ] ), map ); // returns @@ -786,13 +620,9 @@ Creates a new complex number array from a variable number of arguments. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 ); // returns @@ -809,13 +639,9 @@ arr = Complex64Array.of( z1, z2 ); len = arr.length; // returns 2 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = Complex128Array.of( 1.0, -1.0, 2.0, -2.0 ); // returns @@ -841,13 +667,10 @@ Returns an array element located at integer position (index) `i`, with support f ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -868,13 +691,10 @@ z = arr.at( -1 ); re = realf( z ); // returns 9.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -906,13 +726,11 @@ Copies a sequence of elements within the array starting at `start` and ending at ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 4 ); @@ -933,13 +751,11 @@ var re = realf( z ); var im = imagf( z ); // returns -3.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 4 ); @@ -971,13 +787,10 @@ Returns an iterator for iterating over array key-value pairs. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); @@ -998,13 +811,10 @@ re = realf( v[ 1 ] ); var bool = it.next().done; // returns true -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); @@ -1034,13 +844,11 @@ Returns a boolean indicating whether all elements pass a test implemented by a p ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -1051,13 +859,11 @@ var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2 var bool = arr.every( predicate64 ); // returns true -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -1079,13 +885,11 @@ Returns a modified typed array filled with a fill value. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -1100,13 +904,11 @@ var re = realf( z ); var im = imagf( z ); // returns -1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -1132,13 +934,10 @@ Returns a new array containing the elements of an array which pass a test implem ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) > 0.0 ); @@ -1152,13 +951,10 @@ var out = arr.filter( predicate64 ); var len = out.length; // returns 2 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) > 0.0 ); @@ -1183,13 +979,11 @@ Returns the first element in an array for which a predicate function returns a t ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -1206,13 +1000,11 @@ var re = realf( z ); var im = imagf( z ); // returns 2.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -1240,13 +1032,11 @@ Returns the index of the first element in an array for which a predicate functio ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -1257,13 +1047,11 @@ var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, var idx = arr.findIndex( predicate64 ); // returns 1 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -1285,13 +1073,11 @@ Returns the last element in an array for which a predicate function returns a tr ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -1305,13 +1091,11 @@ var z = arr.findLast( predicate64 ); var re = realf( z ); // returns 2.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -1336,13 +1120,11 @@ Returns the index of the last element in an array for which a predicate function ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -1353,13 +1135,11 @@ var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2 var idx = arr.findLastIndex( predicate64 ); // returns 1 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -1381,13 +1161,11 @@ Invokes a function once for each array element. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); @@ -1395,13 +1173,11 @@ arr.forEach( function( v, i ) { console.log( i, realf( v ), imagf( v ) ); }); -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); @@ -1420,13 +1196,11 @@ Returns an array element. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -1441,13 +1215,11 @@ var re = realf( z ); var im = imagf( z ); // returns -1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -1473,13 +1245,9 @@ Returns a boolean indicating whether an array includes a provided value. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 5 ); @@ -1498,13 +1266,9 @@ bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); // returns true -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 5 ); @@ -1532,13 +1296,9 @@ Returns the first index at which a given element can be found. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 5 ); @@ -1557,13 +1317,9 @@ idx = arr.indexOf( new Complex64( 2.0, -2.0 ), 2 ); idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 ); // returns 3 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 5 ); @@ -1587,13 +1343,9 @@ If `searchElement` is not present in the array, the method returns `-1`. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 5 ); @@ -1606,13 +1358,9 @@ var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); idx = arr.indexOf( new Complex64( 1.0, -1.0 ), 1 ); // returns -1 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 5 ); @@ -1634,13 +1382,8 @@ Returns a new string by concatenating all array elements. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -1651,13 +1394,7 @@ arr.set( [ 3.0, 3.0 ], 2 ); var str = arr.join(); // returns '1 + 1i,2 - 2i,3 + 3i' -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -1673,13 +1410,8 @@ By default, the method separates serialized array elements with a comma. To use ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -1690,13 +1422,7 @@ arr.set( [ 3.0, 3.0 ], 2 ); var str = arr.join( '/' ); // returns '1 + 1i/2 - 2i/3 + 3i' -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -1716,13 +1442,8 @@ Returns an iterator for iterating over each index key in a typed array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 2 ); @@ -1740,13 +1461,7 @@ v = iter.next().value; var bool = iter.next().done; // returns true -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 2 ); @@ -1773,13 +1488,9 @@ Returns the last index at which a given element can be found. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 5 ); @@ -1798,13 +1509,9 @@ idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 2 ); idx = arr.lastIndexOf( new Complex64( 4.0, -4.0 ), -1 ); // returns 3 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 5 ); @@ -1828,13 +1535,9 @@ If `searchElement` is not present in the array, the method returns `-1`. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 5 ); @@ -1847,13 +1550,9 @@ var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 0 ); // returns -1 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 5 ); @@ -1875,13 +1574,11 @@ Returns a new array with each element being the result of a provided callback fu ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function scale64( v ) { return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); @@ -1905,13 +1602,11 @@ var re = realf( z ); var im = imagf( z ); // returns -2.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function scale128( v ) { return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); @@ -1952,14 +1647,12 @@ Applies a provided callback function to each element of the array, in order, pas ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); var caddf = require( '@stdlib/complex/float32/base/add' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -1976,14 +1669,12 @@ var re = realf( z ); var im = imagf( z ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -2012,13 +1703,9 @@ By default, the function initializes the accumulated result to the first element ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function reducer64( acc, v ) { acc += realf( v ); @@ -2034,13 +1721,9 @@ arr.set( [ 3.0, 3.0 ], 2 ); var z = arr.reduce( reducer64, 0.0 ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function reducer128( acc, v ) { acc += real( v ); @@ -2065,14 +1748,12 @@ Applies a provided callback function to each element of the array, in reverse or ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); var caddf = require( '@stdlib/complex/float32/base/add' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -2089,14 +1770,12 @@ var re = realf( z ); var im = imagf( z ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -2125,13 +1804,9 @@ By default, the function initializes the accumulated result to the last element ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function reducer64( acc, v ) { acc += realf( v ); @@ -2147,13 +1822,9 @@ arr.set( [ 3.0, 3.0 ], 2 ); var z = arr.reduceRight( reducer64, 0.0 ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function reducer128( acc, v ) { acc += real( v ); @@ -2178,13 +1849,11 @@ Reverses an array in-place. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -2213,13 +1882,11 @@ re = realf( z ); im = imagf( z ); // returns 1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -2257,13 +1924,11 @@ Sets one or more array elements. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -2280,13 +1945,11 @@ var re = realf( z ); var im = imagf( z ); // returns -1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -2308,13 +1971,11 @@ By default, the method sets array elements starting at position (index) `i = 0`. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -2331,13 +1992,11 @@ var re = realf( z ); var im = imagf( z ); // returns -1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -2359,13 +2018,11 @@ In addition to providing a complex number, to set one or more array elements, pr ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -2388,13 +2045,11 @@ var re = realf( z ); var im = imagf( z ); // returns -2.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -2426,9 +2081,8 @@ var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 10 ); @@ -2451,9 +2105,8 @@ var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 10 ); @@ -2487,13 +2140,11 @@ Copies a portion of a typed array to a new typed array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2521,13 +2172,11 @@ re = realf( z ); im = imagf( z ); // returns 8.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2560,13 +2209,11 @@ By default, the method returns a typed array beginning with the first array elem ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2585,13 +2232,11 @@ var re = realf( z ); var im = imagf( z ); // returns 4.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2615,13 +2260,11 @@ By default, the method returns a typed array which includes all array elements a ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2649,13 +2292,11 @@ re = realf( z ); im = imagf( z ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2692,13 +2333,10 @@ Returns a boolean indicating whether at least one element passes a test. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function predicate64( v ) { return ( realf( v ) === imagf( v ) ); @@ -2713,13 +2351,10 @@ arr.set( [ 3.0, -3.0 ], 2 ); var bool = arr.some( predicate64 ); // returns true -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function predicate128( v ) { return ( real( v ) === imag( v ) ); @@ -2745,13 +2380,11 @@ Sorts an array in-place. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function compare64( a, b ) { var re1 = realf( a ); @@ -2791,13 +2424,11 @@ var re = realf( z ); var im = imagf( z ); // returns -1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function compare128( a, b ) { var re1 = real( a ); @@ -2859,13 +2490,11 @@ Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/ ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2893,13 +2522,11 @@ re = realf( z ); im = imagf( z ); // returns 8.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2932,13 +2559,11 @@ By default, the method creates a typed array view beginning with the first array ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2957,13 +2582,11 @@ var re = realf( z ); var im = imagf( z ); // returns 4.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -2987,13 +2610,11 @@ By default, the method creates a typed array view which includes all array eleme ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -3021,13 +2642,11 @@ re = realf( z ); im = imagf( z ); // returns 6.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); @@ -3064,13 +2683,8 @@ Serializes an array as a locale-specific string. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 2 ); @@ -3080,13 +2694,7 @@ arr.set( [ 2.0, 2.0 ], 1 ); var str = arr.toLocaleString(); // returns '1 + 1i,2 + 2i' -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 2 ); @@ -3110,13 +2718,11 @@ Returns a new typed array containing the elements in reversed order. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -3145,13 +2751,11 @@ re = realf( z ); im = imagf( z ); // returns 1.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -3189,13 +2793,11 @@ Returns a new typed array containing the elements in sorted order. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); function compare64( a, b ) { var re1 = realf( a ); @@ -3244,13 +2846,11 @@ re = realf( z ); im = imagf( z ); // returns -3.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); function compare128( a, b ) { var re1 = real( a ); @@ -3321,13 +2921,8 @@ Serializes an array as a string. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -3338,13 +2933,7 @@ arr.set( [ 3.0, 3.0 ], 2 ); var str = arr.toString(); // returns '1 + 1i,2 - 2i,3 + 3i' -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); - -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -3364,13 +2953,11 @@ Returns an iterator for iterating over each value in a typed array. ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 2 ); @@ -3400,13 +2987,11 @@ im = imagf( v ); var bool = iter.next().done; // returns true -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 2 ); @@ -3445,13 +3030,11 @@ Returns a new typed array with the element at a provided index replaced with a p ```javascript var complexFactory = require( '@stdlib/array/complex-factory' ); -var Float32Array = require( '@stdlib/array/float32' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array( 3 ); @@ -3471,13 +3054,11 @@ var re = realf( z ); var im = imagf( z ); // returns 4.0 -var Float64Array = require( '@stdlib/array/float64' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array( 3 ); @@ -3536,17 +3117,11 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var logEach = require( '@stdlib/console/log-each' ); var complexFactory = require( '@stdlib/array/complex-factory' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex64Array = complexFactory( 'complex64' ); +var Complex128Array = complexFactory( 'complex128' ); // Create a complex array by specifying a length: var out = new Complex64Array( 3 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js index 640751d6288a..06a9386a7f87 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.at.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128,nonnegative_indices:at', pkg ), function benchmar var z; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, i ) ); @@ -76,7 +68,7 @@ bench( format( '%s::complex128,negative_indices:at', pkg ), function benchmark( var z; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, i ) ); @@ -106,7 +98,7 @@ bench( format( '%s::complex64,nonnegative_indices:at', pkg ), function benchmark var z; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, i ) ); @@ -136,7 +128,7 @@ bench( format( '%s::complex64,negative_indices:at', pkg ), function benchmark( b var z; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js index beab30c25fe4..fb508f9dc891 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -44,7 +36,7 @@ bench( format( '%s::complex128,copyWithin:len=5', pkg ), function benchmark( b ) var buf; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 5; i++ ) { @@ -75,7 +67,7 @@ bench( format( '%s::complex64,copyWithin:len=5', pkg ), function benchmark( b ) var buf; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 5; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js index 42ec992491d8..5a71879bbb50 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.copy_within.length.js @@ -22,16 +22,8 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var buf; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len+1; i++ ) { @@ -102,7 +94,7 @@ function createBenchmark64( len ) { var buf; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len+1; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js index edb09ef25f75..0ba722b1d841 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.entries.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -44,7 +36,7 @@ bench( format( '%s::complex128,entries:len=10', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { @@ -73,7 +65,7 @@ bench( format( '%s::complex64,entries:len=10', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js index 9acb9060256a..0267b2221a6c 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var format = require( '@stdlib/string/format' ); @@ -46,7 +36,7 @@ bench( format( '%s::complex128:every', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4 ] ); b.tic(); @@ -74,7 +64,7 @@ bench( format( '%s::complex64:every', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js index 6bc1d4afadb5..b59129249b19 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.every.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -125,7 +121,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js index eeb0d30c501f..afd93720f46e 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128:fill', pkg ), function benchmark( b ) { var out; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), @@ -76,7 +68,7 @@ bench( format( '%s::complex64:fill', pkg ), function benchmark( b ) { var out; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js index e99ba91e499d..93cc93de7a31 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.fill.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -48,7 +40,7 @@ var factory = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark128( len ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( len ); return benchmark; @@ -94,7 +86,7 @@ function createBenchmark128( len ) { * @returns {Function} benchmark function */ function createBenchmark64( len ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js index ff19675ffe60..8a92d7d1f554 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:filter', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -73,7 +63,7 @@ bench( format( '%s::complex64:filter', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js index 0dc9408ab4c3..6551ef893ad2 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.filter.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -125,7 +121,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js index addb381f658e..50a3f5f86d13 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:find', pkg ), function benchmark( b ) { var z; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -73,7 +63,7 @@ bench( format( '%s::complex64:find', pkg ), function benchmark( b ) { var z; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js index 677c5eeac2cf..7c829cb92b97 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex128( i, i ) ); @@ -126,7 +122,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js index 7b71c9ba9493..8be2e3ba5b7b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var format = require( '@stdlib/string/format' ); @@ -46,7 +36,7 @@ bench( format( '%s::complex128:findIndex', pkg ), function benchmark( b ) { var idx; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -74,7 +64,7 @@ bench( format( '%s::complex64:findIndex', pkg ), function benchmark( b ) { var idx; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js index b64e292b4449..8dea08338313 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_index.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex128( i, i ) ); @@ -126,7 +122,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js index dc609d7e693f..01c0cc0fc874 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:findLast', pkg ), function benchmark( b ) { var z; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -73,7 +63,7 @@ bench( format( '%s::complex64:findLast', pkg ), function benchmark( b ) { var z; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js index f07417957b45..69a5207b8b62 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; arr.push( new Complex128( 1, -1 ) ); for ( i = 1; i < len; i++ ) { @@ -126,7 +122,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; arr.push( new Complex64( 1, -1 ) ); for ( i = 1; i < len; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js index 302cc4410af7..ee29576ba0ea 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var format = require( '@stdlib/string/format' ); @@ -46,7 +36,7 @@ bench( format( '%s::complex128:findLastIndex', pkg ), function benchmark( b ) { var idx; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -74,7 +64,7 @@ bench( format( '%s::complex64:findLastIndex', pkg ), function benchmark( b ) { var idx; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js index 35e6251f2ee4..fb4a1c119954 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.find_last_index.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; arr.push( new Complex128( 1, -1 ) ); for ( i = 1; i < len; i++ ) { @@ -126,7 +122,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; arr.push( new Complex64( 1, -1 ) ); for ( i = 1; i < len; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js index e0cba1e9ec6a..2e1bd06521a8 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -44,7 +34,7 @@ bench( format( '%s::complex128:forEach', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4 ] ); b.tic(); @@ -73,7 +63,7 @@ bench( format( '%s::complex64:forEach', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js index 8dcd737647fe..636ab65f791f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.for_each.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -51,7 +47,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -103,7 +99,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js index 43bbc1d53d2c..5c911478b362 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.from.js @@ -24,14 +24,6 @@ var bench = require( '@stdlib/bench' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -52,7 +44,7 @@ bench( format( '%s::complex128,typed_array,from', pkg ), function benchmark( b ) var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Float64Array( 0 ); b.tic(); @@ -76,7 +68,7 @@ bench( format( '%s::complex128,typed_array,from:len=5', pkg ), function benchmar var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Float64Array( 10 ); b.tic(); @@ -100,7 +92,7 @@ bench( format( '%s::complex128,typed_array,clbk,from:len=5', pkg ), function ben var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Float64Array( 10 ); b.tic(); @@ -128,7 +120,7 @@ bench( format( '%s::complex128,complex_typed_array,from', pkg ), function benchm var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Complex128Array( 0 ); b.tic(); @@ -152,7 +144,7 @@ bench( format( '%s::complex128,complex_typed_array,from:len=5', pkg ), function var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Complex128Array( 5 ); b.tic(); @@ -176,7 +168,7 @@ bench( format( '%s::complex128,complex_typed_array,clbk,from:len=5', pkg ), func var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Complex128Array( 5 ); b.tic(); @@ -204,7 +196,7 @@ bench( format( '%s::complex128,array,from', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = []; b.tic(); @@ -228,7 +220,7 @@ bench( format( '%s::complex128,array,from:len=5', pkg ), function benchmark( b ) var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -252,7 +244,7 @@ bench( format( '%s::complex128,array,clbk,from:len=5', pkg ), function benchmark var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -279,7 +271,7 @@ bench( format( '%s::complex128,iterable,from', pkg ), opts, function benchmark( var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -319,7 +311,7 @@ bench( format( '%s::complex128,iterable,from:len=5', pkg ), opts, function bench var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -368,7 +360,7 @@ bench( format( '%s::complex128,iterable,clbk,from:len=5', pkg ), opts, function var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -424,7 +416,7 @@ bench( format( '%s::complex64,typed_array,from', pkg ), function benchmark( b ) var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Float32Array( 0 ); b.tic(); @@ -448,7 +440,7 @@ bench( format( '%s::complex64,typed_array,from:len=5', pkg ), function benchmark var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Float32Array( 10 ); b.tic(); @@ -472,7 +464,7 @@ bench( format( '%s::complex64,typed_array,clbk,from:len=5', pkg ), function benc var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Float32Array( 10 ); b.tic(); @@ -500,7 +492,7 @@ bench( format( '%s::complex64,complex_typed_array,from', pkg ), function benchma var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Complex64Array( 0 ); b.tic(); @@ -524,7 +516,7 @@ bench( format( '%s::complex64,complex_typed_array,from:len=5', pkg ), function b var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Complex64Array( 5 ); b.tic(); @@ -548,7 +540,7 @@ bench( format( '%s::complex64,complex_typed_array,clbk,from:len=5', pkg ), funct var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Complex64Array( 5 ); b.tic(); @@ -576,7 +568,7 @@ bench( format( '%s::complex64,array,from', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = []; b.tic(); @@ -600,7 +592,7 @@ bench( format( '%s::complex64,array,from:len=5', pkg ), function benchmark( b ) var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -624,7 +616,7 @@ bench( format( '%s::complex64,array,clbk,from:len=5', pkg ), function benchmark( var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -651,7 +643,7 @@ bench( format( '%s::complex64,iterable,from', pkg ), opts, function benchmark( b var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -691,7 +683,7 @@ bench( format( '%s::complex64,iterable,from:len=5', pkg ), opts, function benchm var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -740,7 +732,7 @@ bench( format( '%s::complex64,iterable,clbk,from:len=5', pkg ), opts, function b var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js index a794f02b5cb8..1b9d0e11914a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.get.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var format = require( '@stdlib/string/format' ); @@ -47,7 +39,7 @@ bench( format( '%s::complex128,get', pkg ), function benchmark( b ) { var z; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { @@ -78,7 +70,7 @@ bench( format( '%s::complex64,get', pkg ), function benchmark( b ) { var z; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js index e4ad61125eb8..fe5144040e6a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128:includes', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, i ) ); @@ -77,7 +69,7 @@ bench( format( '%s::complex64:includes', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js index 847dafaa13cd..58b8dadfd3cd 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.includes.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -103,7 +95,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js index 1905a555fb06..fff62df2b397 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128:indexOf', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, i ) ); @@ -77,7 +69,7 @@ bench( format( '%s::complex64:indexOf', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js index 8dd03af89d56..d88f1320d237 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.index_of.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -103,7 +95,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js index ba5c9acd2812..28c8eee3dc03 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -44,7 +34,7 @@ bench( format( '%s::complex128:join', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -68,7 +58,7 @@ bench( format( '%s::complex64:join', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js index ec70e1bb0f77..53b2e78ec2e4 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.join.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -51,7 +43,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -98,7 +90,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js index b595b8a068d6..3b56c6022281 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.js @@ -24,14 +24,6 @@ var bench = require( '@stdlib/bench' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); @@ -54,7 +46,7 @@ bench( format( '%s::complex128,instantiation,new', pkg ), function benchmark( b var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -77,7 +69,7 @@ bench( format( '%s::complex128,instantiation,no_new', pkg ), function benchmark( var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctor = Complex128Array; b.tic(); @@ -100,7 +92,7 @@ bench( format( '%s::complex128,instantiation,length', pkg ), function benchmark( var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -123,7 +115,7 @@ bench( format( '%s::complex128,instantiation,typed_array', pkg ), function bench var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Float64Array( 0 ); b.tic(); @@ -147,7 +139,7 @@ bench( format( '%s::complex128,instantiation,complex_typed_array', pkg ), functi var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new Complex128Array( 0 ); b.tic(); @@ -171,7 +163,7 @@ bench( format( '%s::complex128,instantiation,array', pkg ), function benchmark( var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = []; b.tic(); @@ -194,7 +186,7 @@ bench( format( '%s::complex128,instantiation,iterable', pkg ), opts, function be var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -235,7 +227,7 @@ bench( format( '%s::complex128,instantiation,arraybuffer', pkg ), function bench var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new ArrayBuffer( 0 ); b.tic(); @@ -259,7 +251,7 @@ bench( format( '%s::complex128,instantiation,arraybuffer,byte_offset', pkg ), fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new ArrayBuffer( 16 ); b.tic(); @@ -283,7 +275,7 @@ bench( format( '%s::complex128,instantiation,arraybuffer,byte_offset,length', pk var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = new ArrayBuffer( 16 ); b.tic(); @@ -307,7 +299,7 @@ bench( format( '%s::complex128,get:buffer', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); b.tic(); @@ -332,7 +324,7 @@ bench( format( '%s::complex128,get:byteLength', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); b.tic(); @@ -357,7 +349,7 @@ bench( format( '%s::complex128,get:byteOffset', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); b.tic(); @@ -382,7 +374,7 @@ bench( format( '%s::complex128,get:length', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); b.tic(); @@ -406,7 +398,7 @@ bench( format( '%s::complex64,instantiation,new', pkg ), function benchmark( b ) var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -429,7 +421,7 @@ bench( format( '%s::complex64,instantiation,no_new', pkg ), function benchmark( var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctor = Complex64Array; b.tic(); @@ -452,7 +444,7 @@ bench( format( '%s::complex64,instantiation,length', pkg ), function benchmark( var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -475,7 +467,7 @@ bench( format( '%s::complex64,instantiation,typed_array', pkg ), function benchm var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Float32Array( 0 ); b.tic(); @@ -499,7 +491,7 @@ bench( format( '%s::complex64,instantiation,complex_typed_array', pkg ), functio var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new Complex64Array( 0 ); b.tic(); @@ -523,7 +515,7 @@ bench( format( '%s::complex64,instantiation,array', pkg ), function benchmark( b var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = []; b.tic(); @@ -546,7 +538,7 @@ bench( format( '%s::complex64,instantiation,iterable', pkg ), opts, function ben var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -587,7 +579,7 @@ bench( format( '%s::complex64,instantiation,arraybuffer', pkg ), function benchm var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new ArrayBuffer( 0 ); b.tic(); @@ -611,7 +603,7 @@ bench( format( '%s::complex64,instantiation,arraybuffer,byte_offset', pkg ), fun var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new ArrayBuffer( 8 ); b.tic(); @@ -635,7 +627,7 @@ bench( format( '%s::complex64,instantiation,arraybuffer,byte_offset,length', pkg var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = new ArrayBuffer( 8 ); b.tic(); @@ -659,7 +651,7 @@ bench( format( '%s::complex64,get:buffer', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); b.tic(); @@ -684,7 +676,7 @@ bench( format( '%s::complex64,get:byteLength', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); b.tic(); @@ -709,7 +701,7 @@ bench( format( '%s::complex64,get:byteOffset', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); b.tic(); @@ -734,7 +726,7 @@ bench( format( '%s::complex64,get:length', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js index 6f8314ef77d1..f6d15a55de91 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:keys:len=2', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:keys:len=2', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js index 36963bb7e573..7668a2ee0bd5 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.keys.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js index 6d96c47cad20..1e84417caf9b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128:lastIndexOf', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, i ) ); @@ -77,7 +69,7 @@ bench( format( '%s::complex64:lastIndexOf', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js index 2e53c78bbf83..a998b888bc47 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.last_index_of.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -102,7 +94,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js index b0c42dc61cfc..4ace1db77c45 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.length.js @@ -22,16 +22,6 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -49,7 +39,7 @@ var factory = require( './../lib' ); function createBenchmark128( len ) { var Complex128Array; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); return benchmark; @@ -89,7 +79,7 @@ function createBenchmark128( len ) { function createBenchmark64( len ) { var Complex64Array; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); return benchmark; diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js index 5cf346828785..9a8a84837da9 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +41,7 @@ bench( format( '%s::complex128:map', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -73,7 +69,7 @@ bench( format( '%s::complex64:map', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js index 2312472b7377..d5243ed342d5 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.map.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var identity = require( '@stdlib/utils/identity-function' ); var pow = require( '@stdlib/math/base/special/pow' ); @@ -53,7 +45,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -100,7 +92,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js index ede18435b438..c03f53251011 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.of.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -43,7 +35,7 @@ bench( format( '%s::complex128,of', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -66,7 +58,7 @@ bench( format( '%s::complex128,interleaved,of:len=5', pkg ), function benchmark( var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -90,7 +82,7 @@ bench( format( '%s::complex128,complex_numbers,of:len=5', pkg ), function benchm var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = []; for ( i = 0; i < 5; i++ ) { @@ -117,7 +109,7 @@ bench( format( '%s::complex64,of', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -140,7 +132,7 @@ bench( format( '%s::complex64,interleaved,of:len=5', pkg ), function benchmark( var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; b.tic(); @@ -164,7 +156,7 @@ bench( format( '%s::complex64,complex_numbers,of:len=5', pkg ), function benchma var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = []; for ( i = 0; i < 5; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js index 72467a52365a..2758f811fefd 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); var caddf = require( '@stdlib/complex/float32/base/add' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); @@ -47,7 +37,7 @@ bench( format( '%s::complex128:reduce', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -71,7 +61,7 @@ bench( format( '%s::complex64:reduce', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js index 7156847c7a38..183c46f8f79b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); var caddf = require( '@stdlib/complex/float32/base/add' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); @@ -54,7 +46,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -101,7 +93,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js index e59e42da0436..256d5deb9b5b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); var caddf = require( '@stdlib/complex/float32/base/add' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); @@ -47,7 +37,7 @@ bench( format( '%s::complex128:reduceRight', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -71,7 +61,7 @@ bench( format( '%s::complex64:reduceRight', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js index 8b3bf87f8d6f..e33f868d7f94 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reduce_right.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var cadd = require( '@stdlib/complex/float64/base/add' ); var caddf = require( '@stdlib/complex/float32/base/add' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); @@ -54,7 +46,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -101,7 +93,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js index bc4d6235e352..ffb4da5a7148 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:reverse', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:reverse', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js index bd92e11cd0de..7b16725fe043 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.reverse.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js index 985861ffaf89..12b2eac06229 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.js @@ -25,12 +25,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -46,7 +40,7 @@ bench( format( '%s::complex128,complex_number,set', pkg ), function benchmark( b var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = []; for ( i = 0; i < 10; i++ ) { @@ -78,7 +72,7 @@ bench( format( '%s::complex128,array,set', pkg ), function benchmark( b ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = []; for ( i = 0; i < 10; i++ ) { @@ -112,7 +106,7 @@ bench( format( '%s::complex128,typed_array,set', pkg ), function benchmark( b ) var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = new Float64Array( 20 ); M = values.length; @@ -152,7 +146,7 @@ bench( format( '%s::complex128,complex_typed_array,set', pkg ), function benchma var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = new Float64Array( 20 ); M = values.length; @@ -189,7 +183,7 @@ bench( format( '%s::complex64,complex_number,set', pkg ), function benchmark( b var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = []; for ( i = 0; i < 10; i++ ) { @@ -221,7 +215,7 @@ bench( format( '%s::complex64,array,set', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = []; for ( i = 0; i < 10; i++ ) { @@ -255,7 +249,7 @@ bench( format( '%s::complex64,typed_array,set', pkg ), function benchmark( b ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = new Float32Array( 20 ); M = values.length; @@ -295,7 +289,7 @@ bench( format( '%s::complex64,complex_typed_array,set', pkg ), function benchmar var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = new Float32Array( 20 ); M = values.length; diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js index 007856683c14..607c97236930 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.set.length.js @@ -23,16 +23,8 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); var randu = require( '@stdlib/random/base/randu' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -56,7 +48,7 @@ function createBenchmark128( len ) { var N; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr1 = []; arr2 = []; @@ -118,7 +110,7 @@ function createBenchmark64( len ) { var N; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr1 = []; arr2 = []; diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js index 9fffb3fd8252..b59a84ab6dc2 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:slice', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:slice', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js index 60ed96ca9dc6..a7fb8f5bea66 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.slice.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js index 736b8efa651c..072b0593f40f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var format = require( '@stdlib/string/format' ); @@ -46,7 +36,7 @@ bench( format( '%s::complex128:some', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4 ] ); b.tic(); @@ -74,7 +64,7 @@ bench( format( '%s::complex64:some', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js index bc28c3a5babb..a44203e1ea5a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.some.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -78,7 +74,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -126,7 +122,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len-1; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js index 9e94a9b9a8a7..26557d50b675 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.js @@ -21,16 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -112,7 +106,7 @@ bench( format( '%s::complex128:sort', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -136,7 +130,7 @@ bench( format( '%s::complex64:sort', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js index 070046c98afa..34a9d42baf1e 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.sort.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -116,7 +112,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -163,7 +159,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js index 9b747830b668..bc9776bd1947 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:subarray', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:subarray', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js index eb6c171e51b0..30f80f5c568b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.subarray.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js index 97a0213584ad..67ee6e9070ea 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -44,7 +34,7 @@ bench( format( '%s::complex128:toLocaleString', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -68,7 +58,7 @@ bench( format( '%s::complex64:toLocaleString', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js index bedd73630f5c..7613616c79ac 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_locale_string.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -51,7 +43,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -98,7 +90,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js index 88edaba02284..274bddd069c0 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:toReversed', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:toReversed', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js index c4fc419d8a3d..26d2c9910722 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_reversed.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js index f2042a2bc3d3..d925b8b85ab8 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.js @@ -21,16 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -112,7 +106,7 @@ bench( format( '%s::complex128:toSorted', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -136,7 +130,7 @@ bench( format( '%s::complex64:toSorted', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js index 88bf5bdd1415..388b5c6d2a7b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_sorted.length.js @@ -21,16 +21,12 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -116,7 +112,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -163,7 +159,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js index 4132304c0857..8628946654d0 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var factory = require( './../lib' ); @@ -44,7 +34,7 @@ bench( format( '%s::complex128:toString', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); @@ -68,7 +58,7 @@ bench( format( '%s::complex64:toString', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js index 1efb7b63c4f9..4d66f981cfdc 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.to_string.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -51,7 +43,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -98,7 +90,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js index 1fac6caa28d9..2d55a95e495f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.js @@ -21,16 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -45,7 +35,7 @@ bench( format( '%s::complex128:values:len=2', pkg ), function benchmark( b ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); b.tic(); @@ -69,7 +59,7 @@ bench( format( '%s::complex64:values:len=2', pkg ), function benchmark( b ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); b.tic(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js index e4cc3802c7b5..a441703d7a73 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.values.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -52,7 +44,7 @@ function createBenchmark128( len ) { var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex128( i, i ) ); @@ -99,7 +91,7 @@ function createBenchmark64( len ) { var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < len; i++ ) { arr.push( new Complex64( i, i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js index 370623175360..cab802284801 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,7 +38,7 @@ bench( format( '%s::complex128:with', pkg ), function benchmark( b ) { var out; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), @@ -76,7 +68,7 @@ bench( format( '%s::complex64:with', pkg ), function benchmark( b ) { var out; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), diff --git a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js index 6ac351be0813..ec61efa31d0e 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js +++ b/lib/node_modules/@stdlib/array/complex-factory/benchmark/benchmark.with.length.js @@ -21,16 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isComplexLike = require( '@stdlib/assert/is-complex-like' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -48,7 +40,7 @@ var factory = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark128( len ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( len ); return benchmark; @@ -94,7 +86,7 @@ function createBenchmark128( len ) { * @returns {Function} benchmark function */ function createBenchmark64( len ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( len ); return benchmark; diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt index b9fbe3f64f75..3557199a9142 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt @@ -1,26 +1,10 @@ -{{alias}}( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) +{{alias}}( dtype ) Returns a complex number typed array constructor. Parameters ---------- dtype: string - Complex number array data type (e.g., 'complex64'). - - FloatArray: Function - Underlying float typed array constructor (e.g., Float32Array). - - ComplexScalar: Function - Complex number scalar constructor (e.g., Complex64). - - getReal: Function - Function returning the real component of a complex number. - - getImag: Function - Function returning the imaginary component of a complex number. - - reinterpret: Function - Function reinterpreting a same-type complex array as its underlying - float array. + Complex number array data type (e.g., 'complex64' or 'complex128'). Returns ------- @@ -29,12 +13,7 @@ Examples -------- - > var f = require( '@stdlib/array/float32' ); - > var C = require( '@stdlib/complex/float32/ctor' ); - > var re = require( '@stdlib/complex/float32/real' ); - > var im = require( '@stdlib/complex/float32/imag' ); - > var ri = require( '@stdlib/strided/base/reinterpret-complex64' ); - > var Complex64Array = {{alias}}( 'complex64', f, C, re, im, ri ) + > var Complex64Array = {{alias}}( 'complex64' ) > var arr = new Complex64Array( 3 ) @@ -459,13 +438,13 @@ Parameters ---------- - element0: number + element0: number|ComplexLike Array element. - element1: number (optional) + element1: number|ComplexLike (optional) Array element. - elementN: ...number (optional) + elementN: ...number|ComplexLike (optional) Array elements. Returns diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts index 03ca253060ea..78d989304cfd 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/types/index.d.ts @@ -26,31 +26,8 @@ import { TypedIterator } from '@stdlib/types/iter'; import { ArrayLike, RealOrComplexTypedArray } from '@stdlib/types/array'; import { ComplexLike } from '@stdlib/types/complex'; import ArrayBuffer = require( '@stdlib/array/buffer' ); - -/** -* Returns the real component of a complex number. -* -* @param z - complex number -* @returns real component -*/ -type GetReal = ( z: ComplexLike ) => number; - -/** -* Returns the imaginary component of a complex number. -* -* @param z - complex number -* @returns imaginary component -*/ -type GetImag = ( z: ComplexLike ) => number; - -/** -* Reinterprets a complex typed array as a float typed array. -* -* @param x - complex typed array -* @param offset - index offset -* @returns float typed array view -*/ -type Reinterpret = ( x: any, offset: number ) => any; +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); /** * Callback invoked for each element in a source object. @@ -300,14 +277,12 @@ interface ComplexTypedArray { * Pointer to the underlying data buffer. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -315,14 +290,12 @@ interface ComplexTypedArray { * // returns * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -335,14 +308,12 @@ interface ComplexTypedArray { * Length (in bytes) of the array. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -350,14 +321,12 @@ interface ComplexTypedArray { * // returns 80 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -370,14 +339,12 @@ interface ComplexTypedArray { * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -385,14 +352,12 @@ interface ComplexTypedArray { * // returns 0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -405,14 +370,12 @@ interface ComplexTypedArray { * Size (in bytes) of each array element. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -420,14 +383,12 @@ interface ComplexTypedArray { * // returns 8 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -440,14 +401,12 @@ interface ComplexTypedArray { * Number of array elements. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -455,14 +414,12 @@ interface ComplexTypedArray { * // returns 10 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -479,14 +436,12 @@ interface ComplexTypedArray { * @returns array element * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -506,14 +461,12 @@ interface ComplexTypedArray { * // returns undefined * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -543,14 +496,12 @@ interface ComplexTypedArray { * @returns modified array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 4 ); * @@ -573,14 +524,12 @@ interface ComplexTypedArray { * // returns 2.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 4 ); * @@ -610,14 +559,12 @@ interface ComplexTypedArray { * @returns iterator * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = [ * new Complex64( 1.0, 1.0 ), @@ -643,14 +590,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = [ * new Complex128( 1.0, 1.0 ), @@ -685,14 +630,12 @@ interface ComplexTypedArray { * @returns boolean indicating whether all elements pass a test * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -708,14 +651,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -741,14 +682,12 @@ interface ComplexTypedArray { * @returns modified typed array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -773,14 +712,12 @@ interface ComplexTypedArray { * // returns 1.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -814,14 +751,12 @@ interface ComplexTypedArray { * @returns new array containing elements which pass a test * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -849,14 +784,12 @@ interface ComplexTypedArray { * // returns 2.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -893,14 +826,12 @@ interface ComplexTypedArray { * @returns array element or undefined * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -922,14 +853,12 @@ interface ComplexTypedArray { * // returns 1.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -960,14 +889,12 @@ interface ComplexTypedArray { * @returns index or -1 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -983,14 +910,12 @@ interface ComplexTypedArray { * // returns 2 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -1015,14 +940,12 @@ interface ComplexTypedArray { * @returns array element or undefined * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -1044,14 +967,12 @@ interface ComplexTypedArray { * // returns 3.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -1082,14 +1003,12 @@ interface ComplexTypedArray { * @returns index or -1 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -1105,14 +1024,12 @@ interface ComplexTypedArray { * // returns 1 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -1136,14 +1053,12 @@ interface ComplexTypedArray { * @param thisArg - execution context * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function log( v, i ) { * console.log( '%s: %s', i, v.toString() ); @@ -1158,14 +1073,12 @@ interface ComplexTypedArray { * arr.forEach( log ); * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function log( v, i ) { * console.log( '%s: %s', i, v.toString() ); @@ -1189,14 +1102,12 @@ interface ComplexTypedArray { * @returns array element * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -1209,14 +1120,12 @@ interface ComplexTypedArray { * // returns undefined * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -1238,14 +1147,12 @@ interface ComplexTypedArray { * @returns boolean indicating whether an array contains a provided value * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 5 ); * @@ -1265,14 +1172,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 5 ); * @@ -1301,14 +1206,12 @@ interface ComplexTypedArray { * @returns index or -1 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 5 ); * @@ -1328,14 +1231,12 @@ interface ComplexTypedArray { * // returns 3 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 5 ); * @@ -1363,14 +1264,12 @@ interface ComplexTypedArray { * @returns string * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * @@ -1384,14 +1283,12 @@ interface ComplexTypedArray { * // returns '1 + 1i/2 + 2i' * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * @@ -1412,14 +1309,12 @@ interface ComplexTypedArray { * @returns iterator * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * @@ -1438,14 +1333,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * @@ -1473,14 +1366,12 @@ interface ComplexTypedArray { * @returns index or -1 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 5 ); * @@ -1500,14 +1391,12 @@ interface ComplexTypedArray { * // returns 1 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 5 ); * @@ -1536,14 +1425,12 @@ interface ComplexTypedArray { * @returns new array containing transformed elements * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function scale( v ) { * return new Complex64( 2.0 * realf( v ), 2.0 * imagf( v ) ); @@ -1568,14 +1455,12 @@ interface ComplexTypedArray { * // returns -2.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function scale( v ) { * return new Complex128( 2.0 * real( v ), 2.0 * imag( v ) ); @@ -1609,15 +1494,13 @@ interface ComplexTypedArray { * @returns accumulated result * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var caddf = require( '@stdlib/complex/float32/base/add' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -1635,15 +1518,13 @@ interface ComplexTypedArray { * // returns 6.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var cadd = require( '@stdlib/complex/float64/base/add' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -1670,15 +1551,13 @@ interface ComplexTypedArray { * @returns accumulated result * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var caddf = require( '@stdlib/complex/float32/base/add' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -1696,15 +1575,13 @@ interface ComplexTypedArray { * // returns 6.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var cadd = require( '@stdlib/complex/float64/base/add' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -1729,14 +1606,12 @@ interface ComplexTypedArray { * @returns reversed array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -1775,14 +1650,12 @@ interface ComplexTypedArray { * // returns 1.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -1853,14 +1726,12 @@ interface ComplexTypedArray { * @throws target array lacks sufficient storage to accommodate source values * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 10 ); * @@ -1885,14 +1756,12 @@ interface ComplexTypedArray { * // returns -1.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 10 ); * @@ -1927,14 +1796,12 @@ interface ComplexTypedArray { * @returns output array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 5 ); * @@ -1984,14 +1851,12 @@ interface ComplexTypedArray { * // returns -2.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 5 ); * @@ -2050,14 +1915,12 @@ interface ComplexTypedArray { * @returns boolean indicating whether at least one element passes a test * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function predicate( v ) { * return ( realf( v ) === imagf( v ) ); @@ -2073,14 +1936,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -2104,14 +1965,12 @@ interface ComplexTypedArray { * @returns sorted array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function compare( a, b ) { * var re1 = realf( a ); @@ -2170,14 +2029,12 @@ interface ComplexTypedArray { * // returns -3.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function compare( a, b ) { * var re1 = real( a ); @@ -2246,14 +2103,12 @@ interface ComplexTypedArray { * @returns subarray * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 5 ); * @@ -2303,14 +2158,12 @@ interface ComplexTypedArray { * // returns -2.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 5 ); * @@ -2369,14 +2222,12 @@ interface ComplexTypedArray { * @returns string * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * @@ -2387,14 +2238,12 @@ interface ComplexTypedArray { * // returns '1 + 1i,2 + 2i' * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * @@ -2412,14 +2261,12 @@ interface ComplexTypedArray { * @returns reversed array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -2458,14 +2305,12 @@ interface ComplexTypedArray { * // returns 1.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -2512,14 +2357,12 @@ interface ComplexTypedArray { * @returns sorted array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function compare( a, b ) { * var re1 = realf( a ); @@ -2578,14 +2421,12 @@ interface ComplexTypedArray { * // returns -3.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function compare( a, b ) { * var re1 = real( a ); @@ -2651,14 +2492,12 @@ interface ComplexTypedArray { * @returns string * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * @@ -2669,14 +2508,12 @@ interface ComplexTypedArray { * // returns '1 + 1i,2 + 2i' * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * @@ -2694,14 +2531,12 @@ interface ComplexTypedArray { * @returns iterator * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * @@ -2732,14 +2567,12 @@ interface ComplexTypedArray { * // returns true * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * @@ -2782,14 +2615,12 @@ interface ComplexTypedArray { * @returns modified typed array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 3 ); * @@ -2810,14 +2641,12 @@ interface ComplexTypedArray { * // returns 4.0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 3 ); * @@ -2853,14 +2682,12 @@ interface ComplexTypedArrayConstructor { * @returns complex number array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array(); * // returns @@ -2869,14 +2696,12 @@ interface ComplexTypedArrayConstructor { * // returns 0 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * // returns @@ -2885,14 +2710,12 @@ interface ComplexTypedArrayConstructor { * // returns 2 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = new Complex64Array( [ 1.0, -1.0 ] ); * // returns @@ -2902,14 +2725,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var buf = new ArrayBuffer( 16 ); * var arr = new Complex64Array( buf ); @@ -2920,14 +2741,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var buf = new ArrayBuffer( 16 ); * var arr = new Complex64Array( buf, 8 ); @@ -2938,14 +2757,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var buf = new ArrayBuffer( 32 ); * var arr = new Complex64Array( buf, 8, 2 ); @@ -2955,14 +2772,12 @@ interface ComplexTypedArrayConstructor { * // returns 2 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array(); * // returns @@ -2971,14 +2786,12 @@ interface ComplexTypedArrayConstructor { * // returns 0 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * // returns @@ -2987,14 +2800,12 @@ interface ComplexTypedArrayConstructor { * // returns 2 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = new Complex128Array( [ 1.0, -1.0 ] ); * // returns @@ -3004,14 +2815,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var buf = new ArrayBuffer( 32 ); * var arr = new Complex128Array( buf ); @@ -3022,14 +2831,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var buf = new ArrayBuffer( 32 ); * var arr = new Complex128Array( buf, 16 ); @@ -3040,14 +2847,12 @@ interface ComplexTypedArrayConstructor { * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var buf = new ArrayBuffer( 64 ); * var arr = new Complex128Array( buf, 16, 2 ); @@ -3067,14 +2872,12 @@ interface ComplexTypedArrayConstructor { * @returns complex number array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = Complex64Array( 2 ); * // returns @@ -3083,14 +2886,12 @@ interface ComplexTypedArrayConstructor { * // returns 2 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = Complex128Array( 2 ); * // returns @@ -3104,27 +2905,23 @@ interface ComplexTypedArrayConstructor { * Constructor name. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var str = Complex64Array.name; * // returns 'Complex64Array' * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var str = Complex128Array.name; * // returns 'Complex128Array' @@ -3135,27 +2932,23 @@ interface ComplexTypedArrayConstructor { * Size (in bytes) of each array element. * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var nbytes = Complex64Array.BYTES_PER_ELEMENT; * // returns 8 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var nbytes = Complex128Array.BYTES_PER_ELEMENT; * // returns 16 @@ -3174,14 +2967,12 @@ interface ComplexTypedArrayConstructor { * @returns complex number array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); * // returns @@ -3190,14 +2981,12 @@ interface ComplexTypedArrayConstructor { * // returns 1 * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * function clbk( v ) { * return new Complex64( realf( v ) * 2.0, imagf( v ) * 2.0 ); @@ -3210,14 +2999,12 @@ interface ComplexTypedArrayConstructor { * // returns 1 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); * // returns @@ -3226,14 +3013,12 @@ interface ComplexTypedArrayConstructor { * // returns 1 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * function clbk( v ) { * return new Complex128( real( v ) * 2.0, imag( v ) * 2.0 ); @@ -3254,14 +3039,12 @@ interface ComplexTypedArrayConstructor { * @returns complex number array * * @example - * var Float32Array = require( '@stdlib/array/float32' ); * var Complex64 = require( '@stdlib/complex/float32/ctor' ); * var realf = require( '@stdlib/complex/float32/real' ); * var imagf = require( '@stdlib/complex/float32/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); + * var Complex64Array = complexFactory( 'complex64' ); * * var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); * // returns @@ -3270,14 +3053,12 @@ interface ComplexTypedArrayConstructor { * // returns 2 * * @example - * var Float64Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * var real = require( '@stdlib/complex/float64/real' ); * var imag = require( '@stdlib/complex/float64/imag' ); - * var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var complexFactory = require( '@stdlib/array/complex-factory' ); * - * var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); + * var Complex128Array = complexFactory( 'complex128' ); * * var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); * // returns @@ -3292,37 +3073,27 @@ interface ComplexTypedArrayConstructor { * Returns a complex number typed array constructor. * * @param dtype - complex number array data type (e.g., `'complex64'`) -* @param FloatArray - underlying float typed array constructor -* @param ComplexScalar - complex number scalar constructor -* @param getReal - function returning the real component of a complex number -* @param getImag - function returning the imaginary component of a complex number -* @param reinterpret - function reinterpreting a same-type complex array as its underlying float array -* @throws first argument must be a string -* @throws second argument must be a function -* @throws third argument must be a function -* @throws fourth argument must be a function -* @throws fifth argument must be a function -* @throws sixth argument must be a function +* @throws first argument must be a supported data type * @returns complex number array constructor * * @example -* var Float32Array = require( '@stdlib/array/float32' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +* var Complex64Array = complexFactory( 'complex64' ); +* // returns * -* var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +* @example +* var Complex128Array = complexFactory( 'complex128' ); * // returns */ -declare function complexFactory( - dtype: string, - FloatArray: Function, - ComplexScalar: new ( ...args: Array ) => T, - getReal: GetReal, - getImag: GetImag, - reinterpret: Reinterpret -): ComplexTypedArrayConstructor; +declare function complexFactory( dtype: 'complex64' ): ComplexTypedArrayConstructor; + +/** +* Returns a complex number typed array constructor. +* +* @param dtype - complex number array data type (e.g., `'complex128'`) +* @throws first argument must be a supported data type +* @returns complex number array constructor +*/ +declare function complexFactory( dtype: 'complex128' ): ComplexTypedArrayConstructor; // EXPORTS // diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts b/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts index caacd2a0a6bb..e3932da75ed3 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/types/test.ts @@ -18,16 +18,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ -import Float32Array = require( '@stdlib/array/float32' ); -import Float64Array = require( '@stdlib/array/float64' ); import Complex64 = require( '@stdlib/complex/float32/ctor' ); import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import realf = require( '@stdlib/complex/float32/real' ); -import imagf = require( '@stdlib/complex/float32/imag' ); -import real = require( '@stdlib/complex/float64/real' ); -import imag = require( '@stdlib/complex/float64/imag' ); -import reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -import reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); import complexArrayFactory = require( './index' ); @@ -35,70 +27,20 @@ import complexArrayFactory = require( './index' ); // The function returns a constructor function... { - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectType ComplexTypedArrayConstructor - complexArrayFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); // $ExpectType ComplexTypedArrayConstructor + complexArrayFactory( 'complex64' ); // $ExpectType ComplexTypedArrayConstructor + complexArrayFactory( 'complex128' ); // $ExpectType ComplexTypedArrayConstructor } // The compiler throws an error if the function is provided a first argument which is not a string... { - complexArrayFactory( 5, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( true, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( null, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( [], Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( {}, Float32Array, Complex64, realf, imagf, reinterpret64 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - complexArrayFactory( 'complex64', 5, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', 'abc', Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', true, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', null, Complex64, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', [], Complex64, realf, imagf, reinterpret64 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a constructor... -{ - complexArrayFactory( 'complex64', Float32Array, 5, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, 'abc', realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, true, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, null, realf, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, [], realf, imagf, reinterpret64 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - complexArrayFactory( 'complex64', Float32Array, Complex64, 5, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, 'abc', imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, true, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, null, imagf, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, [], imagf, reinterpret64 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a function... -{ - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, 5, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, 'abc', reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, true, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, null, reinterpret64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, [], reinterpret64 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a function... -{ - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, 5 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, 'abc' ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, true ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, null ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf, [] ); // $ExpectError + complexArrayFactory( 5 ); // $ExpectError + complexArrayFactory( true ); // $ExpectError + complexArrayFactory( null ); // $ExpectError + complexArrayFactory( [] ); // $ExpectError + complexArrayFactory( {} ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { complexArrayFactory(); // $ExpectError - complexArrayFactory( 'complex64' ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64 ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf ); // $ExpectError - complexArrayFactory( 'complex64', Float32Array, Complex64, realf, imagf ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/array/complex-factory/examples/index.js b/lib/node_modules/@stdlib/array/complex-factory/examples/index.js index 9e26313d5145..86ed60934df1 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/examples/index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/examples/index.js @@ -22,17 +22,11 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var logEach = require( '@stdlib/console/log-each' ); var complexFactory = require( './../lib' ); -var Complex64Array = complexFactory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); -var Complex128Array = complexFactory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); +var Complex64Array = complexFactory( 'complex64' ); +var Complex128Array = complexFactory( 'complex128' ); // Create a Complex64Array by specifying a length: var out = new Complex64Array( 3 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/index.js b/lib/node_modules/@stdlib/array/complex-factory/lib/index.js index a3e35bf6a067..b092f8f7a589 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/lib/index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/index.js @@ -24,14 +24,9 @@ * @module @stdlib/array/complex-factory * * @example -* var Float32Array = require( '@stdlib/array/float32' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); * var factory = require( '@stdlib/array/complex-factory' ); * -* var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret ); +* var Complex64Array = factory( 'complex64' ); * * var arr = new Complex64Array( 2 ); * // returns @@ -40,14 +35,9 @@ * // returns 2 * * @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); * var factory = require( '@stdlib/array/complex-factory' ); * -* var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret ); +* var Complex128Array = factory( 'complex128' ); * * var arr = new Complex128Array( 2 ); * // returns diff --git a/lib/node_modules/@stdlib/array/complex-factory/lib/main.js b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js index 2197fd758b71..d4e9019777ca 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/lib/main.js +++ b/lib/node_modules/@stdlib/array/complex-factory/lib/main.js @@ -31,7 +31,18 @@ var isArray = require( '@stdlib/assert/is-array' ); var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); +var contains = require( '@stdlib/array/base/assert/contains' ).factory; var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var realf = require( '@stdlib/complex/float32/real' ); +var imagf = require( '@stdlib/complex/float32/imag' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var isEven = require( '@stdlib/math/base/assert/is-even' ); var isInteger = require( '@stdlib/math/base/assert/is-integer' ); var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); @@ -50,6 +61,28 @@ var makeFromArray = require( './from_array.js' ); // VARIABLES // var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); +var DTYPES = [ 'complex64', 'complex128' ]; +var DTYPE2FLOATARRAY = { + 'complex64': Float32Array, + 'complex128': Float64Array +}; +var DTYPE2SCALAR = { + 'complex64': Complex64, + 'complex128': Complex128 +}; +var DTYPE2REAL = { + 'complex64': realf, + 'complex128': real +}; +var DTYPE2IMAG = { + 'complex64': imagf, + 'complex128': imag +}; +var DTYPE2REINTERPRET = { + 'complex64': reinterpret64, + 'complex128': reinterpret128 +}; +var isDataType = contains( DTYPES ); // MAIN // @@ -57,55 +90,37 @@ var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); /** * Returns a complex number array constructor. * -* @param {string} dtype - complex number array data type (e.g., 'complex64') -* @param {Function} FloatArray - underlying float typed array constructor (e.g., Float32Array) -* @param {Function} ComplexScalar - complex number scalar constructor (e.g., Complex64) -* @param {Function} getReal - function returning the real component of a complex number -* @param {Function} getImag - function returning the imaginary component of a complex number -* @param {Function} reinterpret - function reinterpreting a same-type complex array as its underlying float array -* @throws {TypeError} first argument must be a string -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* @throws {TypeError} fourth argument must be a function -* @throws {TypeError} fifth argument must be a function -* @throws {TypeError} sixth argument must be a function -* @throws {Error} must provide valid arguments -* @throws {RangeError} must provide valid arguments +* @param {string} dtype - complex number array data type (e.g., 'complex64' or 'complex128') +* @throws {TypeError} first argument must be a supported data type +* @throws {RangeError} must provide a valid argument +* @throws {Error} must provide an initial value or a non-empty array * @returns {Function} complex number array constructor */ -function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpret ) { +function factory( dtype ) { var BYTES_PER_ELEMENT; var fromIteratorMap; + var ComplexScalar; var fromIterator; + var reinterpret; + var FloatArray; var fromArray; + var getReal; + var getImag; - if ( !isString( dtype ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', dtype ) ); - } - if ( !isFunction( FloatArray ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', FloatArray ) ); - } - if ( !isFunction( ComplexScalar ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', ComplexScalar ) ); - } - if ( !isFunction( getReal ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', getReal ) ); - } - if ( !isFunction( getImag ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', getImag ) ); - } - if ( !isFunction( reinterpret ) ) { - throw new TypeError( format( 'invalid argument. Sixth argument must be a function. Value: `%s`.', reinterpret ) ); + if ( !isDataType( dtype ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) ); } + FloatArray = DTYPE2FLOATARRAY[ dtype ]; + ComplexScalar = DTYPE2SCALAR[ dtype ]; + getReal = DTYPE2REAL[ dtype ]; + getImag = DTYPE2IMAG[ dtype ]; + reinterpret = DTYPE2REINTERPRET[ dtype ]; BYTES_PER_ELEMENT = FloatArray.BYTES_PER_ELEMENT * 2; fromIterator = makeFromIterator( getReal, getImag ); fromIteratorMap = makeFromIteratorMap( getReal, getImag ); fromArray = makeFromArray( getReal, getImag ); - - // FUNCTIONS // - /** * Returns a boolean indicating if a value is a complex typed array. * @@ -119,6 +134,10 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre ( typeof value === 'object' && value !== null && + ( + value.constructor.name === 'Complex64Array' || + value.constructor.name === 'Complex128Array' + ) && typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle ) @@ -135,11 +154,10 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre function isComplexArrayConstructor( value ) { return ( value === ComplexArray || - ( - typeof value === 'function' && - typeof value.BYTES_PER_ELEMENT === 'number' && - value.BYTES_PER_ELEMENT > 0 - ) + + // NOTE: weaker test in order to avoid a circular dependency... + value.name === 'Complex64Array' || + value.name === 'Complex128Array' ); } @@ -156,12 +174,10 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre return new ComplexScalar( buf[ idx ], buf[ idx+1 ] ); } - - // CONSTRUCTOR // - /** * Complex number array constructor. * + * @private * @constructor * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable * @param {NonNegativeInteger} [byteOffset=0] - byte offset @@ -240,7 +256,6 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre } buf = buf[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - // eslint-disable-next-line no-warning-comments // FIXME: `buf` is what is returned from above, NOT the original value throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); } @@ -573,7 +588,6 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre if ( !isComplexArray( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); } - // eslint-disable-next-line no-warning-comments // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled if ( arguments.length === 2 ) { this._buffer.copyWithin( target*2, start*2 ); @@ -1875,7 +1889,7 @@ function factory( dtype, FloatArray, ComplexScalar, getReal, getImag, reinterpre tmp.push( getComplex( buf, i ) ); } tmp.sort( compareFcn ); - return new ComplexArray( tmp ); + return new this.constructor( tmp ); }); /** diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js index 3ec5dd7380db..008e8704f376 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.at.js @@ -23,16 +23,12 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +41,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is an `at` method for returning an array element (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'at' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.at ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is an `at` method for returning an array element (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'at' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.at ), true, 'has method' ); t.end(); @@ -64,7 +60,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -96,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -128,7 +124,7 @@ tape( 'the method throws an error if provided an index argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -161,7 +157,7 @@ tape( 'the method throws an error if provided an index argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -194,7 +190,7 @@ tape( 'the method returns `undefined` if provided an index which exceeds array d var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); for ( i = -arr.length; i < arr.length; i++ ) { if ( i < 0 ) { @@ -214,7 +210,7 @@ tape( 'the method returns `undefined` if provided an index which exceeds array d var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); for ( i = -arr.length; i < arr.length; i++ ) { if ( i < 0 ) { @@ -234,7 +230,7 @@ tape( 'the method returns an array element (complex128)', function test( t ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -260,7 +256,7 @@ tape( 'the method returns an array element (complex64)', function test( t ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js index 5e09b8914df9..4fdd94b6a84f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.copy_within.js @@ -29,12 +29,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -47,14 +41,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `copyWithin` method for copying a sequence of array elements within a complex number array (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'copyWithin' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.copyWithin ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `copyWithin` method for copying a sequence of array elements within a complex number array (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'copyWithin' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.copyWithin ), true, 'has method' ); t.end(); @@ -66,7 +60,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +124,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -162,7 +156,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -193,7 +187,7 @@ tape( 'the method copies a sequence of elements within an array (complex128)', f var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -229,7 +223,7 @@ tape( 'the method copies a sequence of elements within an array (complex64)', fu var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -265,7 +259,7 @@ tape( 'the method copies a sequence of elements within an array (negative target var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -301,7 +295,7 @@ tape( 'the method copies a sequence of elements within an array (negative target var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -337,7 +331,7 @@ tape( 'the method copies a sequence of elements within an array (negative start) var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -373,7 +367,7 @@ tape( 'the method copies a sequence of elements within an array (negative start) var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -409,7 +403,7 @@ tape( 'the method copies a sequence of elements within an array (end=length) (co var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -445,7 +439,7 @@ tape( 'the method copies a sequence of elements within an array (end=length) (co var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -481,7 +475,7 @@ tape( 'the method copies a sequence of elements within an array (non-inclusive e var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -519,7 +513,7 @@ tape( 'the method copies a sequence of elements within an array (non-inclusive e var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -557,7 +551,7 @@ tape( 'the method copies a sequence of elements within an array (negative end) ( var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -595,7 +589,7 @@ tape( 'the method copies a sequence of elements within an array (negative end) ( var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -633,7 +627,7 @@ tape( 'the method copies a sequence of elements within an array (target >= lengt var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -667,7 +661,7 @@ tape( 'the method copies a sequence of elements within an array (target >= lengt var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), @@ -701,7 +695,7 @@ tape( 'the method copies a sequence of elements within an array (target > start) var arr; var buf; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = [ new Complex128( 0.0, -0.0 ), new Complex128( 1.0, -1.0 ), @@ -737,7 +731,7 @@ tape( 'the method copies a sequence of elements within an array (target > start) var arr; var buf; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = [ new Complex64( 0.0, -0.0 ), new Complex64( 1.0, -1.0 ), diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js index 89b107616399..6995eb5d6120 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.entries.js @@ -26,16 +26,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isArray = require( '@stdlib/assert/is-array' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); var factory = require( './../lib' ); @@ -49,14 +43,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is an `entries` method for returning an iterator for iterating over array key-value pairs (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'entries' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.entries ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is an `entries` method for returning an iterator for iterating over array key-value pairs (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'entries' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.entries ), true, 'has method' ); t.end(); @@ -68,7 +62,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -100,7 +94,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -135,7 +129,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex128)', f var i; var j; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -166,7 +160,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex64)', fu var i; var j; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); @@ -195,7 +189,7 @@ tape( 'the method returns an iterator which has a `return` method for closing an var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -241,7 +235,7 @@ tape( 'the method returns an iterator which has a `return` method for closing an var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); @@ -287,7 +281,7 @@ tape( 'the method returns an iterator which has a `return` method for closing an var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -333,7 +327,7 @@ tape( 'the method returns an iterator which has a `return` method for closing an var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); @@ -387,7 +381,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -426,7 +420,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js index 820112c83dc3..461640dfff01 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.every.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is an `every` method for returning boolean indicating whether all elements pass a test (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'every' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.every ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is an `every` method for returning boolean indicating whether all elements pass a test (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'every' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.every ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `true` if operating on an empty complex number array ( var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); bool = arr.every( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `true` if operating on an empty complex number array ( var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); bool = arr.every( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns `true` if all elements pass a test (complex128)', func var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0 ] ); bool = arr.every( predicate ); @@ -252,7 +246,7 @@ tape( 'the method returns `true` if all elements pass a test (complex64)', funct var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); bool = arr.every( predicate ); @@ -269,7 +263,7 @@ tape( 'the method returns `false` if one or more elements fail a test (complex12 var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); bool = arr.every( predicate ); @@ -286,7 +280,7 @@ tape( 'the method returns `false` if one or more elements fail a test (complex64 var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); bool = arr.every( predicate ); @@ -304,7 +298,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var ctx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -327,7 +321,7 @@ tape( 'the method supports providing an execution context (complex64)', function var ctx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js index a5a9af57eb67..cd5e7964d5a6 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.fill.js @@ -27,10 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +41,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `fill` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'fill' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.fill ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `fill` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'fill' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.fill ), true, 'has method' ); t.end(); @@ -64,7 +60,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +93,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +126,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -163,7 +159,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -196,7 +192,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -229,7 +225,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -262,7 +258,7 @@ tape( 'the method throws an error if provided a third argument which is not an i var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -295,7 +291,7 @@ tape( 'the method throws an error if provided a third argument which is not an i var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -327,7 +323,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.fill( new Complex128( 1.0, 1.0 ) ); @@ -341,7 +337,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.fill( new Complex64( 1.0, 1.0 ) ); @@ -355,7 +351,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); out = arr.fill( new Complex128( 1.0, 1.0 ) ); @@ -369,7 +365,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); out = arr.fill( new Complex64( 1.0, 1.0 ) ); @@ -383,7 +379,7 @@ tape( 'if called with one argument, the method sets each array element to the pr var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -398,7 +394,7 @@ tape( 'if called with one argument, the method sets each array element to the pr var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -413,7 +409,7 @@ tape( 'if called with two arguments, the method sets each array element to the p var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -428,7 +424,7 @@ tape( 'if called with two arguments, the method sets each array element to the p var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -443,7 +439,7 @@ tape( 'if called with three arguments, the method sets each array element to the var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); @@ -458,7 +454,7 @@ tape( 'if called with three arguments, the method sets each array element to the var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); @@ -473,7 +469,7 @@ tape( 'the method supports negative indices (complex128)', function test( t ) { var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); @@ -488,7 +484,7 @@ tape( 'the method supports negative indices (complex64)', function test( t ) { var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); @@ -503,7 +499,7 @@ tape( 'if a provided start index resolves to a negative index, the method fills var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -518,7 +514,7 @@ tape( 'if a provided start index resolves to a negative index, the method fills var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -533,7 +529,7 @@ tape( 'if a provided end index resolves to an index exceeding the last array ele var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -548,7 +544,7 @@ tape( 'if a provided end index resolves to an index exceeding the last array ele var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); @@ -563,7 +559,7 @@ tape( 'if a provided start index resolves to an index which is greater than or e var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 3 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -578,7 +574,7 @@ tape( 'if a provided start index resolves to an index which is greater than or e var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 3 ); expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js index 79ddfc599b3c..6570ef724e65 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.filter.js @@ -26,8 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); @@ -46,14 +44,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `filter` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'filter' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.filter ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `filter` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'filter' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.filter ), true, 'has method' ); t.end(); @@ -65,7 +63,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -102,7 +100,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -139,7 +137,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -171,7 +169,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -202,7 +200,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.filter( predicate ); @@ -219,7 +217,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.filter( predicate ); @@ -237,7 +235,7 @@ tape( 'the method returns a new complex number array containing only those eleme var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); actual = arr.filter( predicate ); @@ -258,7 +256,7 @@ tape( 'the method returns a new complex number array containing only those eleme var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); actual = arr.filter( predicate ); @@ -279,7 +277,7 @@ tape( 'the method copies all elements to a new array if all elements satisfy a t var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.filter( predicate ); @@ -301,7 +299,7 @@ tape( 'the method copies all elements to a new array if all elements satisfy a t var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.filter( predicate ); @@ -324,7 +322,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var ctx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); ctx = { @@ -351,7 +349,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var ctx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); ctx = { diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js index 7ec0a870d4fc..8c0b05e5216c 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `find` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'find' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.find ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `find` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'find' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.find ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `undefined` if operating on an empty complex number ar var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); z = arr.find( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `undefined` if operating on an empty complex number ar var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); z = arr.find( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns the first element which passes a test (complex128)', f var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); z = arr.find( predicate ); @@ -253,7 +247,7 @@ tape( 'the method returns the first element which passes a test (complex64)', fu var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); z = arr.find( predicate ); @@ -271,7 +265,7 @@ tape( 'the method returns `undefined` if all elements fail a test (complex128)', var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); z = arr.find( predicate ); @@ -288,7 +282,7 @@ tape( 'the method returns `undefined` if all elements fail a test (complex64)', var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); z = arr.find( predicate ); @@ -306,7 +300,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -330,7 +324,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js index 14a27f6c6767..d89e0a91c7a2 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_index.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `findIndex` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findIndex' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.findIndex ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `findIndex` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findIndex' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.findIndex ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); idx = arr.findIndex( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); idx = arr.findIndex( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns the index of the first element which passes a test (co var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); idx = arr.findIndex( predicate ); @@ -252,7 +246,7 @@ tape( 'the method returns the index of the first element which passes a test (co var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); idx = arr.findIndex( predicate ); @@ -269,7 +263,7 @@ tape( 'the method returns `-1` if all elements fail a test (complex128)', functi var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); idx = arr.findIndex( predicate ); @@ -286,7 +280,7 @@ tape( 'the method returns `-1` if all elements fail a test (complex64)', functio var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); idx = arr.findIndex( predicate ); @@ -304,7 +298,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -327,7 +321,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js index 03c6da1267db..6a2080da832e 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `findLast` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLast' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.findLast ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `findLast` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLast' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.findLast ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `undefined` if operating on an empty complex number ar var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); z = arr.findLast( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `undefined` if operating on an empty complex number ar var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); z = arr.findLast( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns the last element which passes a test (complex128)', fu var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); z = arr.findLast( predicate ); @@ -253,7 +247,7 @@ tape( 'the method returns the last element which passes a test (complex64)', fun var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); z = arr.findLast( predicate ); @@ -271,7 +265,7 @@ tape( 'the method returns `undefined` if all elements fail a test (complex128)', var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); z = arr.findLast( predicate ); @@ -288,7 +282,7 @@ tape( 'the method returns `undefined` if all elements fail a test (complex64)', var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); z = arr.findLast( predicate ); @@ -306,7 +300,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var z; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -330,7 +324,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var z; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js index 5e7fb855a4d1..5239667e97cd 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.find_last_index.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `findLastIndex` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLastIndex' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.findLastIndex ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `findLastIndex` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLastIndex' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.findLastIndex ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); idx = arr.findLastIndex( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); idx = arr.findLastIndex( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns the index of the last element which passes a test (com var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); idx = arr.findLastIndex( predicate ); @@ -252,7 +246,7 @@ tape( 'the method returns the index of the last element which passes a test (com var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); idx = arr.findLastIndex( predicate ); @@ -269,7 +263,7 @@ tape( 'the method returns `-1` if all elements fail a test (complex128)', functi var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); idx = arr.findLastIndex( predicate ); @@ -286,7 +280,7 @@ tape( 'the method returns `-1` if all elements fail a test (complex64)', functio var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); idx = arr.findLastIndex( predicate ); @@ -304,7 +298,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -327,7 +321,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js index 0d90ad84b7a8..ab7a234c7891 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.for_each.js @@ -25,14 +25,6 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -47,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `forEach` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'forEach' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.forEach ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `forEach` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'forEach' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.forEach ), true, 'has method' ); t.end(); @@ -66,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -105,7 +97,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -144,7 +136,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -176,7 +168,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -206,7 +198,7 @@ tape( 'the method should not invoke a provided callback function if operating on var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); arr.forEach( fcn ); @@ -221,7 +213,7 @@ tape( 'the method should not invoke a provided callback function if operating on var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); arr.forEach( fcn ); @@ -237,7 +229,7 @@ tape( 'the method returns `undefined` (complex128)', function test( t ) { var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); out = arr.forEach( fcn ); @@ -256,7 +248,7 @@ tape( 'the method returns `undefined` (complex64)', function test( t ) { var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); out = arr.forEach( fcn ); @@ -275,7 +267,7 @@ tape( 'the method invokes a provided function for each element in an array (comp var expected; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); expected = []; arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); arr.forEach( fcn ); @@ -294,7 +286,7 @@ tape( 'the method invokes a provided function for each element in an array (comp var expected; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); expected = []; arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); arr.forEach( fcn ); @@ -313,7 +305,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var ctx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -333,7 +325,7 @@ tape( 'the method supports providing an execution context (complex64)', function var ctx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js index 08cf324181af..368bf709ef94 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.from.js @@ -31,8 +31,6 @@ var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); var factory = require( './../lib' ); @@ -49,7 +47,7 @@ tape( 'attached to the returned constructor is a `from` method for creating a co var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array, 'from' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.from ), true, 'has method' ); @@ -64,7 +62,7 @@ tape( 'attached to the returned constructor is a `from` method for creating a co var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array, 'from' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.from ), true, 'has method' ); @@ -80,7 +78,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -110,7 +108,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -140,7 +138,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ Complex128, @@ -163,7 +161,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ Complex64, @@ -186,7 +184,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -216,7 +214,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -246,7 +244,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -280,7 +278,7 @@ tape( 'the method throws an error if not provided an iterable or array-like obje var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -314,7 +312,7 @@ tape( 'the method throws an error if provided a second argument which is not a f var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -344,7 +342,7 @@ tape( 'the method throws an error if provided a second argument which is not a f var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -375,7 +373,7 @@ tape( 'the method returns a complex number array (complex128)', function test( t var z; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); // Generic array: arr = Complex128Array.from( [] ); @@ -433,7 +431,7 @@ tape( 'the method returns a complex number array (complex64)', function test( t var z; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); // Generic array: arr = Complex64Array.from( [] ); @@ -497,7 +495,7 @@ tape( 'the method returns a complex number array (iterable) (complex128)', funct t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); iter1 = { 'next': next1, @@ -570,7 +568,7 @@ tape( 'the method returns a complex number array (iterable) (complex64)', functi t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); iter1 = { 'next': next1, @@ -637,7 +635,7 @@ tape( 'the method supports providing a "map" function which is invoked for each var z; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); // Generic array: arr = Complex128Array.from( [], clbk1 ); @@ -713,7 +711,7 @@ tape( 'the method supports providing a "map" function which is invoked for each var z; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); // Generic array: arr = Complex64Array.from( [], clbk1 ); @@ -795,7 +793,7 @@ tape( 'the method supports providing a "map" function which is invoked for each t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); iter1 = { 'next': next1, @@ -878,7 +876,7 @@ tape( 'the method supports providing a "map" function which is invoked for each t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); iter1 = { 'next': next1, @@ -954,7 +952,7 @@ tape( 'the method supports providing a `this` context for a provided map functio var arr; var ctx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 @@ -989,7 +987,7 @@ tape( 'the method supports providing a `this` context for a provided map functio var arr; var ctx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 @@ -1030,7 +1028,7 @@ tape( 'the method supports providing a `this` context for a provided map functio t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); iter = { 'next': next, @@ -1088,7 +1086,7 @@ tape( 'the method supports providing a `this` context for a provided map functio t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); iter = { 'next': next, @@ -1140,7 +1138,7 @@ tape( 'the method throws an error if provided a generic array-like object having var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ [ 1, 2, 3 ], @@ -1170,7 +1168,7 @@ tape( 'the method throws an error if provided a generic array-like object having var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ [ 1, 2, 3 ], @@ -1209,7 +1207,7 @@ tape( 'the method throws an error if provided a non-iterable object (ES2015+) (c t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); obj3 = {}; obj3[ ITERATOR_SYMBOL ] = null; @@ -1269,7 +1267,7 @@ tape( 'the method throws an error if provided a non-iterable object (ES2015+) (c t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); obj3 = {}; obj3[ ITERATOR_SYMBOL ] = null; @@ -1321,7 +1319,7 @@ tape( 'the method throws an error if provided a complex number source array and var clbks; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ [ new Complex128( 1.0, 1.0 ) ], @@ -1357,7 +1355,7 @@ tape( 'the method throws an error if provided a complex number source array and var clbks; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ [ new Complex64( 1.0, 1.0 ) ], @@ -1400,7 +1398,7 @@ tape( 'the method throws an error if provided a "map" function which does not re t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); obj1 = {}; obj1[ ITERATOR_SYMBOL ] = createIterable( next1 ); @@ -1471,7 +1469,7 @@ tape( 'the method throws an error if provided a "map" function which does not re t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); obj1 = {}; obj1[ ITERATOR_SYMBOL ] = createIterable( next1 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js index ed80ff4c83e9..6d7da923ddd5 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.get.js @@ -23,16 +23,12 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +41,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `get` method for returning an array element (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'get' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.get ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `get` method for returning an array element (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'get' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.get ), true, 'has method' ); t.end(); @@ -64,7 +60,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -96,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -128,7 +124,7 @@ tape( 'the method throws an error if provided an index argument which is not a n var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -162,7 +158,7 @@ tape( 'the method throws an error if provided an index argument which is not a n var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -196,7 +192,7 @@ tape( 'the method returns `undefined` if provided an index which exceeds array d var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); for ( i = 0; i < arr.length; i++ ) { v = arr.get( arr.length+i ); @@ -211,7 +207,7 @@ tape( 'the method returns `undefined` if provided an index which exceeds array d var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); for ( i = 0; i < arr.length; i++ ) { v = arr.get( arr.length+i ); @@ -226,7 +222,7 @@ tape( 'the method returns an array element (complex128)', function test( t ) { var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex128( i, -i ) ); @@ -247,7 +243,7 @@ tape( 'the method returns an array element (complex64)', function test( t ) { var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = []; for ( i = 0; i < 10; i++ ) { arr.push( new Complex64( i, -i ) ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js index 2ae142bceac3..2b9a417394d7 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.includes.js @@ -23,16 +23,8 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +37,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is an `includes` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'includes' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.includes ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is an `includes` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'includes' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.includes ), true, 'has method' ); t.end(); @@ -64,7 +56,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +89,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +122,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -163,7 +155,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -196,7 +188,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -229,7 +221,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -261,7 +253,7 @@ tape( 'the method returns `false` if operating on an empty complex number array var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); bool = arr.includes( new Complex128( 1.0, 1.0 ) ); @@ -274,7 +266,7 @@ tape( 'the method returns `false` if operating on an empty complex number array var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); bool = arr.includes( new Complex64( 1.0, 1.0 ) ); @@ -287,7 +279,7 @@ tape( 'the method returns `false` if a complex number is not found (complex128)' var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); bool = arr.includes( new Complex128( 1.0, 1.0 ) ); @@ -300,7 +292,7 @@ tape( 'the method returns `false` if a complex number is not found (complex64)', var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); bool = arr.includes( new Complex64( 1.0, 1.0 ) ); @@ -313,7 +305,7 @@ tape( 'the method returns `true` if an array contains a specified complex number var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -330,7 +322,7 @@ tape( 'the method returns `true` if an array contains a specified complex number var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -347,7 +339,7 @@ tape( 'the method returns `false` if provided a second argument which exceeds th var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); bool = arr.includes( new Complex128( 1.0, 1.0 ), 20 ); @@ -360,7 +352,7 @@ tape( 'the method returns `false` if provided a second argument which exceeds th var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); bool = arr.includes( new Complex64( 1.0, 1.0 ), 20 ); @@ -373,7 +365,7 @@ tape( 'the method supports specifying a starting search index (complex128)', fun var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -396,7 +388,7 @@ tape( 'the method supports specifying a starting search index (complex64)', func var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -419,7 +411,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -440,7 +432,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -461,7 +453,7 @@ tape( 'when provided a starting index which resolves to an index which is less t var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -482,7 +474,7 @@ tape( 'when provided a starting index which resolves to an index which is less t var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js index 630eacad8bdf..5820774fe34a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.index_of.js @@ -23,16 +23,8 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +37,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is an `indexOf` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'indexOf' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.indexOf ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is an `indexOf` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'indexOf' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.indexOf ), true, 'has method' ); t.end(); @@ -64,7 +56,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +89,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +122,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -163,7 +155,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -196,7 +188,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -229,7 +221,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -261,7 +253,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); @@ -274,7 +266,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); @@ -287,7 +279,7 @@ tape( 'the method returns `-1` if a complex number is not found (complex128)', f var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); @@ -300,7 +292,7 @@ tape( 'the method returns `-1` if a complex number is not found (complex64)', fu var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); @@ -313,7 +305,7 @@ tape( 'the method returns the index of the first match if a complex number is fo var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -331,7 +323,7 @@ tape( 'the method returns the index of the first match if a complex number is fo var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -349,7 +341,7 @@ tape( 'the method returns `-1` if provided a second argument which exceeds the i var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); idx = arr.indexOf( new Complex128( 1.0, 1.0 ), 20 ); @@ -362,7 +354,7 @@ tape( 'the method returns `-1` if provided a second argument which exceeds the i var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); idx = arr.indexOf( new Complex64( 1.0, 1.0 ), 20 ); @@ -375,7 +367,7 @@ tape( 'the method supports specifying a starting search index (complex128)', fun var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -399,7 +391,7 @@ tape( 'the method supports specifying a starting search index (complex64)', func var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -423,7 +415,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -444,7 +436,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -465,7 +457,7 @@ tape( 'when provided a starting index which resolves to an index which is less t var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -486,7 +478,7 @@ tape( 'when provided a starting index which resolves to an index which is less t var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js index 1f60e5623868..2b6467eb2138 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.join.js @@ -23,16 +23,6 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +35,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `join` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'join' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.join ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `join` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'join' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.join ), true, 'has method' ); t.end(); @@ -64,7 +54,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +87,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +120,7 @@ tape( 'the method throws an error if invoked with a `separator` argument which i var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -162,7 +152,7 @@ tape( 'the method throws an error if invoked with a `separator` argument which i var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -193,7 +183,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex1 var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); str = arr.join(); @@ -206,7 +196,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex6 var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); str = arr.join(); @@ -220,7 +210,7 @@ tape( 'the method returns a string representation of a complex number array with var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i@-3 - 4i'; @@ -236,7 +226,7 @@ tape( 'the method returns a string representation of a complex number array with var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i@-3 - 4i'; @@ -252,7 +242,7 @@ tape( 'the method returns a string representation of a complex number array with var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2 ] ); expected = '1 + 2i'; @@ -273,7 +263,7 @@ tape( 'the method returns a string representation of a complex number array with var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2 ] ); expected = '1 + 2i'; @@ -294,7 +284,7 @@ tape( 'if method invoked without a separator argument, the method returns a stri var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; @@ -310,7 +300,7 @@ tape( 'if method invoked without a separator argument, the method returns a stri var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.js index 5fda8a3eecf8..1154f6ea5a58 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.js @@ -30,8 +30,6 @@ var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); @@ -69,196 +67,56 @@ tape( 'the function throws an error if provided a first argument which is not a function badValue( value ) { return function badValue() { - factory( value, Float32Array, Complex64, realf, imagf, reinterpret64 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'complex64', value, Complex64, realf, imagf, reinterpret64 ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'complex64', Float32Array, value, realf, imagf, reinterpret64 ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'complex64', Float32Array, Complex64, value, imagf, reinterpret64 ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'complex64', Float32Array, Complex64, realf, value, reinterpret64 ); - }; - } -}); - -tape( 'the function throws an error if provided a sixth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws a TypeError when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'complex64', Float32Array, Complex64, realf, imagf, value ); + factory( value ); }; } }); tape( 'the function returns a function (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( typeof Complex64Array, 'function', 'returns a function' ); t.end(); }); tape( 'the function returns a function (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( typeof Complex128Array, 'function', 'returns a function' ); t.end(); }); tape( 'the returned constructor has the correct name (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( Complex64Array.name, 'Complex64Array', 'has correct name' ); t.end(); }); tape( 'the returned constructor has the correct name (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( Complex128Array.name, 'Complex128Array', 'has correct name' ); t.end(); }); tape( 'the returned constructor has the correct BYTES_PER_ELEMENT (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( Complex64Array.BYTES_PER_ELEMENT, 8, 'has correct BYTES_PER_ELEMENT' ); t.end(); }); tape( 'the returned constructor has the correct BYTES_PER_ELEMENT (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( Complex128Array.BYTES_PER_ELEMENT, 16, 'has correct BYTES_PER_ELEMENT' ); t.end(); }); tape( 'the returned constructor creates an empty array by default', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array(); t.strictEqual( arr.length, 0, 'has length 0' ); t.end(); }); tape( 'the returned constructor creates an array of a specified length', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( 10 ); t.strictEqual( arr.length, 10, 'has length 10' ); t.end(); @@ -269,7 +127,7 @@ tape( 'the returned constructor is a constructor (no new) (complex128)', functio var ctor; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctor = Complex128Array; arr = ctor( 0 ); @@ -282,7 +140,7 @@ tape( 'the returned constructor is a constructor (no new) (complex64)', function var ctor; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctor = Complex64Array; arr = ctor( 0 ); @@ -291,70 +149,70 @@ tape( 'the returned constructor is a constructor (no new) (complex64)', function }); tape( 'the returned constructor returns an array (no argument) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array(); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (no argument) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array(); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (length) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( 10 ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (length) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( 10 ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (array) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( [] ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (array) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( [] ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (typed array) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( new Float64Array( 0 ) ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (typed array) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( new Float32Array( 0 ) ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (complex typed array) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( new Complex128Array( 0 ) ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (complex typed array) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( new Complex64Array( 0 ) ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); @@ -364,7 +222,7 @@ tape( 'the returned constructor returns an array (iterable) (complex128)', funct var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( createIterable() ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); @@ -392,7 +250,7 @@ tape( 'the returned constructor returns an array (iterable) (complex64)', functi var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( createIterable() ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); @@ -417,56 +275,56 @@ tape( 'the returned constructor returns an array (iterable) (complex64)', functi }); tape( 'the returned constructor returns an array (ArrayBuffer) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( new ArrayBuffer( 0 ) ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (ArrayBuffer) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( new ArrayBuffer( 0 ) ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (ArrayBuffer, byte offset) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( new ArrayBuffer( 32 ), 16 ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (ArrayBuffer, byte offset) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( new ArrayBuffer( 16 ), 8 ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (ArrayBuffer, byte offset, length) (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); var arr = new Complex128Array( new ArrayBuffer( 32 ), 16, 0 ); t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor returns an array (ArrayBuffer, byte offset, length) (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); var arr = new Complex64Array( new ArrayBuffer( 16 ), 8, 0 ); t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); t.end(); }); tape( 'the returned constructor has a BYTES_PER_ELEMENT property (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); t.strictEqual( Complex128Array.BYTES_PER_ELEMENT, 16, 'returns expected value' ); t.end(); }); tape( 'the returned constructor has a BYTES_PER_ELEMENT property (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); t.strictEqual( Complex64Array.BYTES_PER_ELEMENT, 8, 'returns expected value' ); t.end(); @@ -476,7 +334,7 @@ tape( 'the returned constructor instance has a BYTES_PER_ELEMENT property (compl var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); t.strictEqual( Complex128Array.prototype.BYTES_PER_ELEMENT, 16, 'returns expected value' ); @@ -489,7 +347,7 @@ tape( 'the returned constructor instance has a BYTES_PER_ELEMENT property (compl var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); t.strictEqual( Complex64Array.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); @@ -502,7 +360,7 @@ tape( 'the returned constructor instance has a `buffer` property (complex128)', var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 0 ); t.strictEqual( isArrayBuffer( arr.buffer ), true, 'returns expected value' ); t.end(); @@ -512,7 +370,7 @@ tape( 'the returned constructor instance has a `buffer` property (complex64)', f var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 0 ); t.strictEqual( isArrayBuffer( arr.buffer ), true, 'returns expected value' ); t.end(); @@ -523,7 +381,7 @@ tape( 'the returned constructor instance has a `byteLength` property (complex128 var arr; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 0 ); v = arr.byteLength; @@ -544,7 +402,7 @@ tape( 'the returned constructor instance has a `byteLength` property (complex64) var arr; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 0 ); v = arr.byteLength; @@ -565,7 +423,7 @@ tape( 'the returned constructor instance has a `byteOffset` property (complex128 var arr; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 0 ); v = arr.byteOffset; @@ -586,7 +444,7 @@ tape( 'the returned constructor instance has a `byteOffset` property (complex64) var arr; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 0 ); v = arr.byteOffset; @@ -608,7 +466,7 @@ tape( 'the returned constructor instance has a `length` property (complex128)', var z; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); v = arr.length; @@ -667,7 +525,7 @@ tape( 'the returned constructor instance has a `length` property (complex64)', f var z; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); v = arr.length; @@ -727,7 +585,7 @@ tape( 'the returned constructor instance has a `length` property (iterable) (com var arr; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); iter1 = { 'next': next1, @@ -791,7 +649,7 @@ tape( 'the returned constructor instance has a `length` property (iterable) (com var arr; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); iter1 = { 'next': next1, @@ -853,7 +711,7 @@ tape( 'the returned constructor throws an error if provided an ArrayBuffer whose var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ 1, 2, 3, 4, 5, 6, 7, 9, 24, 74, 801 ]; for ( i = 0; i < values.length; i++ ) { @@ -873,7 +731,7 @@ tape( 'the returned constructor throws an error if provided an ArrayBuffer whose var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ 1, 2, 3, 5, 6, 7, 9, 13, 801 ]; for ( i = 0; i < values.length; i++ ) { @@ -893,7 +751,7 @@ tape( 'the returned constructor throws an error if provided an array-like object var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ [ 1, 2, 3 ], @@ -922,7 +780,7 @@ tape( 'the returned constructor throws an error if provided an array-like object var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ [ 1, 2, 3 ], @@ -951,7 +809,7 @@ tape( 'the returned constructor throws an error if provided a non-iterable objec var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ {}, @@ -978,7 +836,7 @@ tape( 'the returned constructor throws an error if provided a non-iterable objec var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ {}, @@ -1005,7 +863,7 @@ tape( 'the returned constructor throws an error if not provided a length, iterab var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -1035,7 +893,7 @@ tape( 'the returned constructor throws an error if not provided a length, iterab var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -1065,7 +923,7 @@ tape( 'the returned constructor throws an error if provided more than one argume var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -1096,7 +954,7 @@ tape( 'the returned constructor throws an error if provided more than one argume var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -1127,7 +985,7 @@ tape( 'the returned constructor throws an error if provided a byte offset which var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -1159,7 +1017,7 @@ tape( 'the returned constructor throws an error if provided a byte offset which var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -1191,7 +1049,7 @@ tape( 'the returned constructor throws an error if provided a byte offset which var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ 1, 2, 3, 4, 5, 6, 7, 9, 24, 65, 78, 801 ]; for ( i = 0; i < values.length; i++ ) { @@ -1211,7 +1069,7 @@ tape( 'the returned constructor throws an error if provided a byte offset which var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ 1, 2, 3, 5, 6, 7, 9, 13, 801 ]; for ( i = 0; i < values.length; i++ ) { @@ -1231,7 +1089,7 @@ tape( 'the returned constructor throws an error if provided a length argument wh var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -1263,7 +1121,7 @@ tape( 'the returned constructor throws an error if provided a length argument wh var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -1295,7 +1153,7 @@ tape( 'the returned constructor throws an error if provided insufficient memory var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ 16, 24, 32, 48 ]; for ( i = 0; i < values.length; i++ ) { @@ -1315,7 +1173,7 @@ tape( 'the returned constructor throws an error if provided insufficient memory var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ 8, 16, 24, 32 ]; for ( i = 0; i < values.length; i++ ) { diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js index d19b00c8003c..1dd2cad53bea 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.keys.js @@ -23,16 +23,6 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); var factory = require( './../lib' ); @@ -46,14 +36,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `keys` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'keys' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.keys ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `keys` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'keys' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.keys ), true, 'has method' ); t.end(); @@ -65,7 +55,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +88,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -134,7 +124,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex128)', f var r; var e; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); expected = [ { @@ -176,7 +166,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex64)', fu var r; var e; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); expected = [ { @@ -217,7 +207,7 @@ tape( 'the method returns an iterator which does not iterate over empty arrays ( var i; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [] ); expected = [ { @@ -250,7 +240,7 @@ tape( 'the method returns an iterator which does not iterate over empty arrays ( var i; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [] ); expected = [ { @@ -281,7 +271,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (no a var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.keys(); @@ -314,7 +304,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (no a var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.keys(); @@ -347,7 +337,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (argu var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.keys(); @@ -380,7 +370,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (argu var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.keys(); @@ -417,7 +407,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera var v2; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -449,7 +439,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera var v2; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js index 8705e8b5d739..1239120090ac 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.last_index_of.js @@ -23,16 +23,8 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +37,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `lastIndexOf` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'lastIndexOf' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.lastIndexOf ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `lastIndexOf` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'lastIndexOf' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.lastIndexOf ), true, 'has method' ); t.end(); @@ -64,7 +56,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +89,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +122,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -163,7 +155,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -196,7 +188,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -229,7 +221,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -261,7 +253,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); @@ -274,7 +266,7 @@ tape( 'the method returns `-1` if operating on an empty complex number array (co var arr; var idx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); @@ -287,7 +279,7 @@ tape( 'the method returns `-1` if a complex number is not found (complex128)', f var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); @@ -300,7 +292,7 @@ tape( 'the method returns `-1` if a complex number is not found (complex64)', fu var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); @@ -313,7 +305,7 @@ tape( 'the method returns the index of the first match when searching from the e var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -330,7 +322,7 @@ tape( 'the method returns the index of the first match when searching from the e var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -347,7 +339,7 @@ tape( 'the method supports specifying a starting search index (complex128)', fun var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -371,7 +363,7 @@ tape( 'the method supports specifying a starting search index (complex64)', func var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -395,7 +387,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -416,7 +408,7 @@ tape( 'the method supports specifying a starting search index (negative) (comple var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -437,7 +429,7 @@ tape( 'when the method is provided a starting index which resolves to an index w var idx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); @@ -458,7 +450,7 @@ tape( 'when the method is provided a starting index which resolves to an index w var idx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); arr.set( [ 1.0, 1.0 ], 0 ); arr.set( [ 2.0, 2.0 ], 1 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js index ac3e92e517eb..06964c4d8fac 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.map.js @@ -47,14 +47,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `map` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'map' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.map ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `map` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'map' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.map ), true, 'has method' ); t.end(); @@ -66,7 +66,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -99,7 +99,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -132,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -164,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -195,7 +195,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.map( identity ); @@ -210,7 +210,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.map( identity ); @@ -226,7 +226,7 @@ tape( 'the method returns a new complex number array containing elements which a var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); actual = arr.map( scale ); @@ -248,7 +248,7 @@ tape( 'the method returns a new complex number array containing elements which a var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); actual = arr.map( scale ); @@ -271,7 +271,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var arr; var ctx; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); ctx = { @@ -298,7 +298,7 @@ tape( 'the method supports providing an execution context (complex64)', function var arr; var ctx; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); ctx = { @@ -324,7 +324,7 @@ tape( 'the method supports a map function which returns a two-element array cont var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); actual = arr.map( scale ); @@ -345,7 +345,7 @@ tape( 'the method supports a map function which returns a two-element array cont var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); actual = arr.map( scale ); @@ -366,7 +366,7 @@ tape( 'the method throws an error if provided a map function which does not retu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); clbks = [ clbk1, @@ -413,7 +413,7 @@ tape( 'the method throws an error if provided a map function which does not retu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); clbks = [ clbk1, diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js index 8591c0de9e75..6c1893e60fc4 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.of.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -48,7 +42,7 @@ tape( 'attached to the returned constructor is an `of` method for creating a com var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array, 'of' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.of ), true, 'has method' ); @@ -63,7 +57,7 @@ tape( 'attached to the returned constructor is an `of` method for creating a com var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array, 'of' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.of ), true, 'has method' ); @@ -79,7 +73,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ '5', @@ -109,7 +103,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ '5', @@ -139,7 +133,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); values = [ Complex128, @@ -162,7 +156,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var values; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); values = [ Complex64, @@ -186,7 +180,7 @@ tape( 'the method returns a complex number array (complex128)', function test( t var z; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); // No arguments: arr = Complex128Array.of(); @@ -242,7 +236,7 @@ tape( 'the method returns a complex number array (complex64)', function test( t var z; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); // No arguments: arr = Complex64Array.of(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js index d582a034f670..0f075b995a05 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce.js @@ -26,16 +26,12 @@ var isFunction = require( '@stdlib/assert/is-function' ); var cadd128 = require( '@stdlib/complex/float64/base/add' ); var cadd64 = require( '@stdlib/complex/float32/base/add' ); var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -48,14 +44,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `reduce` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduce' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.reduce ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `reduce` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduce' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.reduce ), true, 'has method' ); t.end(); @@ -67,7 +63,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -100,7 +96,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -133,7 +129,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -165,7 +161,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -195,7 +191,7 @@ tape( 'the method throws an error if not provided an initial value when operatin var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 0 ); t.throws( foo, Error, 'throws an error' ); t.end(); @@ -209,7 +205,7 @@ tape( 'the method throws an error if not provided an initial value when operatin var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 0 ); t.throws( foo, Error, 'throws an error' ); t.end(); @@ -227,7 +223,7 @@ tape( 'the method uses the first element of the array as the initial value when var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); accArray = [ 1.0, -1.0, 3.0, -3.0 ]; valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; @@ -260,7 +256,7 @@ tape( 'the method uses the first element of the array as the initial value when var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); accArray = [ 1.0, -1.0, 3.0, -3.0 ]; valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; @@ -293,7 +289,7 @@ tape( 'the method supports providing an initial value as the second argument (co var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; @@ -325,7 +321,7 @@ tape( 'the method supports providing an initial value as the second argument (co var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; @@ -355,7 +351,7 @@ tape( 'the method returns the accumulated result (complex128)', function test( t var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Complex128( 6.0, -6.0 ); actual = arr.reduce( cadd128 ); @@ -372,7 +368,7 @@ tape( 'the method returns the accumulated result (complex64)', function test( t var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Complex64( 6.0, -6.0 ); actual = arr.reduce( cadd64 ); @@ -389,7 +385,7 @@ tape( 'the method supports returning real-valued results (complex128)', function var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = 6.0; actual = arr.reduce( reducer, 0.0 ); @@ -408,7 +404,7 @@ tape( 'the method supports returning real-valued results (complex64)', function var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = 6.0; actual = arr.reduce( reducer, 0.0 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js index e820e5659608..afd81c72ffc4 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reduce_right.js @@ -26,16 +26,12 @@ var isFunction = require( '@stdlib/assert/is-function' ); var cadd128 = require( '@stdlib/complex/float64/base/add' ); var cadd64 = require( '@stdlib/complex/float32/base/add' ); var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -48,14 +44,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `reduceRight` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduceRight' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.reduceRight ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `reduceRight` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduceRight' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.reduceRight ), true, 'has method' ); t.end(); @@ -67,7 +63,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -100,7 +96,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -133,7 +129,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -165,7 +161,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -195,7 +191,7 @@ tape( 'the method throws an error if not provided an initial value when operatin var Complex128Array; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 0 ); t.throws( foo, Error, 'throws an error' ); t.end(); @@ -209,7 +205,7 @@ tape( 'the method throws an error if not provided an initial value when operatin var Complex64Array; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 0 ); t.throws( foo, Error, 'throws an error' ); t.end(); @@ -228,7 +224,7 @@ tape( 'the method uses the last element of the array as the initial value when a var arr; var len; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); len = arr.length; accArray = [ 3.0, -3.0, 5.0, -5.0 ]; @@ -263,7 +259,7 @@ tape( 'the method uses the last element of the array as the initial value when a var arr; var len; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); len = arr.length; accArray = [ 3.0, -3.0, 5.0, -5.0 ]; @@ -298,7 +294,7 @@ tape( 'the method supports providing an initial value as the second argument (co var arr; var len; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); len = arr.length; accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; @@ -333,7 +329,7 @@ tape( 'the method supports providing an initial value as the second argument (co var arr; var len; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); len = arr.length; accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; @@ -365,7 +361,7 @@ tape( 'the method returns the accumulated result (complex128)', function test( t var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Complex128( 6.0, -6.0 ); actual = arr.reduceRight( cadd128 ); @@ -382,7 +378,7 @@ tape( 'the method returns the accumulated result (complex64)', function test( t var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Complex64( 6.0, -6.0 ); actual = arr.reduceRight( cadd64 ); @@ -399,7 +395,7 @@ tape( 'the method supports returning real-valued results (complex128)', function var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = 6.0; actual = arr.reduceRight( reducer, 0.0 ); @@ -418,7 +414,7 @@ tape( 'the method supports returning real-valued results (complex64)', function var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = 6.0; actual = arr.reduceRight( reducer, 0.0 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js index eb915cd4fcc1..54cbef1cc200 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.reverse.js @@ -26,12 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -46,14 +40,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `reverse` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reverse' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.reverse ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `reverse` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reverse' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.reverse ), true, 'has method' ); t.end(); @@ -65,7 +59,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +124,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.reverse(); @@ -144,7 +138,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.reverse(); @@ -159,7 +153,7 @@ tape( 'the method reverses elements of a complex number array in-place (complex1 var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); out = arr.reverse(); @@ -177,7 +171,7 @@ tape( 'the method reverses elements of a complex number array in-place (complex6 var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); out = arr.reverse(); @@ -194,7 +188,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); out = arr.reverse(); @@ -207,7 +201,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); out = arr.reverse(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js index 2c21bc1aeb2c..827c23320514 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.set.js @@ -32,8 +32,6 @@ var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -46,14 +44,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `set` method for setting one or more array elements (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'set' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.set ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `set` method for setting one or more array elements (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'set' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.set ), true, 'has method' ); t.end(); @@ -65,7 +63,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -129,7 +127,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -161,7 +159,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -193,7 +191,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -225,7 +223,7 @@ tape( 'the method throws an error if provided a first argument which is not a co var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -257,7 +255,7 @@ tape( 'the method throws an error if provided an index argument which is not a n var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -291,7 +289,7 @@ tape( 'the method throws an error if provided an index argument which is not a n var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -325,7 +323,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -352,7 +350,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -380,7 +378,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr1 = new Complex128Array( 10 ); arr2 = new Complex128Array( 10 ); @@ -410,7 +408,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr1 = new Complex64Array( 10 ); arr2 = new Complex64Array( 10 ); @@ -440,7 +438,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr1 = new Complex128Array( 10 ); arr2 = []; for ( i = 0; i < arr1.length; i++ ) { @@ -473,7 +471,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr1 = new Complex64Array( 10 ); arr2 = []; for ( i = 0; i < arr1.length; i++ ) { @@ -506,7 +504,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr1 = new Complex128Array( 10 ); arr2 = []; for ( i = 0; i < arr1.length; i++ ) { @@ -540,7 +538,7 @@ tape( 'the method throws an error if provided an index argument which is out-of- var arr2; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr1 = new Complex64Array( 10 ); arr2 = []; for ( i = 0; i < arr1.length; i++ ) { @@ -573,7 +571,7 @@ tape( 'the method throws an error if provided an array-like object containing in var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -600,7 +598,7 @@ tape( 'the method throws an error if provided an array-like object containing in var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -627,7 +625,7 @@ tape( 'the method throws an error if provided an array-like object containing in var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -654,7 +652,7 @@ tape( 'the method throws an error if provided an array-like object containing in var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -681,7 +679,7 @@ tape( 'the method sets an array element (complex number) (complex128)', function var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); v = arr.get( 0 ); @@ -718,7 +716,7 @@ tape( 'the method sets an array element (complex number) (complex64)', function var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); v = arr.get( 0 ); @@ -756,7 +754,7 @@ tape( 'the method sets an array element (complex typed array) (complex128)', fun var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); v = arr.get( 0 ); @@ -822,7 +820,7 @@ tape( 'the method sets an array element (complex typed array) (complex64)', func var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); v = arr.get( 0 ); @@ -888,7 +886,7 @@ tape( 'the method sets an array element (array-like object containing complex nu var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); v = arr.get( 0 ); @@ -954,7 +952,7 @@ tape( 'the method sets an array element (array-like object containing complex nu var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); v = arr.get( 0 ); @@ -1020,7 +1018,7 @@ tape( 'the method sets an array element (array-like object containing interleave var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); v = arr.get( 0 ); @@ -1086,7 +1084,7 @@ tape( 'the method sets an array element (array-like object containing interleave var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); v = arr.get( 0 ); @@ -1154,7 +1152,7 @@ tape( 'the method sets an array element (complex typed array; shared buffer) (co var ab; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); byteOffset = 224; // 14 * 16 @@ -1229,7 +1227,7 @@ tape( 'the method sets an array element (complex typed array; shared buffer) (co var ab; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); byteOffset = 112; // 14 * 8 @@ -1305,7 +1303,7 @@ tape( 'the method sets an array element (typed array; shared buffer) (complex128 var v; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); byteOffset = 224; // 14 * 16 @@ -1389,7 +1387,7 @@ tape( 'the method sets an array element (typed array; shared buffer) (complex64) var v; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); byteOffset = 112; // 14 * 8 diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js index 72143acec4fc..380d9a2dd67b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.slice.js @@ -26,12 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -46,14 +40,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `slice` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'slice' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.slice ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `slice` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'slice' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.slice ), true, 'has method' ); t.end(); @@ -65,7 +59,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -131,7 +125,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -163,7 +157,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -195,7 +189,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -227,7 +221,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -258,7 +252,7 @@ tape( 'the method returns an empty typed array if operating on an empty complex var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.slice(); @@ -271,7 +265,7 @@ tape( 'the method returns an empty typed array if operating on an empty complex var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.slice(); @@ -285,7 +279,7 @@ tape( 'if called without arguments, the method returns a typed array containing var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.slice(); @@ -303,7 +297,7 @@ tape( 'if called without arguments, the method returns a typed array containing var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.slice(); @@ -321,7 +315,7 @@ tape( 'if called with one argument, the method returns a typed array containing var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.slice( 1 ); @@ -338,7 +332,7 @@ tape( 'if called with one argument, the method returns a typed array containing var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.slice( 1 ); @@ -355,7 +349,7 @@ tape( 'if provided two arguments, the method returns a typed array containing el var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -381,7 +375,7 @@ tape( 'if provided two arguments, the method returns a typed array containing el var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -407,7 +401,7 @@ tape( 'the method resolves negative indices relative to the last element (comple var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -430,7 +424,7 @@ tape( 'the method resolves negative indices relative to the last element (comple var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -453,7 +447,7 @@ tape( 'the method returns an empty typed array if a resolved beginning index exc var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); actual = arr.slice( 2, 0 ); @@ -470,7 +464,7 @@ tape( 'the method returns an empty typed array if a resolved beginning index exc var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); actual = arr.slice( 2, 0 ); @@ -487,7 +481,7 @@ tape( 'the method returns an empty typed array if a resolved beginning index exc var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); actual = arr.slice( 5 ); @@ -504,7 +498,7 @@ tape( 'the method returns an empty typed array if a resolved beginning index exc var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); actual = arr.slice( 5 ); @@ -521,7 +515,7 @@ tape( 'the method returns an empty typed array if a resolved ending index is les var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); @@ -543,7 +537,7 @@ tape( 'the method returns an empty typed array if a resolved ending index is les var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js index 21c5d52750e7..8a3c7928578a 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.some.js @@ -23,16 +23,10 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +39,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `some` method for returning a boolean indicating whether at least one element passes a test (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'some' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.some ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `some` method for returning a boolean indicating whether at least one element passes a test (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'some' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.some ), true, 'has method' ); t.end(); @@ -64,7 +58,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -101,7 +95,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -138,7 +132,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -170,7 +164,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -201,7 +195,7 @@ tape( 'the method returns `false` if operating on an empty complex number array var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); bool = arr.some( predicate ); @@ -218,7 +212,7 @@ tape( 'the method returns `false` if operating on an empty complex number array var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); bool = arr.some( predicate ); @@ -235,7 +229,7 @@ tape( 'the method returns `true` if at least one element passes a test (complex1 var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 1.0, 2.0 ] ); bool = arr.some( predicate ); @@ -252,7 +246,7 @@ tape( 'the method returns `true` if at least one element passes a test (complex6 var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 1.0, 2.0 ] ); bool = arr.some( predicate ); @@ -269,7 +263,7 @@ tape( 'the method returns `false` if all elements fail a test (complex128)', fun var bool; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); bool = arr.some( predicate ); @@ -286,7 +280,7 @@ tape( 'the method returns `false` if all elements fail a test (complex64)', func var bool; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); bool = arr.some( predicate ); @@ -304,7 +298,7 @@ tape( 'the method supports providing an execution context (complex128)', functio var ctx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -327,7 +321,7 @@ tape( 'the method supports providing an execution context (complex64)', function var ctx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; @@ -350,7 +344,7 @@ tape( 'the method stops executing upon encountering the first element which pass var ctx; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); ctx = { 'count': 0 }; @@ -373,7 +367,7 @@ tape( 'the method stops executing upon encountering the first element which pass var ctx; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); ctx = { 'count': 0 }; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js index b4dba214873b..06e5667bcaf3 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.sort.js @@ -26,8 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); @@ -113,14 +111,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `sort` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'sort' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.sort ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `sort` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'sort' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.sort ), true, 'has method' ); t.end(); @@ -132,7 +130,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -165,7 +163,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -198,7 +196,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -230,7 +228,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -261,7 +259,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.sort( compareFcn128 ); @@ -275,7 +273,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.sort( compareFcn64 ); @@ -290,7 +288,7 @@ tape( 'the method sorts elements of a complex number array in-place (complex128) var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.sort( compareFcn128 ); @@ -308,7 +306,7 @@ tape( 'the method sorts elements of a complex number array in-place (complex64)' var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.sort( compareFcn64 ); @@ -325,7 +323,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.sort( compareFcn128 ); @@ -338,7 +336,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.sort( compareFcn64 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js index 806702b3522b..da3b30e5558f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.subarray.js @@ -26,12 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -46,14 +40,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `subarray` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'subarray' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.subarray ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `subarray` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'subarray' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.subarray ), true, 'has method' ); t.end(); @@ -65,7 +59,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -131,7 +125,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -163,7 +157,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -195,7 +189,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -227,7 +221,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -258,7 +252,7 @@ tape( 'the method returns empty array if operating on an empty complex number ar var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.subarray(); @@ -272,7 +266,7 @@ tape( 'the method returns empty array if operating on an empty complex number ar var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.subarray(); @@ -287,7 +281,7 @@ tape( 'if called without arguments, the method returns a view containing the sam var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray(); @@ -305,7 +299,7 @@ tape( 'if called without arguments, the method returns a view containing the sam var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray(); @@ -323,7 +317,7 @@ tape( 'if called with one argument, the method returns a view containing element var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray( 1 ); @@ -341,7 +335,7 @@ tape( 'if called with one argument, the method returns a view containing element var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray( 1 ); @@ -359,7 +353,7 @@ tape( 'if provided two arguments, the method returns a view containing elements var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray( 1, 3 ); @@ -377,7 +371,7 @@ tape( 'if provided two arguments, the method returns a view containing elements var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); actual = arr.subarray( 1, 3 ); @@ -395,7 +389,7 @@ tape( 'the method resolves negative indices relative to the last element (comple var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -420,7 +414,7 @@ tape( 'the method resolves negative indices relative to the last element (comple var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); @@ -445,7 +439,7 @@ tape( 'the method returns an empty view if a resolved beginning index exceeds a var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); actual = arr.subarray( 2, 0 ); @@ -463,7 +457,7 @@ tape( 'the method returns an empty view if a resolved beginning index exceeds a var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); actual = arr.subarray( 2, 0 ); @@ -481,7 +475,7 @@ tape( 'the method returns an empty view if a resolved beginning index exceeds th var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); actual = arr.subarray( 5 ); @@ -499,7 +493,7 @@ tape( 'the method returns an empty view if a resolved beginning index exceeds th var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); actual = arr.subarray( 5 ); @@ -517,7 +511,7 @@ tape( 'the method returns an empty view if a resolved ending index is less than var actual; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float64Array( [] ); @@ -541,7 +535,7 @@ tape( 'the method returns an empty view if a resolved ending index is less than var actual; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); expected = new Float32Array( [] ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js index c171f9b0c8bc..269a19a2ce8f 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_locale_string.js @@ -23,16 +23,6 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +35,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `toLocaleString` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toLocaleString' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.toLocaleString ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `toLocaleString` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toLocaleString' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.toLocaleString ), true, 'has method' ); t.end(); @@ -64,7 +54,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +87,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +120,7 @@ tape( 'the method throws an error if provided a first argument which is not a st var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); values = [ @@ -162,7 +152,7 @@ tape( 'the method throws an error if provided a first argument which is not a st var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); values = [ @@ -194,7 +184,7 @@ tape( 'the method throws an error if provided a first argument which is not a st var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); values = [ @@ -226,7 +216,7 @@ tape( 'the method throws an error if provided a first argument which is not a st var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); values = [ @@ -258,7 +248,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); values = [ @@ -290,7 +280,7 @@ tape( 'the method throws an error if provided a second argument which is not an var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); values = [ @@ -321,7 +311,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex1 var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); str = arr.toLocaleString(); @@ -334,7 +324,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex6 var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); str = arr.toLocaleString(); @@ -348,7 +338,7 @@ tape( 'the method returns a string representation of a complex number array (com var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; @@ -364,7 +354,7 @@ tape( 'the method returns a string representation of a complex number array (com var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js index adeb1f0f5709..28ec7d80febb 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_reversed.js @@ -26,12 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -46,14 +40,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `toReversed` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toReversed' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.toReversed ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `toReversed` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toReversed' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.toReversed ), true, 'has method' ); t.end(); @@ -65,7 +59,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -98,7 +92,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +124,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.toReversed(); @@ -143,7 +137,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.toReversed(); @@ -157,7 +151,7 @@ tape( 'the method returns a new typed array containing elements in reverse order var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); out = arr.toReversed(); @@ -175,7 +169,7 @@ tape( 'the method returns a new typed array containing elements in reverse order var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); out = arr.toReversed(); @@ -192,7 +186,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); out = arr.toReversed(); @@ -205,7 +199,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); out = arr.toReversed(); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js index 28a690f01e1c..3bf971a2ffeb 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_sorted.js @@ -26,8 +26,6 @@ var isFunction = require( '@stdlib/assert/is-function' ); var instanceOf = require( '@stdlib/assert/instance-of' ); var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); @@ -113,14 +111,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `toSorted` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toSorted' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.toSorted ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `toSorted` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toSorted' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.toSorted ), true, 'has method' ); t.end(); @@ -132,7 +130,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -165,7 +163,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -198,7 +196,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -230,7 +228,7 @@ tape( 'the method throws an error if provided a first argument which is not a fu var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -261,7 +259,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); out = arr.toSorted( compareFcn128 ); @@ -274,7 +272,7 @@ tape( 'the method returns an empty array if operating on an empty complex number var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); out = arr.toSorted( compareFcn64 ); @@ -288,7 +286,7 @@ tape( 'the method returns a new typed array containing elements in sorted order var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.toSorted( compareFcn128 ); @@ -306,7 +304,7 @@ tape( 'the method returns a new typed array containing elements in sorted order var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.toSorted( compareFcn64 ); @@ -323,7 +321,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.toSorted( compareFcn128 ); @@ -336,7 +334,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); out = arr.toSorted( compareFcn64 ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js index b458f55ace04..51f4621b1060 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.to_string.js @@ -23,16 +23,6 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +35,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `toString` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toString' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.toString ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `toString` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toString' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.toString ), true, 'has method' ); t.end(); @@ -64,7 +54,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +87,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -129,7 +119,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex1 var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array(); str = arr.toString(); @@ -142,7 +132,7 @@ tape( 'the method returns an empty string if invoked on an empty array (complex6 var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array(); str = arr.toString(); @@ -156,7 +146,7 @@ tape( 'the method returns a string representation of a complex number array (com var str; var arr; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; @@ -172,7 +162,7 @@ tape( 'the method returns a string representation of a complex number array (com var str; var arr; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1, 2, -3, -4 ] ); expected = '1 + 2i,-3 - 4i'; diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js index 71e8279147b0..302de9ebb6a6 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.values.js @@ -25,16 +25,12 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isFunction = require( '@stdlib/assert/is-function' ); var isComplex128 = require( '@stdlib/assert/is-complex128' ); var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); var factory = require( './../lib' ); @@ -48,14 +44,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `values` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'values' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.values ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `values` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'values' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.values ), true, 'has method' ); t.end(); @@ -67,7 +63,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -100,7 +96,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -136,7 +132,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex128)', f var r; var e; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); expected = [ { @@ -180,7 +176,7 @@ tape( 'the method returns an iterator protocol-compliant object (complex64)', fu var r; var e; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); expected = [ { @@ -223,7 +219,7 @@ tape( 'the method returns an iterator which does not iterate over empty arrays ( var i; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [] ); expected = [ { @@ -256,7 +252,7 @@ tape( 'the method returns an iterator which does not iterate over empty arrays ( var i; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [] ); expected = [ { @@ -287,7 +283,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (no a var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.values(); @@ -322,7 +318,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (no a var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.values(); @@ -357,7 +353,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (argu var it; var v; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.values(); @@ -392,7 +388,7 @@ tape( 'the returned iterator has a `return` method for closing an iterator (argu var it; var v; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); it = arr.values(); @@ -436,7 +432,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera t.end(); return; } - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex128Array( buf ); @@ -474,7 +470,7 @@ tape( 'if an environment supports `Symbol.iterator`, the method returns an itera t.end(); return; } - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; arr = new Complex64Array( buf ); diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js index 1de3fa4f0d7e..132196024b18 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.with.js @@ -27,10 +27,6 @@ var Float32Array = require( '@stdlib/array/float32' ); var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var factory = require( './../lib' ); @@ -45,14 +41,14 @@ tape( 'main export is a function', function test( t ) { }); tape( 'attached to the prototype of the returned constructor is a `with` method (complex128)', function test( t ) { - var Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + var Complex128Array = factory( 'complex128' ); t.strictEqual( hasOwnProp( Complex128Array.prototype, 'with' ), true, 'has property' ); t.strictEqual( isFunction( Complex128Array.prototype.with ), true, 'has method' ); t.end(); }); tape( 'attached to the prototype of the returned constructor is a `with` method (complex64)', function test( t ) { - var Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + var Complex64Array = factory( 'complex64' ); t.strictEqual( hasOwnProp( Complex64Array.prototype, 'with' ), true, 'has property' ); t.strictEqual( isFunction( Complex64Array.prototype.with ), true, 'has method' ); t.end(); @@ -64,7 +60,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -97,7 +93,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -130,7 +126,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 5 ); values = [ @@ -163,7 +159,7 @@ tape( 'the method throws an error if provided a first argument which is not an i var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 5 ); values = [ @@ -196,7 +192,7 @@ tape( 'the method throws an error if provided a first argument which is not in b var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -223,7 +219,7 @@ tape( 'the method throws an error if provided a first argument which is not in b var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -250,7 +246,7 @@ tape( 'the method throws an error if provided a second argument which is not a c var arr; var i; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); values = [ @@ -283,7 +279,7 @@ tape( 'the method throws an error if provided a second argument which is not a c var arr; var i; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); values = [ @@ -315,7 +311,7 @@ tape( 'the method does not change the array length (complex128)', function test( var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( 10 ); out = arr.with( 5, new Complex128( 1.0, 1.0 ) ); @@ -328,7 +324,7 @@ tape( 'the method does not change the array length (complex64)', function test( var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( 10 ); out = arr.with( 5, new Complex64( 1.0, 1.0 ) ); @@ -342,7 +338,7 @@ tape( 'the method returns a new complex number array with the element at a provi var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); expected = new Float64Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); out = arr.with( 1, new Complex128( 5.0, 5.0 ) ); @@ -359,7 +355,7 @@ tape( 'the method returns a new complex number array with the element at a provi var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); expected = new Float32Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); out = arr.with( 1, new Complex64( 5.0, 5.0 ) ); @@ -376,7 +372,7 @@ tape( 'the method supports negative indices (complex128)', function test( t ) { var arr; var out; - Complex128Array = factory( 'complex128', Float64Array, Complex128, real, imag, reinterpret128 ); + Complex128Array = factory( 'complex128' ); arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); expected = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); @@ -393,7 +389,7 @@ tape( 'the method supports negative indices (complex64)', function test( t ) { var arr; var out; - Complex64Array = factory( 'complex64', Float32Array, Complex64, realf, imagf, reinterpret64 ); + Complex64Array = factory( 'complex64' ); arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); From 4dc6e78b16de9c60f3e57b773ef0ddbae292cc5a Mon Sep 17 00:00:00 2001 From: Uday Kakade Date: Sat, 4 Apr 2026 21:28:28 +0530 Subject: [PATCH 07/12] Fix Lint errors in README.md --- .../@stdlib/array/complex-factory/README.md | 100 ++++++++++++++---- .../array/complex-factory/package.json | 1 + .../array/complex-factory/test/test.js | 2 - 3 files changed, 79 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/README.md b/lib/node_modules/@stdlib/array/complex-factory/README.md index 63ee3a7c461b..52f7abfb89de 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/README.md +++ b/lib/node_modules/@stdlib/array/complex-factory/README.md @@ -792,7 +792,10 @@ var realf = require( '@stdlib/complex/float32/real' ); var Complex64Array = complexFactory( 'complex64' ); -var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ) +] ); var it = arr.entries(); @@ -816,7 +819,10 @@ var real = require( '@stdlib/complex/float64/real' ); var Complex128Array = complexFactory( 'complex128' ); -arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ) +] ); it = arr.entries(); @@ -854,7 +860,10 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ) +] ); var bool = arr.every( predicate64 ); // returns true @@ -869,7 +878,10 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ) +] ); bool = arr.every( predicate128 ); // returns true @@ -943,7 +955,11 @@ function predicate64( v ) { return ( realf( v ) > 0.0 ); } -var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( -2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, -1.0 ), + new Complex64( -2.0, 2.0 ), + new Complex64( 3.0, -3.0 ) +] ); var out = arr.filter( predicate64 ); // returns @@ -960,7 +976,11 @@ function predicate128( v ) { return ( real( v ) > 0.0 ); } -arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( -2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, -1.0 ), + new Complex128( -2.0, 2.0 ), + new Complex128( 3.0, -3.0 ) +] ); out = arr.filter( predicate128 ); // returns @@ -989,7 +1009,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, -3.0 ) +] ); var z = arr.find( predicate64 ); // returns @@ -1010,7 +1034,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, -3.0 ) +] ); z = arr.find( predicate128 ); // returns @@ -1042,7 +1070,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, -3.0 ) +] ); var idx = arr.findIndex( predicate64 ); // returns 1 @@ -1057,7 +1089,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, -3.0 ) +] ); idx = arr.findIndex( predicate128 ); // returns 1 @@ -1083,7 +1119,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, -3.0 ) +] ); var z = arr.findLast( predicate64 ); // returns @@ -1101,7 +1141,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, -3.0 ) +] ); z = arr.findLast( predicate128 ); // returns @@ -1130,7 +1174,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, 1.0 ), + new Complex64( 2.0, 2.0 ), + new Complex64( 3.0, -3.0 ) +] ); var idx = arr.findLastIndex( predicate64 ); // returns 1 @@ -1145,7 +1193,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, 1.0 ), + new Complex128( 2.0, 2.0 ), + new Complex128( 3.0, -3.0 ) +] ); idx = arr.findLastIndex( predicate128 ); // returns 1 @@ -1167,11 +1219,14 @@ var imagf = require( '@stdlib/complex/float32/imag' ); var Complex64Array = complexFactory( 'complex64' ); -var arr = new Complex64Array( [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ] ); +var arr = new Complex64Array( [ + new Complex64( 1.0, -1.0 ), + new Complex64( 2.0, -2.0 ) +] ); -arr.forEach( function( v, i ) { +arr.forEach( ( v, i ) => { console.log( i, realf( v ), imagf( v ) ); -}); +} ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); @@ -1179,11 +1234,14 @@ var imag = require( '@stdlib/complex/float64/imag' ); var Complex128Array = complexFactory( 'complex128' ); -arr = new Complex128Array( [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ] ); +arr = new Complex128Array( [ + new Complex128( 1.0, -1.0 ), + new Complex128( 2.0, -2.0 ) +] ); -arr.forEach( function( v, i ) { +arr.forEach( ( v, i ) => { console.log( i, real( v ), imag( v ) ); -}); +} ); ``` The invoked function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. @@ -3212,8 +3270,6 @@ logEach( '%s', out ); [@stdlib/array/buffer]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/buffer -[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol - [@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64 diff --git a/lib/node_modules/@stdlib/array/complex-factory/package.json b/lib/node_modules/@stdlib/array/complex-factory/package.json index 307e22e2da49..6d4756837e2b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/package.json +++ b/lib/node_modules/@stdlib/array/complex-factory/package.json @@ -15,6 +15,7 @@ ], "main": "./lib", "directories": { + "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", "lib": "./lib", diff --git a/lib/node_modules/@stdlib/array/complex-factory/test/test.js b/lib/node_modules/@stdlib/array/complex-factory/test/test.js index 1154f6ea5a58..24f538e182f8 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/test/test.js +++ b/lib/node_modules/@stdlib/array/complex-factory/test/test.js @@ -27,9 +27,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); From b5b9a5722be96d83ddff4c87a62420bedf7e9df6 Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Sat, 4 Apr 2026 23:37:13 +0530 Subject: [PATCH 08/12] Format examples in repl.txt for better readability Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- .../@stdlib/array/complex-factory/docs/repl.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt index 3557199a9142..28c6ae171052 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt @@ -2813,9 +2813,11 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var arr = new {{alias:@stdlib/array/complex128}}([ 1.0, -1.0, + ... 2.0, -2.0 ]) - > var out = arr.with( 1, new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + > var out = arr.with( 1, new + ... {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) > var z = out.get( 1 ) @@ -2844,9 +2846,11 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var arr = new {{alias:@stdlib/array/complex64}}([ 1.0, -1.0, + ... 2.0, -2.0 ]) - > var out = arr.with( 1, new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + > var out = arr.with( 1, new + ... {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) > var z = out.get( 1 ) @@ -2855,3 +2859,6 @@ > var im = {{alias:@stdlib/complex/float32/imag}}( z ) -3.0 + + See Also + -------- From d2e886dc01a2caa3dd55020dfcd53a426a4c4ad0 Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Sun, 5 Apr 2026 08:51:19 +0530 Subject: [PATCH 09/12] Fix Brakcet Spacing and Arrow Fn Lints Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- .../@stdlib/array/complex-factory/README.md | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/README.md b/lib/node_modules/@stdlib/array/complex-factory/README.md index 52f7abfb89de..28da7733239d 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/README.md +++ b/lib/node_modules/@stdlib/array/complex-factory/README.md @@ -792,10 +792,10 @@ var realf = require( '@stdlib/complex/float32/real' ); var Complex64Array = complexFactory( 'complex64' ); -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) -] ); +]); var it = arr.entries(); @@ -819,10 +819,10 @@ var real = require( '@stdlib/complex/float64/real' ); var Complex128Array = complexFactory( 'complex128' ); -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) -] ); +]); it = arr.entries(); @@ -860,10 +860,10 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ) -] ); +]); var bool = arr.every( predicate64 ); // returns true @@ -878,10 +878,10 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ) -] ); +]); bool = arr.every( predicate128 ); // returns true @@ -955,11 +955,11 @@ function predicate64( v ) { return ( realf( v ) > 0.0 ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, -1.0 ), new Complex64( -2.0, 2.0 ), new Complex64( 3.0, -3.0 ) -] ); +]); var out = arr.filter( predicate64 ); // returns @@ -976,11 +976,11 @@ function predicate128( v ) { return ( real( v ) > 0.0 ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, -1.0 ), new Complex128( -2.0, 2.0 ), new Complex128( 3.0, -3.0 ) -] ); +]); out = arr.filter( predicate128 ); // returns @@ -1009,11 +1009,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) -] ); +]); var z = arr.find( predicate64 ); // returns @@ -1034,11 +1034,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) -] ); +]); z = arr.find( predicate128 ); // returns @@ -1070,11 +1070,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) -] ); +]); var idx = arr.findIndex( predicate64 ); // returns 1 @@ -1089,11 +1089,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) -] ); +]); idx = arr.findIndex( predicate128 ); // returns 1 @@ -1119,11 +1119,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) -] ); +]); var z = arr.findLast( predicate64 ); // returns @@ -1141,11 +1141,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) -] ); +]); z = arr.findLast( predicate128 ); // returns @@ -1174,11 +1174,11 @@ function predicate64( v ) { return ( realf( v ) === imagf( v ) ); } -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, 1.0 ), new Complex64( 2.0, 2.0 ), new Complex64( 3.0, -3.0 ) -] ); +]); var idx = arr.findLastIndex( predicate64 ); // returns 1 @@ -1193,11 +1193,11 @@ function predicate128( v ) { return ( real( v ) === imag( v ) ); } -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, 1.0 ), new Complex128( 2.0, 2.0 ), new Complex128( 3.0, -3.0 ) -] ); +]); idx = arr.findLastIndex( predicate128 ); // returns 1 @@ -1219,12 +1219,12 @@ var imagf = require( '@stdlib/complex/float32/imag' ); var Complex64Array = complexFactory( 'complex64' ); -var arr = new Complex64Array( [ +var arr = new Complex64Array([ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) -] ); +]); -arr.forEach( ( v, i ) => { +arr.forEach( function forEach( v, i ) { console.log( i, realf( v ), imagf( v ) ); } ); @@ -1234,12 +1234,12 @@ var imag = require( '@stdlib/complex/float64/imag' ); var Complex128Array = complexFactory( 'complex128' ); -arr = new Complex128Array( [ +arr = new Complex128Array([ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) -] ); +]); -arr.forEach( ( v, i ) => { +arr.forEach( function forEach( v, i ) { console.log( i, real( v ), imag( v ) ); } ); ``` From b95eb9e791e978c867baa60073af63724a8b08f2 Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Sun, 5 Apr 2026 09:58:28 +0530 Subject: [PATCH 10/12] fix 'FunctionExpression' is not allowed lint errors Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- .../@stdlib/array/complex-factory/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/README.md b/lib/node_modules/@stdlib/array/complex-factory/README.md index 28da7733239d..52785876252b 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/README.md +++ b/lib/node_modules/@stdlib/array/complex-factory/README.md @@ -1217,6 +1217,10 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); +function log( v, i ) { + console.log( i, realf( v ), imagf( v ) ); +} + var Complex64Array = complexFactory( 'complex64' ); var arr = new Complex64Array([ @@ -1224,14 +1228,16 @@ var arr = new Complex64Array([ new Complex64( 2.0, -2.0 ) ]); -arr.forEach( function forEach( v, i ) { - console.log( i, realf( v ), imagf( v ) ); -} ); +arr.forEach( log ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); +function log2( v, i ) { + console.log( i, real( v ), imag( v ) ); +} + var Complex128Array = complexFactory( 'complex128' ); arr = new Complex128Array([ @@ -1239,9 +1245,7 @@ arr = new Complex128Array([ new Complex128( 2.0, -2.0 ) ]); -arr.forEach( function forEach( v, i ) { - console.log( i, real( v ), imag( v ) ); -} ); +arr.forEach( log2 ); ``` The invoked function is provided three arguments: **value**, **index**, and **arr**. To set the execution context, provide a `thisArg`. From d43fc4155ea67fcef85a0b016ce33358fec46ced Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Sun, 5 Apr 2026 14:23:44 +0530 Subject: [PATCH 11/12] Fix repl.txt 80 character exceeding error (prototypes left) Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- .../array/complex-factory/docs/repl.txt | 290 ++++++++++++------ 1 file changed, 196 insertions(+), 94 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt index 28c6ae171052..ec95f8cfe785 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt @@ -104,7 +104,8 @@ Examples -------- - > var arr1 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr1 = new {{alias:@stdlib/array/complex128}}( buf ) > var arr2 = new {{alias:@stdlib/array/complex128}}( arr1 ) @@ -127,7 +128,8 @@ Examples -------- - > var arr1 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ] + > var arr1 = new {{alias:@stdlib/array/complex64}}( buf ) > var arr2 = new {{alias:@stdlib/array/complex64}}( arr1 ) @@ -199,11 +201,14 @@ Examples -------- - > var arr1 = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr1 = new {{alias:@stdlib/array/complex128}}( buf ) > var len = arr1.length 2 - > var buf = [ new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ) ]; + > var z1 = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ); + > var z2 = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ); + > buf = [ z1, z2 ]; > var arr2 = new {{alias:@stdlib/array/complex128}}( buf ) > len = arr2.length @@ -225,11 +230,14 @@ Examples -------- - > var arr1 = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr1 = new {{alias:@stdlib/array/complex64}}( buf ) > var len = arr1.length 2 - > var buf = [ new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ) ]; + > var z1 = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ); + > var z2 = new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ); + > buf = [ z1, z2 ]; > var arr2 = new {{alias:@stdlib/array/complex64}}( buf ) > len = arr2.length @@ -340,7 +348,8 @@ Examples -------- > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias:@stdlib/array/complex128}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = {{alias:@stdlib/array/complex128}}.from( buf, clbkFcn ) > var len = arr.length 2 @@ -380,7 +389,8 @@ Examples -------- > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias:@stdlib/array/complex64}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = {{alias:@stdlib/array/complex64}}.from( buf, clbkFcn ) > var len = arr.length 2 @@ -649,7 +659,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.at( 1 ) @@ -678,7 +689,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.at( 1 ) @@ -710,7 +722,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > arr.copyWithin( 0, 2 ) @@ -744,7 +757,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > arr.copyWithin( 0, 2 ) @@ -766,7 +780,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var it = arr.entries(); > var v = it.next().value @@ -801,7 +816,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var it = arr.entries(); > var v = it.next().value @@ -852,8 +868,10 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) > 0.0 ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > function predicate( v ) { return ( re( v ) > 0.0 ); }; + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var bool = arr.every( predicate ) true @@ -885,8 +903,10 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) > 0.0 ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > function predicate( v ) { return ( re( v ) > 0.0 ); }; + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var bool = arr.every( predicate ) true @@ -1013,8 +1033,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.filter( predicate ) @@ -1057,8 +1080,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.filter( predicate ) @@ -1100,8 +1126,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.find( predicate ) @@ -1139,8 +1168,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.find( predicate ) @@ -1178,8 +1210,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var idx = arr.findIndex( predicate ) 0 @@ -1213,8 +1248,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var idx = arr.findIndex( predicate ) 0 @@ -1248,8 +1286,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.findLast( predicate ) @@ -1287,8 +1328,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.findLast( predicate ) @@ -1326,8 +1370,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var idx = arr.findLastIndex( predicate ) 1 @@ -1361,8 +1408,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var idx = arr.findLastIndex( predicate ) 1 @@ -1389,7 +1439,8 @@ -------- > var str = '%'; > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > arr.forEach( clbk ); > str @@ -1417,7 +1468,8 @@ -------- > var str = '%'; > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > arr.forEach( clbk ); > str @@ -1442,7 +1494,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.get( 1 ) @@ -1470,7 +1523,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.get( 1 ) @@ -1500,11 +1554,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) - > var bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + > var z = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ); + > var bool = arr.includes( z ) true - > bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) + > bool = arr.includes( z, 3 ) false @@ -1528,11 +1584,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) - > var bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + > var z = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ); + > var bool = arr.includes( z ) true - > bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) + > bool = arr.includes( z, 3 ) false @@ -1558,11 +1616,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) - > var idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) + > var z = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ); + > var idx = arr.indexOf( z ) 2 - > idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) + > idx = arr.indexOf( z, 3 ) -1 @@ -1588,11 +1648,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) - > var idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) + > var z = new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ); + > var idx = arr.indexOf( z ) 2 - > idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) + > idx = arr.indexOf( z, 3 ) -1 @@ -1612,7 +1674,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var str = arr.join() '1 - 1i,2 - 2i' @@ -1636,7 +1699,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var str = arr.join() '1 - 1i,2 - 2i' @@ -1654,7 +1718,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var it = arr.keys(); > var v = it.next().value @@ -1675,7 +1740,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var it = arr.keys(); > var v = it.next().value @@ -1708,11 +1774,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) - > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ) ) + > var z = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ); + > var idx = arr.lastIndexOf( z ) 3 - > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), 2 ) + > idx = arr.lastIndexOf( z, 2 ) 0 @@ -1738,11 +1806,13 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) - > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ) ) + > var z = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ); + > var idx = arr.lastIndexOf( z ) 3 - > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), 2 ) + > idx = arr.lastIndexOf( z, 2 ) 0 @@ -1774,7 +1844,8 @@ Examples -------- > function clbk( v ) { return v; }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.map( clbk ) @@ -1820,7 +1891,8 @@ Examples -------- > function clbk( v ) { return v; }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.map( clbk ) @@ -1873,7 +1945,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.reduce( {{alias:@stdlib/complex/float64/base/add}} ) @@ -1918,7 +1991,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.reduce( {{alias:@stdlib/complex/float32/base/add}} ) @@ -1963,7 +2037,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var z = arr.reduceRight( {{alias:@stdlib/complex/float64/base/add}} ) @@ -2008,7 +2083,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var z = arr.reduceRight( {{alias:@stdlib/complex/float32/base/add}} ) @@ -2030,7 +2106,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > arr.reverse(); > var z = arr.get( 0 ) @@ -2065,7 +2142,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > arr.reverse(); > var z = arr.get( 0 ) @@ -2184,7 +2262,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.slice( 1 ) @@ -2224,7 +2303,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.slice( 1 ) @@ -2270,8 +2350,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > var im = {{alias:@stdlib/complex/float64/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var bool = arr.some( predicate ) true @@ -2303,8 +2386,11 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > var im = {{alias:@stdlib/complex/float32/imag}}; + > function predicate( v ) { return ( re( v ) === im( v ) ); }; + > var buf = [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var bool = arr.some( predicate ) true @@ -2335,8 +2421,10 @@ Examples -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > function compare( a, b ) { return ( re( a ) - re( b ) ); }; + > var buf = [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > arr.sort( compare ); > var z = arr.get( 0 ) @@ -2384,8 +2472,10 @@ Examples -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > function compare( a, b ) { return ( re( a ) - re( b ) ); }; + > var buf = [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > arr.sort( compare ); > var z = arr.get( 0 ) @@ -2429,7 +2519,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.subarray( 1, 3 ) @@ -2470,7 +2561,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.subarray( 1, 3 ) @@ -2548,7 +2640,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.toReversed() @@ -2582,7 +2675,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) + > var buf = [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.toReversed() @@ -2631,8 +2725,10 @@ Examples -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; - > var arr = new {{alias:@stdlib/array/complex128}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var re = {{alias:@stdlib/complex/float64/real}}; + > function compare( a, b ) { return ( re( a ) - re( b ) ); }; + > var buf = [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var out = arr.toSorted( compare ); > var z = out.get( 0 ) @@ -2680,8 +2776,10 @@ Examples -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; - > var arr = new {{alias:@stdlib/array/complex64}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) + > var re = {{alias:@stdlib/complex/float32/real}}; + > function compare( a, b ) { return ( re( a ) - re( b ) ); }; + > var buf = [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var out = arr.toSorted( compare ); > var z = out.get( 0 ) @@ -2714,7 +2812,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) + > var buf = [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var str = arr.toString() '1 + 1i,2 - 2i,3 + 3i' @@ -2730,7 +2829,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) + > var buf = [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var str = arr.toString() '1 + 1i,2 - 2i,3 + 3i' @@ -2746,7 +2846,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex128}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex128}}( buf ) > var it = arr.values(); > var v = it.next().value @@ -2775,7 +2876,8 @@ Examples -------- - > var arr = new {{alias:@stdlib/array/complex64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; + > var arr = new {{alias:@stdlib/array/complex64}}( buf ) > var it = arr.values(); > var v = it.next().value From 507925883a4ceeebeb8a318f8e085d91beea5b53 Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Sun, 5 Apr 2026 15:26:52 +0530 Subject: [PATCH 12/12] Fix semicolon bug in repl.txt Fix syntax error by adding a semicolon to the example. Signed-off-by: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> --- lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt index ec95f8cfe785..244439738730 100644 --- a/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/complex-factory/docs/repl.txt @@ -128,7 +128,7 @@ Examples -------- - > var buf = [ 1.0, -1.0, 2.0, -2.0 ] + > var buf = [ 1.0, -1.0, 2.0, -2.0 ]; > var arr1 = new {{alias:@stdlib/array/complex64}}( buf ) > var arr2 = new {{alias:@stdlib/array/complex64}}( arr1 )