diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/README.md new file mode 100644 index 000000000000..60b93fbb7656 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/README.md @@ -0,0 +1,202 @@ + + +# zlogspace + +> Fill a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval. + +
+ +
+ + + +
+ +## Usage + +```javascript +var zlogspace = require( '@stdlib/blas/ext/base/ndarray/zlogspace' ); +``` + +#### zlogspace( arrays ) + +Fills a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval. + + + +```javascript +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Complex128Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' +}); + +var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' +}); + +var stp = scalar2ndarray( new Complex128( 3.0, 0.0 ), { + 'dtype': 'complex128' +}); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); + +var out = zlogspace( [ x, base, strt, stp, endpoint ] ); +// returns [ [ 1.0, 0.0 ], [ 10.0, 0.0 ], [ 100.0, 0.0 ], [ 1000.0, 0.0 ] ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray specifying the base of the logarithmic scale. + - a zero-dimensional ndarray specifying the exponent of the starting value, where the starting value is given by `base^start`. + - a zero-dimensional ndarray specifying the exponent of the final value, where the final value is given by `base^stop`. + - a zero-dimensional ndarray specifying whether to include the `base^stop` value when writing values to the input ndarray. If `true`, the input ndarray is filled with logarithmically spaced values over the closed interval `[base^start, base^stop]`. If `false`, the input ndarray is filled with logarithmically spaced values over the half-open interval `[base^start, base^stop)`. + +
+ + + +
+ +## Notes + +- Let `M` be the number of generated values (which is either `N` or `N+1` depending on whether `endpoint` is `true` or `false`, respectively). The complex increment between exponents is thus given by + + ```text + Δ = (stop-start)/(M-1) + ``` + + and the generated values are equal to `base^(start+Δ*i)` for `i = 0, 1, ..., M-1`, where exponentiation is performed in the complex sense. + +- When the number of generated values is greater than `1` and `endpoint` is `true`, the set of values written to a provided input ndarray is guaranteed to include the `base^start` and `base^stop` values. Beware, however, that values between `base^start` and `base^stop` are subject to floating-point rounding errors. Hence, + + + + ```javascript + var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); + var Complex128 = require( '@stdlib/complex/float64/ctor' ); + var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + + var x = new Complex128Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + + var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + + var stp = scalar2ndarray( new Complex128( 1.0, 0.0 ), { + 'dtype': 'complex128' + }); + + var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + zlogspace( [ x, base, strt, stp, endpoint ] ); + + var v = x.get( 1 ); + // returns [ ~3.162, 0.0 ] + ``` + + where `v` is only guaranteed to be approximately equal to the square root of `10`. + +- When `N = 1` and `endpoint` is `false`, only the `base^start` value is written to a provided input ndarray. When `N = 1` and `endpoint` is `true`, only the `base^stop` value is written to a provided input ndarray. + +- Generated values follow a logarithmic spiral in the complex plane, where imaginary components of `start` and `stop` control phase rotation. If `Re(start) < Re(stop)`, the magnitudes of the generated values are in ascending order; otherwise, the magnitudes are in descending order. + +- The input ndarray is **mutated**. + +
+ + + +
+ +## Examples + + + +```javascript +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var zlogspace = require( '@stdlib/blas/ext/base/ndarray/zlogspace' ); + +var x = new Complex128Vector( 10 ); +console.log( ndarray2array( x ) ); + +var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' +}); +console.log( 'Base: %d', ndarraylike2scalar( base ) ); + +var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Start: %s', ndarraylike2scalar( strt ) ); + +var stp = scalar2ndarray( new Complex128( 9.0, 1.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Stop: %s', ndarraylike2scalar( stp ) ); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); +console.log( 'Endpoint: %s', ndarraylike2scalar( endpoint ) ); + +zlogspace( [ x, base, strt, stp, endpoint ] ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/benchmark/benchmark.js new file mode 100644 index 000000000000..000b6c690b37 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/benchmark/benchmark.js @@ -0,0 +1,120 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pkg = require( './../package.json' ).name; +var zlogspace = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var endpoint; + var base; + var strt; + var stp; + var x; + + x = new Complex128Vector( len ); + base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + stp = [ + scalar2ndarray( new Complex128( 9.0, 1.0 ), { + 'dtype': 'complex128' + }), + scalar2ndarray( new Complex128( 5.0, 1.0 ), { + 'dtype': 'complex128' + }) + ]; + endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + 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 = zlogspace( [ x, base, strt, stp[ i%2 ], endpoint ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/repl.txt new file mode 100644 index 000000000000..a6c668bf3175 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/repl.txt @@ -0,0 +1,67 @@ + +{{alias}}( arrays ) + Fills a one-dimensional double-precision complex floating-point ndarray + with logarithmically spaced values over a specified interval. + + Let `N` be the number of elements in the input ndarray. If `N = 1` and + `endpoint` is `true`, the set of values written to an input ndarray only + includes `base^stop`, but not `base^start`; otherwise, when `N = 1` and + `endpoint` is `false`, the set of values written to an input ndarray only + includes `base^start`, but not `base^stop`. + + Generated values follow a logarithmic spiral in the complex plane, where + imaginary components of `start` and `stop` control phase rotation. If the + real part of `start` is less than that of `stop`, the magnitudes of the + generated values will be in ascending order; otherwise, the magnitudes will + be in descending order. + + When `N >= 2` and `endpoint` is `true`, the set of values written to an + input ndarray is guaranteed to include the `base^start` and `base^stop` + values. Beware, however, that values between `base^start` and `base^stop` + are subject to floating-point rounding errors. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray specifying the base of the logarithmic + scale. + - a zero-dimensional ndarray specifying the exponent of the starting + value. + - a zero-dimensional ndarray specifying the exponent of the final + value. + - a zero-dimensional ndarray specifying whether to include the + `base^stop` value when writing values to the input ndarray. + + Returns + ------- + out: ndarray + Input ndarray. + + Examples + -------- + // Create the input ndarray: + > var x = new {{alias:@stdlib/ndarray/vector/complex128}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + + // Specify the base: + > var base = {{alias:@stdlib/ndarray/from-scalar}}( 10.0, { 'dtype': 'float64' } ); + + // Specify the exponent of the starting value: + > var s = new {{alias:@stdlib/complex/float64/ctor}}( 0.0, 0.0 ); + > var strt = {{alias:@stdlib/ndarray/from-scalar}}( s, { 'dtype': 'complex128' } ); + + // Specify the exponent of the final value: + > s = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 0.0 ); + > var stp = {{alias:@stdlib/ndarray/from-scalar}}( s, { 'dtype': 'complex128' } ); + + // Specify whether to include the endpoint: + > var endpoint = {{alias:@stdlib/ndarray/from-scalar}}( true, { 'dtype': 'bool' } ); + + // Fill the input ndarray: + > {{alias}}( [ x, base, strt, stp, endpoint ] ) + [ [ 1.0, 0.0 ], [ 10.0, 0.0 ] ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/index.d.ts new file mode 100644 index 000000000000..fc25015d500b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/index.d.ts @@ -0,0 +1,72 @@ +/* +* @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 { complex128ndarray, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Fills a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the base of the logarithmic scale. +* - a zero-dimensional ndarray specifying the exponent of the starting value. +* - a zero-dimensional ndarray specifying the exponent of the final value. +* - a zero-dimensional ndarray specifying whether to include the `base^stop` value when writing values to the input ndarray. +* +* @param arrays - array-like object containing ndarrays +* @returns input ndarray +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Complex128Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var stp = scalar2ndarray( new Complex128( 3.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = zlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ [ 1.0, 0.0 ], [ 10.0, 0.0 ], [ 100.0, 0.0 ], [ 1000.0, 0.0 ] ] +*/ +declare function zlogspace( arrays: [ complex128ndarray, typedndarray, complex128ndarray, complex128ndarray, typedndarray ] ): complex128ndarray; + + +// EXPORTS // + +export = zlogspace; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/test.ts new file mode 100644 index 000000000000..e56415919504 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/docs/types/test.ts @@ -0,0 +1,83 @@ +/* +* @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 space-in-parens */ + +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import zlogspace = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + const strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + const stp = scalar2ndarray( new Complex128( 9.0, 1.0 ), { + 'dtype': 'complex128' + }); + const endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + zlogspace( [ x, base, strt, stp, endpoint ] ); // $ExpectType complex128ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + zlogspace( '10' ); // $ExpectError + zlogspace( 10 ); // $ExpectError + zlogspace( true ); // $ExpectError + zlogspace( false ); // $ExpectError + zlogspace( null ); // $ExpectError + zlogspace( undefined ); // $ExpectError + zlogspace( [] ); // $ExpectError + zlogspace( {} ); // $ExpectError + zlogspace( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'complex128' + }); + const base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + const strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + const stp = scalar2ndarray( new Complex128( 9.0, 1.0 ), { + 'dtype': 'complex128' + }); + const endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + zlogspace(); // $ExpectError + zlogspace( [ x, base, strt, stp, endpoint ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/examples/index.js new file mode 100644 index 000000000000..3189f012af89 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/examples/index.js @@ -0,0 +1,52 @@ +/** +* @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 Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var zlogspace = require( './../lib' ); + +var x = new Complex128Vector( 10 ); +console.log( ndarray2array( x ) ); + +var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' +}); +console.log( 'Base: %d', ndarraylike2scalar( base ) ); + +var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Start: %s', ndarraylike2scalar( strt ) ); + +var stp = scalar2ndarray( new Complex128( 9.0, 1.0 ), { + 'dtype': 'complex128' +}); +console.log( 'Stop: %s', ndarraylike2scalar( stp ) ); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); +console.log( 'Endpoint: %s', ndarraylike2scalar( endpoint ) ); + +zlogspace( [ x, base, strt, stp, endpoint ] ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/index.js new file mode 100644 index 000000000000..ca248256859f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/index.js @@ -0,0 +1,61 @@ +/** +* @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'; + +/** +* Fill a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval. +* +* @module @stdlib/blas/ext/base/ndarray/zlogspace +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var zlogspace = require( '@stdlib/blas/ext/base/ndarray/zlogspace' ); +* +* var x = new Complex128Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var stp = scalar2ndarray( new Complex128( 3.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = zlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ [ 1.0, 0.0 ], [ 10.0, 0.0 ], [ 100.0, 0.0 ], [ 1000.0, 0.0 ] ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/main.js new file mode 100644 index 000000000000..33300c6b8500 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/lib/main.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 ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/zlogspace' ).ndarray; + + +// MAIN // + +/** +* Fills a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the base of the logarithmic scale. +* - a zero-dimensional ndarray specifying the exponent of the starting value. +* - a zero-dimensional ndarray specifying the exponent of the final value. +* - a zero-dimensional ndarray specifying whether to include the `base^stop` value when writing values to the input ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} input ndarray +* +* @example +* var Complex128Vector = require( '@stdlib/ndarray/vector/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Complex128Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var stp = scalar2ndarray( new Complex128( 3.0, 0.0 ), { +* 'dtype': 'complex128' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = zlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ [ 1.0, 0.0 ], [ 10.0, 0.0 ], [ 100.0, 0.0 ], [ 1000.0, 0.0 ] ] +*/ +function zlogspace( arrays ) { + var endpoint; + var base; + var strt; + var stp; + var x; + + x = arrays[ 0 ]; + base = ndarraylike2scalar( arrays[ 1 ] ); + strt = ndarraylike2scalar( arrays[ 2 ] ); + stp = ndarraylike2scalar( arrays[ 3 ] ); + endpoint = ndarraylike2scalar( arrays[ 4 ] ); + + strided( numelDimension( x, 0 ), base, strt, stp, endpoint, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len + + return x; +} + + +// EXPORTS // + +module.exports = zlogspace; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/package.json new file mode 100644 index 000000000000..c1e40ff097f4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/zlogspace", + "version": "0.0.0", + "description": "Fill a one-dimensional double-precision complex floating-point ndarray with logarithmically spaced values over a specified interval.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "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", + "blas", + "extended", + "fill", + "assign", + "set", + "logspace", + "logarithmic", + "sequence", + "seq", + "strided", + "array", + "ndarray", + "complex", + "complex128", + "double-precision", + "float64" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/test/test.js new file mode 100644 index 000000000000..bb969939d00e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/zlogspace/test/test.js @@ -0,0 +1,124 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var isEqualDataType = require( '@stdlib/ndarray/base/assert/is-equal-data-type' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var cos = require( '@stdlib/math/base/special/cos' ); +var sin = require( '@stdlib/math/base/special/sin' ); +var E = require( '@stdlib/constants/float64/e' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var getStrides = require( '@stdlib/ndarray/strides' ); +var getOffset = require( '@stdlib/ndarray/offset' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var zlogspace = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlogspace, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function fills a one-dimensional ndarray (endpoint=true)', function test( t ) { + var endpoint; + var expected; + var actual; + var strt; + var base; + var lnb; + var stp; + var x; + + lnb = ln( E ); + + x = ndarray( 'complex128', new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + base = scalar2ndarray( E, { + 'dtype': 'float64' + }); + strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + stp = scalar2ndarray( new Complex128( 0.0, 1.0 ), { + 'dtype': 'complex128' + }); + endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + actual = zlogspace( [ x, base, strt, stp, endpoint ] ); + expected = new Complex128Array( [ 1.0, 0.0, cos( lnb ), sin( lnb ) ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), 'complex128' ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2 ], 'returns expected value' ); + t.deepEqual( getStrides( actual ), [ 1 ], 'returns expected value' ); + t.strictEqual( getOffset( actual ), 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function fills a one-dimensional ndarray (endpoint=false)', function test( t ) { + var endpoint; + var expected; + var actual; + var strt; + var base; + var lnb; + var stp; + var x; + + lnb = ln( E ); + + x = ndarray( 'complex128', new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + base = scalar2ndarray( E, { + 'dtype': 'float64' + }); + strt = scalar2ndarray( new Complex128( 0.0, 0.0 ), { + 'dtype': 'complex128' + }); + stp = scalar2ndarray( new Complex128( 0.0, 2.0 ), { + 'dtype': 'complex128' + }); + endpoint = scalar2ndarray( false, { + 'dtype': 'bool' + }); + + actual = zlogspace( [ x, base, strt, stp, endpoint ] ); + expected = new Complex128Array( [ 1.0, 0.0, cos( lnb ), sin( lnb ) ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), 'complex128' ), true, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( getData( actual ), expected ), true, 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 2 ], 'returns expected value' ); + t.deepEqual( getStrides( actual ), [ 1 ], 'returns expected value' ); + t.strictEqual( getOffset( actual ), 0, 'returns expected value' ); + + t.end(); +});