From 78fc33759559c11e82ea1bab05afeb6a255cc71b Mon Sep 17 00:00:00 2001 From: Aniket Sonawane Date: Thu, 5 Mar 2026 19:26:44 +0530 Subject: [PATCH 1/4] docs: improve doctests for complex number instances in array/complex128 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/complex128/README.md | 305 ++---------------- .../@stdlib/array/complex128/docs/repl.txt | 267 +++++---------- .../@stdlib/array/complex128/lib/main.js | 74 +---- 3 files changed, 120 insertions(+), 526 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex128/README.md b/lib/node_modules/@stdlib/array/complex128/README.md index 2f1c930424d0..042ded9ace1d 100644 --- a/lib/node_modules/@stdlib/array/complex128/README.md +++ b/lib/node_modules/@stdlib/array/complex128/README.md @@ -282,8 +282,6 @@ The iterator returned by an iterable must return either a complex number or an a ```javascript var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); var Float64Array = require( '@stdlib/array/float64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var iter; var arr; @@ -331,13 +329,7 @@ if ( ITERATOR_SYMBOL === null ) { // returns 2 z = arr.get( 0 ); - // returns - - re = real( z ); - // returns 1.0 - - im = imag( z ); - // returns -1.0 + // returns [ 1.0, -1.0 ] } ``` @@ -347,7 +339,6 @@ To invoke a function for each `src` value, provide a callback function. If `src` var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function map( z ) { return new Complex128( real(z)*2.0, imag(z)*2.0 ); } @@ -363,13 +354,7 @@ var len = arr.length; // returns 1 var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] ``` or an array-like object containing real and imaginary components @@ -403,22 +388,10 @@ var len = arr.length; // returns 2 var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 +// returns [ 4.0, -4.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. @@ -426,8 +399,6 @@ If `src` is an array-like object containing interleaved real and imaginary compo ```javascript 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' ); function map( v ) { return v * 2.0; @@ -444,13 +415,7 @@ var len = arr.length; // returns 1 var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] ``` A callback function is provided two arguments: @@ -521,9 +486,6 @@ len = arr.length; Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. ```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - var arr = new Complex128Array( 10 ); // Set the first, second, and last elements: @@ -533,23 +495,11 @@ arr.set( [ 9.0, -9.0 ], 9 ); // Get the first element: var z = arr.at( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 +// returns [ 1.0, -1.0 ] // Get the last element: z = arr.at( -1 ); -// returns - -re = real( z ); -// returns 9.0 - -im = imag( z ); -// returns -9.0 +// returns [ 9.0, -9.0 ] ``` If provided an out-of-bounds index, the method returns `undefined`. @@ -572,8 +522,6 @@ Copies a sequence of elements within the array starting at `start` and ending at ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = new Complex128Array( 4 ); @@ -585,54 +533,28 @@ arr.set( new Complex128( 4.0, -4.0 ), 3 ); // Get the first array element: var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 +// returns [ 1.0, -1.0 ] // Get the second array element: z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] // Copy the last two elements to the first two elements: arr.copyWithin( 0, 2 ); // Get the first array element: z = arr.get( 0 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns -3.0 +// returns [ 3.0, -3.0 ] // Get the second array element: z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 +// returns [ 4.0, -4.0 ] ``` By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = new Complex128Array( 4 ); @@ -644,54 +566,28 @@ arr.set( new Complex128( 4.0, -4.0 ), 3 ); // Get the third array element: var z = arr.get( 2 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns -3.0 +// returns [ 3.0, -3.0 ] // Get the last array element: z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 +// returns [ 4.0, -4.0 ] // Copy the first two elements to the last two elements: arr.copyWithin( 2, 0, 2 ); // Get the third array element: z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 +// returns [ 1.0, -1.0 ] // Get the last array element: z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] ``` When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = new Complex128Array( 4 ); @@ -703,46 +599,22 @@ arr.set( new Complex128( 4.0, -4.0 ), 3 ); // Get the third array element: var z = arr.get( 2 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns -3.0 +// returns [ 3.0, -3.0 ] // Get the last array element: z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 +// returns [ 4.0, -4.0 ] // Copy the first two elements to the last two elements using negative indices: arr.copyWithin( -2, -4, -2 ); // Get the third array element: z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 +// returns [ 1.0, -1.0 ] // Get the last array element: z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 +// returns [ 2.0, -2.0 ] ``` @@ -753,8 +625,6 @@ Returns an iterator for iterating over array key-value pairs. ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = [ new Complex128( 1.0, -1.0 ), @@ -768,31 +638,13 @@ var it = arr.entries(); // Iterate over the key-value pairs... var v = it.next().value; -// returns [ 0, ] - -var re = real( v[ 1 ] ); -// returns 1.0 - -var im = imag( v[ 1 ] ); -// returns -1.0 +// returns [ 0, [ 1.0, -1.0 ] ] v = it.next().value; -// returns [ 1, ] - -re = real( v[ 1 ] ); -// returns 2.0 - -im = imag( v[ 1 ] ); -// returns -2.0 +// returns [ 1, [ 2.0, -2.0 ] ] v = it.next().value; -// returns [ 2, ] - -re = real( v[ 1 ] ); -// returns 3.0 - -im = imag( v[ 1 ] ); -// returns -3.0 +// returns [ 2, [ 3.0, -3.0 ] ] var bool = it.next().done; // returns true @@ -864,8 +716,6 @@ Returns a modified typed array filled with a fill value. ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = new Complex128Array( 3 ); @@ -873,72 +723,34 @@ var arr = new Complex128Array( 3 ); arr.fill( new Complex128( 1.0, 1.0 ) ); var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 1.0 +// returns [ 1.0, 1.0 ] z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns 1.0 +// returns [ 1.0, 1.0 ] // Fill all elements starting from the second element: arr.fill( new Complex128( 2.0, 2.0 ), 1 ); z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 +// returns [ 2.0, 2.0 ] z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 +// returns [ 2.0, 2.0 ] // Fill all elements from first element until the second-to-last element: arr.fill( new Complex128( 3.0, 3.0 ), 0, 2 ); z = arr.get( 0 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns 3.0 +// returns [ 3.0, 3.0 ] z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns 3.0 +// returns [ 3.0, 3.0 ] ``` When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. ```javascript var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); var arr = new Complex128Array( 3 ); @@ -946,22 +758,10 @@ var arr = new Complex128Array( 3 ); arr.fill( new Complex128( 1.0, 1.0 ), 0, -1 ); var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 1.0 +// returns [ 1.0, 1.0 ] z = arr.get( arr.length - 1 ); -// returns - -re = real( z ); -// returns 0.0 - -im = imag( z ); -// returns 0.0 +// returns [ 0.0, 0.0 ] ``` @@ -973,7 +773,6 @@ Returns a new array containing the elements of an array which pass a test implem ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -992,13 +791,7 @@ 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 +// returns [ 2.0, 2.0 ] ``` The `predicate` function is provided three arguments: @@ -1048,7 +841,6 @@ Returns the first element in an array for which a predicate function returns a t ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -1061,13 +853,7 @@ 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 +// returns [ 1.0, 1.0 ] ``` The `predicate` function is provided three arguments: @@ -1081,7 +867,6 @@ To set the function execution context, provide a `thisArg`. ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function predicate( v, i ) { this.count += 1; return ( i >= 0 && real( v ) === imag( v ) ); @@ -1099,13 +884,7 @@ arr.set( [ 2.0, 2.0 ], 1 ); arr.set( [ 3.0, 3.0 ], 2 ); var z = arr.find( predicate, context ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns 2.0 +// returns [ 2.0, 2.0 ] var count = context.count; // returns 2 @@ -1180,7 +959,6 @@ Returns the last element in an array for which a predicate function returns a tr ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -1193,13 +971,7 @@ 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 +// returns [ 3.0, 3.0 ] ``` The `predicate` function is provided three arguments: @@ -1213,7 +985,6 @@ To set the function execution context, provide a `thisArg`. ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); - function predicate( v, i ) { this.count += 1; return ( i >= 0 && real( v ) === imag( v ) ); @@ -1231,13 +1002,7 @@ arr.set( [ 2.0, 2.0 ], 1 ); arr.set( [ 3.0, -3.0 ], 2 ); var z = arr.findLast( predicate, context ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns 2.0 +// returns [ 2.0, 2.0 ] var count = context.count; // returns 2 diff --git a/lib/node_modules/@stdlib/array/complex128/docs/repl.txt b/lib/node_modules/@stdlib/array/complex128/docs/repl.txt index 0d99f99501cc..ef7ad30e5ce7 100644 --- a/lib/node_modules/@stdlib/array/complex128/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/complex128/docs/repl.txt @@ -82,7 +82,7 @@ {{alias}}( obj ) - Creates a 128-bit complex number array from an array-like object or + Creates a 128-bit complex number array from an array-like object or iterable. Parameters @@ -165,12 +165,11 @@ thisArg: Any (optional) Callback execution context. - Returns ------- out: Complex128Array A typed array. - + Examples -------- > function clbkFcn( v ) { return v * 2.0 }; @@ -179,11 +178,7 @@ > 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 + [ 2.0, -2.0 ] {{alias}}.of( element0[, element1[, ...elementN]] ) @@ -219,11 +214,7 @@ > 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 + [ 1.0, -1.0 ] {{alias}}.BYTES_PER_ELEMENT @@ -327,11 +318,7 @@ > var arr = new {{alias}}( [ 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 + [ 2.0, -2.0 ] {{alias}}.prototype.copyWithin( target, start[, end] ) @@ -342,10 +329,10 @@ ---------- target: integer Target start index position. - + start: integer Source start index position. - + end: integer (optional) Source end index position. Default: out.length. @@ -353,7 +340,7 @@ ------- out: Complex128Array Modified array. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) @@ -361,11 +348,7 @@ > 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 + [ 3.0, -3.0 ] {{alias}}.prototype.entries() @@ -382,23 +365,11 @@ > 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 + [ 0, [ 1.0, -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 + [ 1, [ 2.0, -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 + [ 2, [ 3.0, -3.0 ] ] > var bool = it.next().done true @@ -456,30 +427,18 @@ ------- out: Complex128Array Modified array. - + Examples -------- > var arr = new {{alias}}( 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 + [ 1.0, 1.0 ] > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 + [ 1.0, 1.0 ] > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 + [ 1.0, 1.0 ] {{alias}}.prototype.filter( predicate[, thisArg] ) @@ -508,7 +467,7 @@ ------- out: Complex128Array A new typed array. - + Examples -------- > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; @@ -519,11 +478,7 @@ > 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 + [ 2.0, 2.0 ] {{alias}}.prototype.find( predicate[, thisArg] ) @@ -546,23 +501,19 @@ 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}}( [ 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 + [ 1.0, 1.0 ] {{alias}}.prototype.findIndex( predicate[, thisArg] ) @@ -585,12 +536,12 @@ 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 ) ); }; @@ -619,24 +570,20 @@ Predicate function which tests array elements. thisArg: Any (optional) - Execution context. - + 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}}( [ 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 + [ 2.0, 2.0 ] {{alias}}.prototype.findLastIndex( predicate[, thisArg] ) @@ -664,7 +611,7 @@ ------- out: integer Array index or `-1`. - + Examples -------- > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; @@ -690,7 +637,7 @@ thisArg: Any (optional) Execution context. - + Examples -------- > var str = '%'; @@ -712,22 +659,18 @@ ---------- i: integer Element index. - + Returns ------- out: Complex128|void Array element or `undefined`. - + Examples -------- > var arr = new {{alias}}( [ 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 + [ 2.0, -2.0 ] {{alias}}.prototype.includes( searchElement[, fromIndex] ) @@ -742,12 +685,12 @@ 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}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) @@ -777,7 +720,7 @@ ------- out: integer Array index or `-1`. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) @@ -796,12 +739,12 @@ ---------- separator: string (optional) Separator string. Default: ','. - + Returns ------- out: string Array serialized as a string. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) @@ -819,7 +762,7 @@ ------- iterator: Iterator Iterator for iterating over array index keys. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) @@ -847,12 +790,12 @@ 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}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) @@ -887,7 +830,7 @@ ------- out: Complex128Array A new typed array. - + Examples -------- > function clbk( v ) { return v; }; @@ -896,17 +839,9 @@ > 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 + [ 1.0, -1.0 ] > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 + [ 2.0, -2.0 ] {{alias}}.prototype.reduce( reducerFn[, initialValue] ) @@ -932,26 +867,22 @@ Parameters ---------- reducerFn: Function - Function to apply to each array element. + Function to apply to each array element. initialValue: any (optional) Initial accumulation value. - + Returns ------- out: any Accumulated result. - + Examples -------- > var arr = new {{alias}}( [ 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 + [ 3.0, -3.0 ] {{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) @@ -981,22 +912,18 @@ initialValue: any (optional) Initial accumulation value. - + Returns ------- out: any Accumulated result. - + Examples -------- > var arr = new {{alias}}( [ 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 + [ 3.0, -3.0 ] {{alias}}.prototype.reverse() @@ -1015,23 +942,11 @@ > 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 + [ 3.0, -3.0 ] > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 + [ 2.0, -2.0 ] > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 + [ 1.0, -1.0 ] {{alias}}.prototype.set( z[, i] ) @@ -1058,18 +973,10 @@ > 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 + [ 1.0, -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 + [ 2.0, -2.0 ] {{alias}}.prototype.slice( [start[, end]] ) @@ -1084,12 +991,12 @@ 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}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) @@ -1099,17 +1006,9 @@ > 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 + [ 2.0, -2.0 ] > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 + [ 3.0, -3.0 ] {{alias}}.prototype.some( predicate[, thisArg] ) @@ -1127,15 +1026,15 @@ 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 ) ); }; @@ -1162,12 +1061,12 @@ ---------- 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 ) ); }; @@ -1175,23 +1074,11 @@ > 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 + [ 1.0, -1.0 ] > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 + [ 2.0, -2.0 ] > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 + [ 3.0, -3.0 ] {{alias}}.prototype.subarray( [begin[, end]] ) @@ -1242,10 +1129,10 @@ ---------- locales: string|Array (optional) Locale identifier(s). - + options: Object (optional) An object containing serialization options. - + Returns ------- str: string @@ -1266,7 +1153,7 @@ ------- out: Complex128Array New typed array. - + Examples -------- > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) @@ -1310,12 +1197,12 @@ ---------- 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 ) ); }; @@ -1349,7 +1236,7 @@ ------- str: string String serialization of the array. - + Examples -------- > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) @@ -1365,7 +1252,7 @@ ------- iterator: Iterator Iterator for iterating over array values. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) @@ -1395,15 +1282,15 @@ ---------- index: integer Element index. - + value: Complex128 - Element value. + Element value. Returns ------- out: Complex128Array New typed array. - + Examples -------- > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) diff --git a/lib/node_modules/@stdlib/array/complex128/lib/main.js b/lib/node_modules/@stdlib/array/complex128/lib/main.js index d46359f10ec5..73232f899912 100644 --- a/lib/node_modules/@stdlib/array/complex128/lib/main.js +++ b/lib/node_modules/@stdlib/array/complex128/lib/main.js @@ -550,41 +550,21 @@ setReadOnly( Complex128Array, 'of', function of() { * @returns {(Complex128|void)} array element * * @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * var arr = new Complex128Array( 10 ); * * var z = arr.at( 0 ); -* // returns -* -* var re = real( z ); -* // returns 0.0 -* -* var im = imag( z ); -* // returns 0.0 +* // returns [ 0.0, 0.0 ] * * arr.set( [ 1.0, -1.0 ], 0 ); * arr.set( [ 2.0, -2.0 ], 1 ); * arr.set( [ 9.0, -9.0 ], 9 ); * * z = arr.at( 0 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns -1.0 +* // returns [ 1.0, -1.0 ] * * z = arr.at( -1 ); -* // returns -* -* re = real( z ); -* // returns 9.0 -* -* im = imag( z ); -* // returns -9.0 +* // returns [ 9.0, -9.0 ] * * z = arr.at( 100 ); * // returns undefined @@ -693,8 +673,6 @@ setReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYT * * @example * var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * var arr = new Complex128Array( 4 ); * @@ -708,13 +686,7 @@ setReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYT * 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 +* var z = arr.get( 3 );[ 2.0, 2.0 ] */ setReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) { if ( !isComplexArray( this ) ) { @@ -909,30 +881,16 @@ setReadOnly( Complex128Array.prototype, 'every', function every( predicate, this * @returns {Complex128Array} modified array * * @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * 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 +* // returns [ 1.0, 1.0 ] * * z = arr.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns 1.0 +* // returns [ 1.0, 1.0 ] */ setReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) { var buf; @@ -1002,8 +960,6 @@ setReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end * @returns {Complex128Array} complex number array * * @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -1022,13 +978,7 @@ setReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end * // returns 1 * * var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 2.0 -* -* var im = imag( z ); -* // returns 2.0 +* // returns [ 2.0, 2.0 ] */ setReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) { var buf; @@ -1065,8 +1015,6 @@ setReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, th * @returns {(Complex128|void)} array element or undefined * * @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * function predicate( v ) { * return ( real( v ) === imag( v ) ); @@ -1079,13 +1027,7 @@ setReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, th * 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 +* // returns [ 1.0, 1.0 ] */ setReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) { var buf; From 11eaf4c672048c2288070221806b384bb027f9a0 Mon Sep 17 00:00:00 2001 From: Aniket Sonawane Date: Thu, 5 Mar 2026 21:55:42 +0530 Subject: [PATCH 2/4] docs: improve doctests for complex number instances in array/complex128 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/complex128/lib/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/complex128/lib/main.js b/lib/node_modules/@stdlib/array/complex128/lib/main.js index 73232f899912..b3602b7e8879 100644 --- a/lib/node_modules/@stdlib/array/complex128/lib/main.js +++ b/lib/node_modules/@stdlib/array/complex128/lib/main.js @@ -686,7 +686,8 @@ setReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYT * arr.copyWithin( 2, 0, 2 ); * * // Get the last array element: -* var z = arr.get( 3 );[ 2.0, 2.0 ] +* var z = arr.get( 3 ); +* // returns [ 2.0, 2.0 ] */ setReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) { if ( !isComplexArray( this ) ) { From af083fb74d448600c45353320a9fb5e2bc46cba7 Mon Sep 17 00:00:00 2001 From: Aniket Sonawane Date: Fri, 6 Mar 2026 00:34:07 +0530 Subject: [PATCH 3/4] chore: trigger CI --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- From 762298337ed94dda76c108872c4ff31e2e0b37e2 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 10 Apr 2026 02:10:00 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/array/complex128/README.md | 6 ++++++ lib/node_modules/@stdlib/array/complex128/lib/main.js | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/array/complex128/README.md b/lib/node_modules/@stdlib/array/complex128/README.md index 042ded9ace1d..f700318485c0 100644 --- a/lib/node_modules/@stdlib/array/complex128/README.md +++ b/lib/node_modules/@stdlib/array/complex128/README.md @@ -339,6 +339,7 @@ To invoke a function for each `src` value, provide a callback function. If `src` var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function map( z ) { return new Complex128( real(z)*2.0, imag(z)*2.0 ); } @@ -773,6 +774,7 @@ Returns a new array containing the elements of an array which pass a test implem ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -841,6 +843,7 @@ Returns the first element in an array for which a predicate function returns a t ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -867,6 +870,7 @@ To set the function execution context, provide a `thisArg`. ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function predicate( v, i ) { this.count += 1; return ( i >= 0 && real( v ) === imag( v ) ); @@ -959,6 +963,7 @@ Returns the last element in an array for which a predicate function returns a tr ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function predicate( v ) { return ( real( v ) === imag( v ) ); } @@ -985,6 +990,7 @@ To set the function execution context, provide a `thisArg`. ```javascript var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); + function predicate( v, i ) { this.count += 1; return ( i >= 0 && real( v ) === imag( v ) ); diff --git a/lib/node_modules/@stdlib/array/complex128/lib/main.js b/lib/node_modules/@stdlib/array/complex128/lib/main.js index b3602b7e8879..49bd1f0ac59c 100644 --- a/lib/node_modules/@stdlib/array/complex128/lib/main.js +++ b/lib/node_modules/@stdlib/array/complex128/lib/main.js @@ -550,7 +550,6 @@ setReadOnly( Complex128Array, 'of', function of() { * @returns {(Complex128|void)} array element * * @example -* * var arr = new Complex128Array( 10 ); * * var z = arr.at( 0 ); @@ -882,7 +881,6 @@ setReadOnly( Complex128Array.prototype, 'every', function every( predicate, this * @returns {Complex128Array} modified array * * @example -* * var arr = new Complex128Array( 3 ); * * arr.fill( new Complex128( 1.0, 1.0 ), 1 ); @@ -961,7 +959,6 @@ setReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end * @returns {Complex128Array} complex number array * * @example -* * function predicate( v ) { * return ( real( v ) === imag( v ) ); * } @@ -1016,7 +1013,6 @@ setReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, th * @returns {(Complex128|void)} array element or undefined * * @example -* * function predicate( v ) { * return ( real( v ) === imag( v ) ); * }