diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/README.md b/lib/node_modules/@stdlib/lapack/base/zlacgv/README.md new file mode 100644 index 000000000000..52e8cad0b2df --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/README.md @@ -0,0 +1,225 @@ + + +# zlacgv + +> Conjugate each element in a double-precision complex floating-point vector. + +
+ +## Usage + +```javascript +var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); +``` + +#### zlacgv( N, zx, strideZX ) + +Conjugates each element in a double-precision complex floating-point vector. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + +zlacgv( 2, zx, 1 ); + +var z = zx.get( 0 ); +// returns + +var re = real( z ); +// returns 1.0 + +var im = imag( z ); +// returns -2.0 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **zx**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideZX**: stride length for `zx`. + +The `N` and stride parameters determine which elements in `zx` are conjugated. For example, to conjugate every other element in `zx`, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +zlacgv( 2, zx, 2 ); + +var z = zx.get( 0 ); +// returns + +var re = real( z ); +// returns 1.0 + +var im = imag( z ); +// returns -2.0 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +// Initial array: +var zx0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +// Create an offset view: +var zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +// Conjugate every element in `zx1`: +zlacgv( 3, zx1, 1 ); + +var z = zx0.get( 1 ); +// returns + +var re = real( z ); +// returns 3.0 + +var im = imag( z ); +// returns -4.0 +``` + +#### zlacgv.ndarray( N, zx, strideZX, offsetZX ) + +Conjugates each element in a double-precision floating-point vector using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +zlacgv.ndarray( 3, zx, 1, 0 ); + +var z = zx.get( 0 ); +// returns + +var re = real( z ); +// returns 1.0 + +var im = imag( z ); +// returns -2.0 +``` + +The function has the following additional parameters: + +- **offsetZX**: starting index for `zx`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to conjugate every other element in the input strided array starting from the second element, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + +zlacgv.ndarray( 2, zx, 2, 1 ); + +var z = zx.get( 3 ); +// returns + +var re = real( z ); +// returns 7.0 + +var im = imag( z ); +// returns -8.0 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `zx` unchanged. +- `zlacgv()` corresponds to the [LAPACK][lapack] BLAS-like level 1 routine [`zlacgv`][zlacgv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +// Conjugate elements: +zlacgv( zx.length, zx, 1 ); +console.log( zx.get( zx.length-1 ).toString() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.js new file mode 100644 index 000000000000..b60f0d1b15a5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var zlacgv = require( './../lib/zlacgv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zxbuf; + var zx; + + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.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++ ) { + zlacgv( zx.length, zx, 1 ); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return 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 = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..415187e72284 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var zlacgv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zxbuf; + var zx; + + zxbuf = uniform( len*2, -100.0, 100.0, options ); + zx = new Complex128Array( zxbuf.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++ ) { + zlacgv( zx.length, zx, 1, 0 ); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( zxbuf[ i%(len*2) ] ) ) { + b.fail( 'should not return 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 = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/repl.txt new file mode 100644 index 000000000000..7d6dd2f01f9d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/repl.txt @@ -0,0 +1,108 @@ + +{{alias}}( N, zx, strideZX ) + Conjugates each element in a double-precision complex floating-point vector. + + The `N` and stride parameters determine which elements in `zx` are + conjugated. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is less than or equal to `0`, the function returns `zx` unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + Input array. + + strideZX: integer + Stride length for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 2, zx, 1 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 2, zx, 2 ); + > z = zx.get( 0 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + // Using typed array views: + > var zx0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex128}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 2, zx1, 1 ); + > z = zx0.get( 1 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -4.0 + + +{{alias}}.ndarray( N, zx, strideZX, offsetZX ) + Conjugates each element in a double-precision complex floating-point vector + using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a starting + index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex128Array + Input array. + + strideZX: integer + Stride length for `zx`. + + offsetZX: integer + Starting index for `zx`. + + Returns + ------- + zx: Complex128Array + Input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, zx, 1, 0 ); + > var z = zx.get( 0 ); + > var re = {{alias:@stdlib/complex/float64/real}}( z ) + 1.0 + > var im = {{alias:@stdlib/complex/float64/imag}}( z ) + -2.0 + + // Advanced indexing: + > zx = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > {{alias}}.ndarray( 2, zx, 1, 2 ); + > z = zx.get( 2 ); + > re = {{alias:@stdlib/complex/float64/real}}( z ) + 5.0 + > im = {{alias:@stdlib/complex/float64/imag}}( z ) + -6.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/index.d.ts new file mode 100644 index 000000000000..5eb0c409bf1e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/index.d.ts @@ -0,0 +1,136 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `zlacgv`. +*/ +interface Routine { + /** + * Conjugates each element in a double-precision complex floating-point vector. + * + * @param N - number of indexed elements + * @param zx - input array + * @param strideZX - `zx` stride length + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * zlacgv( 3, zx, 1 ); + * + * var z = zx.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -2.0 + */ + ( N: number, zx: Complex128Array, strideZX: number ): Complex128Array; + + /** + * Conjugates each element in a double-precision complex floating-point vector. + * + * @param N - number of indexed elements + * @param zx - input array + * @param strideZX - `zx` stride length + * @param offsetZX - starting index for `zx` + * @returns input array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * + * var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * zlacgv.ndarray( 3, zx, 1, 0 ); + * + * var z = zx.get( 0 ); + * // returns + * + * var re = real( z ); + * // returns 1.0 + * + * var im = imag( z ); + * // returns -2.0 + */ + ndarray( N: number, zx: Complex128Array, strideZX: number, offsetZX: number ): Complex128Array; +} + +/** +* Conjugates each element in a double-precision complex floating-point vector. +* +* @param N - number of indexed elements +* @param zx - input array +* @param strideZX - `zx` stride length +* @returns input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv( 3, zx, 1 ); +* +* var z = zx.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns -4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv.ndarray( 2, zx, 1, 1 ); +* +* var z = zx.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns -4.0 +*/ +declare var zlacgv: Routine; + + +// EXPORTS // + +export = zlacgv; diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/test.ts new file mode 100644 index 000000000000..316833499da0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/docs/types/test.ts @@ -0,0 +1,158 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import zlacgv = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zlacgv( zx.length, zx, 1 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zlacgv( '10', zx, 1 ); // $EzxpectError + zlacgv( true, zx, 1 ); // $ExpectError + zlacgv( false, zx, 1 ); // $ExpectError + zlacgv( null, zx, 1 ); // $ExpectError + zlacgv( undefined, zx, 1 ); // $ExpectError + zlacgv( [], zx, 1 ); // $ExpectError + zlacgv( {}, zx, 1 ); // $ExpectError + zlacgv( ( zx: number ): number => zx, zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zlacgv( zx.length, 10, 1 ); // $ExpectError + zlacgv( zx.length, '10', 1 ); // $ExpectError + zlacgv( zx.length, true, 1 ); // $ExpectError + zlacgv( zx.length, false, 1 ); // $ExpectError + zlacgv( zx.length, null, 1 ); // $ExpectError + zlacgv( zx.length, undefined, 1 ); // $ExpectError + zlacgv( zx.length, [ '1' ], 1 ); // $ExpectError + zlacgv( zx.length, {}, 1 ); // $ExpectError + zlacgv( zx.length, ( zx: number ): number => zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zlacgv( zx.length, zx, '10' ); // $ExpectError + zlacgv( zx.length, zx, true ); // $ExpectError + zlacgv( zx.length, zx, false ); // $ExpectError + zlacgv( zx.length, zx, null ); // $ExpectError + zlacgv( zx.length, zx, undefined ); // $ExpectError + zlacgv( zx.length, zx, [] ); // $ExpectError + zlacgv( zx.length, zx, {} ); // $ExpectError + zlacgv( zx.length, zx, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + zlacgv(); // $ExpectError + zlacgv( zx.length ); // $ExpectError + zlacgv( zx.length, zx ); // $ExpectError + zlacgv( zx.length, zx, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zlacgv.ndarray( zx.length, zx, 1, 0 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zlacgv.ndarray( '10', zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( true, zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( false, zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( null, zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( undefined, zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( [], zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( {}, zx, 1, 0 ); // $ExpectError + zlacgv.ndarray( ( zx: number ): number => zx, zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const zx = new Complex128Array( 10 ); + + zlacgv( zx.length, 10, 1, 0 ); // $ExpectError + zlacgv( zx.length, '10', 1, 0 ); // $ExpectError + zlacgv( zx.length, true, 1, 0 ); // $ExpectError + zlacgv( zx.length, false, 1, 0 ); // $ExpectError + zlacgv( zx.length, null, 1, 0 ); // $ExpectError + zlacgv( zx.length, undefined, 1, 0 ); // $ExpectError + zlacgv( zx.length, [ '1' ], 1, 0 ); // $ExpectError + zlacgv( zx.length, {}, 1, 0 ); // $ExpectError + zlacgv( zx.length, ( zx: number ): number => zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zlacgv.ndarray( zx.length, zx, '10', 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, true, 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, false, 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, null, 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, undefined, 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, [], 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, {}, 0 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, ( zx: number ): number => zx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex128Array( 10 ); + + zlacgv.ndarray( zx.length, zx, 1, '10' ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, true ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, false ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, null ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, undefined ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, [] ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, {} ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex128Array( 10 ); + + zlacgv.ndarray(); // $ExpectError + zlacgv.ndarray( zx.length ); // $ExpectError + zlacgv.ndarray( zx.length, zx ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1 ); // $ExpectError + zlacgv.ndarray( zx.length, zx, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/examples/index.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/examples/index.js new file mode 100644 index 000000000000..400a205f9d18 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var zlacgv = require( './../lib' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex128', rand ); +console.log( zx.toString() ); + +// Conjugate elements: +zlacgv( zx.length, zx, 1 ); +console.log( zx.get( zx.length-1 ).toString() ); diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/index.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/index.js new file mode 100644 index 000000000000..cbe244398be4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/index.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* LAPACK BLAS-like level-1 routine to conjugate each element in a double-precision complex floating-point vector. +* +* @module @stdlib/lapack/base/zlacgv +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv( 3, zx, 1 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 1.0 +* +* var im = imag( z ); +* // returns -2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* var zlacgv = require( '@stdlib/lapack/base/zlacgv' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv.ndarray( 3, 1, 0 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 1.0 +* +* var im = imag( z ); +* // returns -2.0 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var zlacgv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zlacgv = main; +} else { + zlacgv = tmp; +} + + +// EXPORTS // + +module.exports = zlacgv; + +// exports: { "ndarray": "zlacgv.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/main.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/main.js new file mode 100644 index 000000000000..6fcede7ec60e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var zlacgv = require( './zlacgv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zlacgv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zlacgv; diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/ndarray.js new file mode 100644 index 000000000000..d4584f505972 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/ndarray.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); + + +// MAIN // + +/** +* Conjugates each element in a double-precision complex floating-point vector. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - input array +* @param {integer} strideZX - `zx` stride length +* @param {NonNegativeInteger} offsetZX - starting `zx` index +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv( 3, zx, 1, 0 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 1.0 +* +* var im = imag( z ); +* // returns -2.0 +*/ +function zlacgv( N, zx, strideZX, offsetZX ) { + var zx64; + var ix; + var sx; + var i; + + if ( N <= 0 ) { + return zx; + } + // Reinterpret the input array as a real-valued array of interleaved real and imaginary components: + zx64 = reinterpret( zx, 0 ); + + // Adjust the strides and offset: + sx = strideZX * 2; + ix = ( offsetZX * 2 ) + 1; // index of the first imaginary component + + // Conjugate each element by negating the imaginary components... + for ( i = 0; i < N; i++ ) { + zx64[ ix ] = -zx64[ ix ]; + ix += sx; + } + return zx; +} + + +// EXPORTS // + +module.exports = zlacgv; diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/zlacgv.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/zlacgv.js new file mode 100644 index 000000000000..d4ed37909628 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/lib/zlacgv.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Conjugates each element in a double-precision complex floating-point vector. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} zx - input array +* @param {integer} strideZX - `zx` stride length +* @returns {Complex128Array} input array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* zlacgv( 3, zx, 1 ); +* +* var z = zx.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 1.0 +* +* var im = imag( z ); +* // returns -2.0 +*/ +function zlacgv( N, zx, strideZX ) { + return ndarray( N, zx, strideZX, stride2offset( N, strideZX ) ); +} + + +// EXPORTS // + +module.exports = zlacgv; diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/package.json b/lib/node_modules/@stdlib/lapack/base/zlacgv/package.json new file mode 100644 index 000000000000..83f9b07e6c0f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/package.json @@ -0,0 +1,78 @@ +{ + "name": "@stdlib/lapack/base/zlacgv", + "version": "0.0.0", + "description": "Conjugate each element in a double-precision complex floating-point vector.", + "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", + "browser": "./lib/main.js", + "directories": { + "benchmark": "./benchmark", + "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", + "stdmath", + "mathematics", + "math", + "lapack", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "zlacgv", + "conjugate", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "double", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.js new file mode 100644 index 000000000000..fa0b9473898e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 proxyquire = require( 'proxyquire' ); +var isBrowser = require( '@stdlib/assert/is-browser' ); +var zlacgv = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': isBrowser +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlacgv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof zlacgv.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var zlacgv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zlacgv, mock, 'returns native implementation' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var zlacgv; + var main; + + main = require( './../lib/zlacgv.js' ); + + zlacgv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zlacgv, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.ndarray.js new file mode 100644 index 000000000000..63d59c2b54b4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.ndarray.js @@ -0,0 +1,283 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zlacgv = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlacgv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( zlacgv.length, 4, 'arity of 4' ); + t.end(); +}); + +tape( 'the function conjugates elements in a strided array', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ]); + + zlacgv( 4, zx, 1, 0 ); + + expected = new Complex128Array([ + 0.3, // 1 + -0.1, // 1 + 0.5, // 2 + -0.0, // 2 + 0.0, // 3 + -0.5, // 3 + 0.0, // 4 + -0.2, // 4 + 2.0, + 3.0, + 2.0, + 3.0 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `zx` stride', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.1, // 1 + 0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + -0.3, // 3 + 7.0, + 2.0 + ]); + + zlacgv( 3, zx, 2, 0 ); + + expected = new Complex128Array([ + 0.1, // 1 + -0.1, // 1 + 3.0, + 6.0, + -0.6, // 2 + -0.1, // 2 + 4.0, + 7.0, + 0.1, // 3 + 0.3, // 3 + 7.0, + 2.0 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `zx` stride', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.1, // 3 + 0.1, // 3 + 3.0, + 6.0, + -0.6, // 2 + 0.1, // 2 + 4.0, + 7.0, + 0.1, // 1 + -0.3, // 1 + 7.0, + 2.0 + ]); + + zlacgv( 3, zx, -2, 4 ); + + expected = new Complex128Array([ + 0.1, // 3 + -0.1, // 3 + 3.0, + 6.0, + -0.6, // 2 + -0.1, // 2 + 4.0, + 7.0, + 0.1, // 1 + 0.3, // 1 + 7.0, + 2.0 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `zx` offset', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, // 2 + -0.3, // 2 + 7.0, // 3 + 2.0 // 3 + ]); + + zlacgv( 3, zx, 1, 3 ); + + expected = new Complex128Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + -6.0, // 1 + 0.1, // 2 + 0.3, // 2 + 7.0, // 3 + -2.0 // 3 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + out = zlacgv( 4, zx, 1, 0 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + expected = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0 + ]); + + zlacgv( -1, zx, 1, 0 ); + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + zlacgv( 0, zx, 1, 0 ); + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + 6.0, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.0, // 2 + 3.0 // 2 + ]); + + zlacgv( 2, zx, -3, 6 ); + + expected = new Complex128Array([ + 0.1, + 0.1, + 3.0, + 6.0, + -0.6, + 0.1, + 4.0, // 1 + -6.0, // 1 + 0.1, + -0.3, + 7.0, + 2.0, + 2.0, // 2 + -3.0 // 2 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.zlacgv.js b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.zlacgv.js new file mode 100644 index 000000000000..e60b44ebdee8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlacgv/test/test.zlacgv.js @@ -0,0 +1,235 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zlacgv = require( './../lib/zlacgv.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlacgv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( zlacgv.length, 3, 'arity of 3' ); + t.end(); +}); + +tape( 'the function conjugates elements in a strided array', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 0.3, // 1 + 0.1, // 1 + 0.5, // 2 + 0.0, // 2 + 0.0, // 3 + 0.5, // 3 + 0.0, // 4 + 0.2 // 4 + ]); + + zlacgv( 4, zx, 1 ); + + expected = new Complex128Array([ + 0.3, // 1 + -0.1, // 1 + 0.5, // 2 + -0.0, // 2 + 0.0, // 3 + -0.5, // 3 + 0.0, // 4 + -0.2 // 4 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a `zx` stride', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0, + 9.0, // 3 + 10.0, // 3 + 11.0, + 12.0 + ]); + + zlacgv( 3, zx, 2 ); + + expected = new Complex128Array([ + 1.0, // 1 + -2.0, // 1 + 3.0, + 4.0, + 5.0, // 2 + -6.0, // 2 + 7.0, + 8.0, + 9.0, // 3 + -10.0, // 3 + 11.0, + 12.0 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative `zx` stride', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array([ + 1.0, // 3 + 2.0, // 3 + 3.0, + 4.0, + 5.0, // 2 + 6.0, // 2 + 7.0, + 8.0, + 9.0, // 1 + 10.0, // 1 + 11.0, + 12.0 + ]); + + zlacgv( 3, zx, -2 ); + + expected = new Complex128Array([ + 1.0, // 3 + -2.0, // 3 + 3.0, + 4.0, + 5.0, // 2 + -6.0, // 2 + 7.0, + 8.0, + 9.0, // 1 + -10.0, // 1 + 11.0, + 12.0 + ]); + + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the input array', function test( t ) { + var out; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + out = zlacgv( 4, zx, 1 ); + + t.strictEqual( out, zx, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns the input array unchanged', function test( t ) { + var expected; + var zx; + + zx = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + expected = new Complex128Array([ + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0 + ]); + + zlacgv( -1, zx, 1 ); + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + zlacgv( 0, zx, 1 ); + t.ok( isSameComplex128Array( zx, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var zx0; + var zx1; + + // Initial arrays... + zx0 = new Complex128Array([ + 0.1, + -0.3, + 8.0, // 1 + 9.0, // 1 + 0.5, // 2 + -0.1, // 2 + 2.0, // 3 + 5.0, // 3 + 2.0, + 3.0 + ]); + + // Create offset views... + zx1 = new Complex128Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element + + zlacgv( 3, zx1, 1 ); + + expected = new Complex128Array([ + 0.1, + -0.3, + 8.0, // 1 + -9.0, // 1 + 0.5, // 2 + 0.1, // 2 + 2.0, // 3 + -5.0, // 3 + 2.0, + 3.0 + ]); + + t.ok( isSameComplex128Array( zx0, expected ), 'returns expected value' ); + + t.end(); +});