diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/README.md new file mode 100644 index 000000000000..2f8a4627faf7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/README.md @@ -0,0 +1,196 @@ + + +# dlogspace + +> Fill a one-dimensional double-precision floating-point ndarray with logarithmically spaced values over a specified interval. + +
+ +
+ + + +
+ +## Usage + +```javascript +var dlogspace = require( '@stdlib/blas/ext/base/ndarray/dlogspace' ); +``` + +#### dlogspace( arrays ) + +Fills a one-dimensional double-precision floating-point ndarray with logarithmically spaced values over a specified interval. + +```javascript +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Float64Vector( [ 0.0, 0.0, 0.0, 0.0 ] ); + +var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' +}); + +var strt = scalar2ndarray( 0.0, { + 'dtype': 'float64' +}); + +var stp = scalar2ndarray( 3.0, { + 'dtype': 'float64' +}); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); + +var out = dlogspace( [ x, base, strt, stp, endpoint ] ); +// returns [ 1.0, 10.0, 100.0, 1000.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 spacing between the 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`. + +- 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 Float64Vector = require( '@stdlib/ndarray/vector/float64' ); + var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + var ndarray2array = require( '@stdlib/ndarray/to-array' ); + + var x = new Float64Vector( [ 0.0, 0.0, 0.0 ] ); + + var base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + + var strt = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + + var stp = scalar2ndarray( 1.0, { + 'dtype': 'float64' + }); + + var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + dlogspace( [ x, base, strt, stp, endpoint ] ); + + var arr = ndarray2array( x ); + // returns [ 1.0, ~3.16, 10.0 ] + ``` + + where `arr[1]` 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. + +- If `start < stop`, the exponents are written to a provided input ndarray in ascending order; otherwise, they are written in descending order. + +- The input ndarray is **mutated**. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var dlogspace = require( '@stdlib/blas/ext/base/ndarray/dlogspace' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = discreteUniform( [ 10 ], -100, 100, opts ); +console.log( ndarray2array( x ) ); + +var base = scalar2ndarray( 10.0, opts ); +console.log( 'Base: %d', ndarraylike2scalar( base ) ); + +var strt = scalar2ndarray( 0.0, opts ); +console.log( 'Start: %d', ndarraylike2scalar( strt ) ); + +var stp = scalar2ndarray( 9.0, opts ); +console.log( 'Stop: %d', ndarraylike2scalar( stp ) ); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); +console.log( 'Endpoint: %s', ndarraylike2scalar( endpoint ) ); + +dlogspace( [ x, base, strt, stp, endpoint ] ); +console.log( ndarray2array( x ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/benchmark/benchmark.js new file mode 100644 index 000000000000..31b441779d88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/benchmark/benchmark.js @@ -0,0 +1,119 @@ +/** +* @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 uniform = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dlogspace = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 = uniform( [ len ], 0.0, 100.0, options ); + base = scalar2ndarray( 10.0, options ); + strt = scalar2ndarray( 0.0, options ); + stp = [ + scalar2ndarray( 9.0, options ), + scalar2ndarray( 5.0, options ) + ]; + 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 = dlogspace( [ x, base, strt, stp[ i%2 ], endpoint ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( out.get( i%len ) ) ) { + 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/repl.txt new file mode 100644 index 000000000000..372082327c69 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/repl.txt @@ -0,0 +1,65 @@ + +{{alias}}( arrays ) + Fills a one-dimensional double-precision 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`. + + If `start` is less than `stop`, the set of values written to an input + ndarray will be written in ascending order, and, if `start` is greater than + `stop`, the set of written values 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 opts = { 'dtype': 'float64' }; + > var x = new {{alias:@stdlib/ndarray/vector/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + + // Specify the base: + > var base = {{alias:@stdlib/ndarray/from-scalar}}( 10.0, opts ); + + // Specify the exponent of the starting value: + > var strt = {{alias:@stdlib/ndarray/from-scalar}}( 0.0, opts ); + + // Specify the exponent of the final value: + > var stp = {{alias:@stdlib/ndarray/from-scalar}}( 3.0, opts ); + + // Specify whether to include the endpoint: + > opts = { 'dtype': 'bool' }; + > var endpoint = {{alias:@stdlib/ndarray/from-scalar}}( true, opts ); + + // Fill the input ndarray: + > {{alias}}( [ x, base, strt, stp, endpoint ] ) + [ 1.0, 10.0, 100.0, 1000.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/index.d.ts new file mode 100644 index 000000000000..8c7324e84ca5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/index.d.ts @@ -0,0 +1,71 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { float64ndarray, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Fills a one-dimensional double-precision 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 Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var stp = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = dlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0 ] +*/ +declare function dlogspace( arrays: [ float64ndarray, typedndarray, typedndarray, typedndarray, typedndarray ] ): float64ndarray; + + +// EXPORTS // + +export = dlogspace; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/test.ts new file mode 100644 index 000000000000..870e0f0c5afa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/docs/types/test.ts @@ -0,0 +1,82 @@ +/* +* @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 zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import dlogspace = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + const strt = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + const stp = scalar2ndarray( 9.0, { + 'dtype': 'float64' + }); + const endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + dlogspace( [ x, base, strt, stp, endpoint ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + dlogspace( '10' ); // $ExpectError + dlogspace( 10 ); // $ExpectError + dlogspace( true ); // $ExpectError + dlogspace( false ); // $ExpectError + dlogspace( null ); // $ExpectError + dlogspace( undefined ); // $ExpectError + dlogspace( [] ); // $ExpectError + dlogspace( {} ); // $ExpectError + dlogspace( ( 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': 'float64' + }); + const base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + const strt = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + const stp = scalar2ndarray( 9.0, { + 'dtype': 'float64' + }); + const endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + dlogspace(); // $ExpectError + dlogspace( [ x, base, strt, stp, endpoint ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/examples/index.js new file mode 100644 index 000000000000..287578cde23e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/examples/index.js @@ -0,0 +1,49 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); +var dlogspace = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var x = discreteUniform( [ 10 ], -100, 100, opts ); +console.log( ndarray2array( x ) ); + +var base = scalar2ndarray( 10.0, opts ); +console.log( 'Base: %d', ndarraylike2scalar( base ) ); + +var strt = scalar2ndarray( 0.0, opts ); +console.log( 'Start: %d', ndarraylike2scalar( strt ) ); + +var stp = scalar2ndarray( 9.0, opts ); +console.log( 'Stop: %d', ndarraylike2scalar( stp ) ); + +var endpoint = scalar2ndarray( true, { + 'dtype': 'bool' +}); +console.log( 'Endpoint: %s', ndarraylike2scalar( endpoint ) ); + +dlogspace( [ x, base, strt, stp, endpoint ] ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/index.js new file mode 100644 index 000000000000..73ff1bd8b800 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/index.js @@ -0,0 +1,60 @@ +/** +* @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 floating-point ndarray with logarithmically spaced values over a specified interval. +* +* @module @stdlib/blas/ext/base/ndarray/dlogspace +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var dlogspace = require( '@stdlib/blas/ext/base/ndarray/dlogspace' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var stp = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = dlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/main.js new file mode 100644 index 000000000000..565377e7bccc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/lib/main.js @@ -0,0 +1,95 @@ +/** +* @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/dlogspace' ).ndarray; + + +// MAIN // + +/** +* Fills a one-dimensional double-precision 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 Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float64Vector( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* var base = scalar2ndarray( 10.0, { +* 'dtype': 'float64' +* }); +* +* var strt = scalar2ndarray( 0.0, { +* 'dtype': 'float64' +* }); +* +* var stp = scalar2ndarray( 5.0, { +* 'dtype': 'float64' +* }); +* +* var endpoint = scalar2ndarray( true, { +* 'dtype': 'bool' +* }); +* +* var out = dlogspace( [ x, base, strt, stp, endpoint ] ); +* // returns [ 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0 ] +*/ +function dlogspace( 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 = dlogspace; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/package.json new file mode 100644 index 000000000000..de3b562963ed --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/dlogspace", + "version": "0.0.0", + "description": "Fill a one-dimensional double-precision 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" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/test/test.js new file mode 100644 index 000000000000..1cfc86faa639 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlogspace/test/test.js @@ -0,0 +1,108 @@ +/** +* @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 isEqualDataType = require( '@stdlib/ndarray/base/assert/is-equal-data-type' ); +var Float64Array = require( '@stdlib/array/float64' ); +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 dlogspace = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlogspace, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function fills a one-dimensional ndarray (endpoint=true)', function test( t ) { + var endpoint; + var actual; + var strt; + var base; + var stp; + var x; + + x = ndarray( 'float64', new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); + base = scalar2ndarray( 10.0, { + 'dtype': 'float64' + }); + strt = scalar2ndarray( 0.0, { + 'dtype': 'float64' + }); + stp = scalar2ndarray( 3.0, { + 'dtype': 'float64' + }); + endpoint = scalar2ndarray( true, { + 'dtype': 'bool' + }); + + actual = dlogspace( [ x, base, strt, stp, endpoint ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), 'float64' ), true, 'returns expected value' ); + t.deepEqual( getData( actual ), new Float64Array( [ 1.0, 10.0, 100.0, 1000.0 ] ), 'returns expected value' ); + t.deepEqual( getShape( actual ), [ 4 ], '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 actual; + var strt; + var base; + var stp; + var x; + + x = ndarray( 'float64', new Float64Array( [ 0.0, 0.0 ] ), [ 2 ], [ 1 ], 0, 'row-major' ); + base = scalar2ndarray( 2.0, { + 'dtype': 'float64' + }); + strt = scalar2ndarray( 1.0, { + 'dtype': 'float64' + }); + stp = scalar2ndarray( 3.0, { + 'dtype': 'float64' + }); + endpoint = scalar2ndarray( false, { + 'dtype': 'bool' + }); + + actual = dlogspace( [ x, base, strt, stp, endpoint ] ); + t.strictEqual( actual, x, 'returns expected value' ); + t.strictEqual( isEqualDataType( getDType( actual ), 'float64' ), true, 'returns expected value' ); + t.deepEqual( getData( actual ), new Float64Array( [ 2.0, 4.0 ] ), '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(); +});