From 7f7f9f3ab44c81c01d58f07703c63f35d0710ea0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 14 Mar 2026 01:25:28 +0500 Subject: [PATCH 01/12] feat: add blas/ext/base/dvander --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 333 +++++++++++++ .../ext/base/dvander/benchmark/benchmark.js | 109 +++++ .../dvander/benchmark/benchmark.native.js | 114 +++++ .../dvander/benchmark/benchmark.ndarray.js | 109 +++++ .../benchmark/benchmark.ndarray.native.js | 114 +++++ .../ext/base/dvander/benchmark/c/Makefile | 146 ++++++ .../dvander/benchmark/c/benchmark.length.c | 204 ++++++++ .../@stdlib/blas/ext/base/dvander/binding.gyp | 170 +++++++ .../blas/ext/base/dvander/docs/repl.txt | 107 +++++ .../ext/base/dvander/docs/types/index.d.ts | 116 +++++ .../blas/ext/base/dvander/docs/types/test.ts | 342 ++++++++++++++ .../blas/ext/base/dvander/examples/c/Makefile | 146 ++++++ .../ext/base/dvander/examples/c/example.c | 43 ++ .../blas/ext/base/dvander/examples/index.js | 40 ++ .../blas/ext/base/dvander/include.gypi | 53 +++ .../include/stdlib/blas/ext/base/dvander.h | 48 ++ .../blas/ext/base/dvander/lib/dvander.js | 112 +++++ .../ext/base/dvander/lib/dvander.native.js | 59 +++ .../blas/ext/base/dvander/lib/index.js | 70 +++ .../@stdlib/blas/ext/base/dvander/lib/main.js | 35 ++ .../blas/ext/base/dvander/lib/native.js | 35 ++ .../blas/ext/base/dvander/lib/ndarray.js | 144 ++++++ .../ext/base/dvander/lib/ndarray.native.js | 62 +++ .../blas/ext/base/dvander/manifest.json | 85 ++++ .../blas/ext/base/dvander/package.json | 74 +++ .../blas/ext/base/dvander/src/Makefile | 70 +++ .../@stdlib/blas/ext/base/dvander/src/addon.c | 72 +++ .../@stdlib/blas/ext/base/dvander/src/main.c | 156 +++++++ .../ext/base/dvander/test/test.dvander.js | 437 ++++++++++++++++++ .../base/dvander/test/test.dvander.native.js | 354 ++++++++++++++ .../blas/ext/base/dvander/test/test.js | 82 ++++ .../ext/base/dvander/test/test.ndarray.js | 378 +++++++++++++++ .../base/dvander/test/test.ndarray.native.js | 385 +++++++++++++++ 33 files changed, 4804 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/include/stdlib/blas/ext/base/dvander.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md new file mode 100644 index 000000000000..125ea9f26a5d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -0,0 +1,333 @@ + + +# dvander + +> Generate a double-precision floating-point Vandermonde matrix. + +
+ +## Usage + +```javascript +var dvander = require( '@stdlib/blas/ext/base/dvander' ); +``` + +#### dvander( order, M, N, mode, x, strideX, out, LDO ) + +Generates a double-precision floating-point Vandermonde matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var out = new Float64Array( 9 ); + +dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in the matrix `out`. +- **N**: number of columns in the matrix `out`. +- **mode**: specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`). +- **x**: input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: stride length for `x`. +- **out**: output [`Float64Array`][@stdlib/array/float64]. +- **LDO**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`). + +The stride parameter determines which elements in the input vector are accessed at runtime. For example, to use every other element in `x`, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); +var out = new Float64Array( 9 ); + +dvander( 'row-major', 3, 3, -1, x, 2, out, 3 ); +// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array... +var x0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + +// Create an offset view... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = new Float64Array( 9 ); + +dvander( 'row-major', 3, 3, -1, x1, 1, out, 3 ); +// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +``` + + + +#### dvander.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) + + + +Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var out = new Float64Array( 9 ); + +dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **strideOut1**: stride of the first dimension of `out`. +- **strideOut2**: stride of the second dimension of `out`. +- **offsetOut**: starting index for `out`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); +var out = new Float64Array( 9 ); + +dvander.ndarray( 3, 3, -1, x, 1, 1, out, 3, 1, 0 ); +// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +``` + +
+ + + +
+ +## Notes + +- If `M` or `N` is equal to `0`, both functions return `out` unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dvander = require( '@stdlib/blas/ext/base/dvander' ); + +var opts = { + 'dtype': 'float64' +}; + +var M = 3; +var N = 4; + +var x = discreteUniform( M, 0, 10, opts ); +var out = new Float64Array( M*N ); + +dvander( 'row-major', M, N, -1, x, 1, out, N ); +console.log( out ); + +out = new Float64Array( M*N ); +dvander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/dvander.h" +``` + +#### stdlib_strided_dvander( order, M, N, mode, \*X, strideX, \*Out, LDO ) + +Generates a double-precision floating-point Vandermonde matrix. + +```c +#include "stdlib/blas/base/shared.h" + +const double x[ 3 ] = { 1.0, 2.0, 3.0 }; +double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + +stdlib_strided_dvander( CblasRowMajor, 3, 3, -1.0, x, 1, Out, 3 ); +``` + +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. +- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). +- **X**: `[in] double*` input vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Out**: `[out] double*` output matrix. +- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`). + +```c +void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); +``` + + + +#### stdlib_strided_dvander_ndarray( M, N, mode, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) + + + +Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" + +const double x[ 3 ] = { 1.0, 2.0, 3.0 }; +double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + +stdlib_strided_dvander_ndarray( 3, 3, -1.0, x, 1, 0, Out, 3, 1, 0 ); +``` + +The function accepts the following arguments: + +- **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. +- **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. +- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). +- **X**: `[in] double*` input vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Out**: `[out] double*` output matrix. +- **strideOut1**: `[in] CBLAS_INT` stride of the first dimension of `Out`. +- **strideOut2**: `[in] CBLAS_INT` stride of the second dimension of `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. + +```c +void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/dvander.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define the input vector: + const double x[ 3 ] = { 1.0, 2.0, 3.0 }; + + // Define a 3x3 output matrix stored in row-major order: + double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Specify the number of rows and columns: + const int M = 3; + const int N = 3; + + // Perform operation: + stdlib_strided_dvander( CblasRowMajor, M, N, -1.0, x, 1, Out, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "Out[%i,%i] = %lf\n", i, j, Out[ (i*N)+j ] ); + } + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js new file mode 100644 index 000000000000..e3333b140daa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js @@ -0,0 +1,109 @@ +/** +* @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/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dvander = require( './../lib/dvander.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var out; + var x; + + x = uniform( N, -10.0, 10.0, options ); + out = zeros( N*N, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dvander( 'row-major', N, N, -1, x, 1, out, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s:size=%d', pkg, len*len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js new file mode 100644 index 000000000000..8a8e4c80ce42 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js @@ -0,0 +1,114 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dvander = tryRequire( resolve( __dirname, './../lib/dvander.native.js' ) ); +var opts = { + 'skip': ( dvander instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var out; + var x; + + x = uniform( N, -10.0, 10.0, options ); + out = zeros( N*N, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dvander( 'row-major', N, N, -1, x, 1, out, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s::native:size=%d', pkg, len*len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..27cdf0d263dc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js @@ -0,0 +1,109 @@ +/** +* @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/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dvander = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var out; + var x; + + x = uniform( N, -10.0, 10.0, options ); + out = zeros( N*N, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dvander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:size=%d', pkg, len*len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..7601c4435b2f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,114 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var dvander = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dvander instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array dimension size +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var out; + var x; + + x = uniform( N, -10.0, 10.0, options ); + out = zeros( N*N, 'float64' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dvander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + 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 = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s::native:ndarray:size=%d', pkg, len*len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..8f34297c0b24 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -0,0 +1,204 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/dvander.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "dvander" +#define ITERATIONS 1000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + double *out; + double *x; + double t; + int i; + + x = (double *)malloc( len * sizeof( double ) ); + out = (double *)malloc( len * len * sizeof( double ) ); + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double() * 20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_dvander( CblasRowMajor, len, len, -1.0, x, 1, out, len ); + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( x ); + free( out ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + double *out; + double *x; + double t; + int i; + + x = (double *)malloc( len * sizeof( double ) ); + out = (double *)malloc( len * len * sizeof( double ) ); + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_double() * 20.0 ) - 10.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_dvander_ndarray( len, len, -1.0, x, 1, 0, out, len, 1, 0 ); + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( out[ 0 ] != out[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( x ); + free( out ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = (int)sqrt( pow( 10, i ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::native::%s:size=%d\n", NAME, len*len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = (int)sqrt( pow( 10, i ) ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::native::%s:ndarray:size=%d\n", NAME, len*len ); + elapsed = benchmark2( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/dvander/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt new file mode 100644 index 000000000000..76d8859cd9f7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt @@ -0,0 +1,107 @@ + +{{alias}}( order, M, N, mode, x, strideX, out, LDO ) + Generates a double-precision floating-point Vandermonde matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `M` or `N` is equal to `0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. + + M: integer + Number of rows in `out`. + + N: integer + Number of columns in `out`. + + mode: number + Specifies whether columns should contain powers that are increasing + (`1`) or decreasing (`-1`). + + x: Float64Array + Input vector. + + strideX: integer + Stride length for `x`. + + out: Float64Array + Output matrix. + + LDO: integer + Stride of the first dimension of `out` (a.k.a., leading dimension of + the matrix `out`). + + Returns + ------- + out: Float64Array + Output matrix. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}( 'row-major', 3, 3, -1, x, 1, out, 3 ) + [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] + + +{{alias}}.ndarray( M, N, mode, x, strideX, offsetX, out, so1, so2, oo ) + Generates a double-precision floating-point Vandermonde matrix using + alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + M: integer + Number of rows in `out`. + + N: integer + Number of columns in `out`. + + mode: number + Specifies whether columns should contain powers that are increasing + (`1`) or decreasing (`-1`). + + x: Float64Array + Input vector. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + out: Float64Array + Output matrix. + + so1: integer + Stride of the first dimension of `out`. + + so2: integer + Stride of the second dimension of `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: Float64Array + Output matrix. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ) + [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts new file mode 100644 index 000000000000..06ebd14cf0f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts @@ -0,0 +1,116 @@ +/* +* @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 { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dvander`. +*/ +interface Routine { + /** + * Generates a double-precision floating-point Vandermonde matrix. + * + * @param order - storage layout + * @param M - number of rows in the matrix `Out` + * @param N - number of columns in the matrix `Out` + * @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) + * @param x - input vector + * @param strideX - stride length for `x` + * @param out - output matrix + * @param LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + * var out = new Float64Array( 9 ); + * + * dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] + */ + ( order: Layout, M: number, N: number, mode: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array; + + /** + * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. + * + * @param M - number of rows in the matrix `Out` + * @param N - number of columns in the matrix `Out` + * @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) + * @param x - input vector + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @param out - output matrix + * @param strideOut1 - stride of the first dimension of `Out` + * @param strideOut2 - stride of the second dimension of `Out` + * @param offsetOut - starting index for `Out` + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + * var out = new Float64Array( 9 ); + * + * dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] + */ + ndarray( M: number, N: number, mode: number, x: Float64Array, strideX: number, offsetX: number, out: Float64Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float64Array; +} + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @param order - storage layout +* @param M - number of rows in the matrix `Out` +* @param N - number of columns in the matrix `Out` +* @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) +* @param x - input vector +* @param strideX - stride length for `x` +* @param out - output matrix +* @param LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) +* @returns output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +declare var dvander: Routine; + + +// EXPORTS // + +export = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts new file mode 100644 index 000000000000..c04785f93e40 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts @@ -0,0 +1,342 @@ +/* +* @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. +*/ + +import dvander = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, 10, -1, x, 1, out, 10 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 10, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( true, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( false, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( null, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( undefined, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( [], 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( {}, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( ( x: number ): number => x, 10, 10, -1, x, 1, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', '10', 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', true, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', false, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', null, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', undefined, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', [], 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', {}, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', ( x: number ): number => x, 10, -1, x, 1, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, '10', -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, true, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, false, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, null, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, undefined, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, [], -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, {}, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, ( x: number ): number => x, -1, x, 1, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, 10, '10', x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, true, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, false, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, null, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, undefined, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, [], x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, {}, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, ( x: number ): number => x, x, 1, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, 10, -1, 10, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, '10', 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, true, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, false, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, null, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, undefined, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, [ '1' ], 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, {}, 1, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, ( x: number ): number => x, 1, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, 10, -1, x, '10', out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, true, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, false, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, null, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, undefined, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, [], out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, {}, out, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, ( x: number ): number => x, out, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dvander( 'row-major', 10, 10, -1, x, 1, 10, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, '10', 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, true, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, false, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, null, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, undefined, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, [ '1' ], 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, {}, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, ( x: number ): number => x, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander( 'row-major', 10, 10, -1, x, 1, out, '10' ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, true ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, false ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, null ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, undefined ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, [] ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, {} ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander(); // $ExpectError + dvander( 'row-major' ); // $ExpectError + dvander( 'row-major', 10 ); // $ExpectError + dvander( 'row-major', 10, 10 ); // $ExpectError + dvander( 'row-major', 10, 10, -1 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1 ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out ); // $ExpectError + dvander( 'row-major', 10, 10, -1, x, 1, out, 10, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( '10', 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( true, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( false, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( null, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( undefined, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( [], 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( {}, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( ( x: number ): number => x, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, '10', -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, true, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, false, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, null, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, undefined, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, [], -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, {}, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, ( x: number ): number => x, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, ( x: number ): number => x, x, 1, 0, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Float64Array... +{ + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, true, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, false, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, null, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, ( x: number ): number => x, 1, 0, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, '10', 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, true, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, false, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, null, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, [], 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, {}, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, ( x: number ): number => x, 0, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, 1, '10', out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, true, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, false, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, null, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, [], out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, {}, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, ( x: number ): number => x, out, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dvander.ndarray( 10, 10, -1, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, 1, 0, out, '10', 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, true, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, false, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, null, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, [], 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, {}, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, '10', 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, true, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, false, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, null, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, [], 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, {}, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, '10' ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, true ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, false ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, null ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, undefined ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, [] ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, {} ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 100 ); + + dvander.ndarray(); // $ExpectError + dvander.ndarray( 10 ); // $ExpectError + dvander.ndarray( 10, 10 ); // $ExpectError + dvander.ndarray( 10, 10, -1 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1 ); // $ExpectError + dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c new file mode 100644 index 000000000000..ca907c81ba48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/dvander.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 output matrix stored in row-major order: + double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Define the input vector: + const double x[ 3 ] = { 1.0, 2.0, 3.0 }; + + // Specify the number of rows and columns: + const int M = 3; + const int N = 3; + + // Generate the Vandermonde matrix: + stdlib_strided_dvander( CblasRowMajor, M, N, -1.0, x, 1, Out, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + printf( "Out[%i,%i] = %lf\n", i, j, Out[ (i*N)+j ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js new file mode 100644 index 000000000000..24a7c1675dee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js @@ -0,0 +1,40 @@ +/** +* @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/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dvander = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var M = 3; +var N = 4; + +var x = discreteUniform( M, 0, 10, opts ); +var out = new Float64Array( M*N ); + +dvander( 'row-major', M, N, -1, x, 1, out, N ); +console.log( out ); + +out = new Float64Array( M*N ); +dvander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dvander/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/include.gypi @@ -0,0 +1,53 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +function dvander( order, M, N, mode, x, strideX, out, LDO ) { + var iscm; + var vala; + var sa1; + var sa2; + var ox; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + + // Check if we can early return... + if ( M === 0 || N === 0 ) { + return out; + } + + iscm = isColumnMajor( order ); + if ( iscm ) { + vala = M; + } else { + vala = N; + } + + if ( LDO < vala ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', vala, LDO ) ); + } + + ox = stride2offset( M, strideX ); + if ( iscm ) { + sa1 = 1; + sa2 = LDO; + } else { // order === 'row-major' + sa1 = LDO; + sa2 = 1; + } + return ndarray( M, N, mode, x, strideX, ox, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js new file mode 100644 index 000000000000..36273f42df0a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -0,0 +1,59 @@ +/** +* @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 resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of rows in the matrix `Out` +* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) +* @param {Float64Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {Float64Array} out - output matrix +* @param {PositiveInteger} LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +function dvander( order, M, N, mode, x, strideX, out, LDO ) { + addon( resolve( order ), M, N, mode, x, strideX, out, LDO ); + return out; +} + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js new file mode 100644 index 000000000000..3abe655b8b56 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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'; + +/** +* Generate a double-precision floating-point Vandermonde matrix. +* +* @module @stdlib/blas/ext/base/dvander +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dvander = require( '@stdlib/blas/ext/base/dvander' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dvander = require( '@stdlib/blas/ext/base/dvander' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.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 dvander; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dvander = main; +} else { + dvander = tmp; +} + + +// EXPORTS // + +module.exports = dvander; + +// exports: { "ndarray": "dvander.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/main.js new file mode 100644 index 000000000000..5c5d983fa06b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dvander = require( './dvander.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dvander, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/native.js new file mode 100644 index 000000000000..dd4181279f0b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/native.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dvander = require( './dvander.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( dvander, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js new file mode 100644 index 000000000000..31d7aa0fbf12 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -0,0 +1,144 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; + + +// MAIN // + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @param {NonNegativeInteger} M - number of rows in the matrix `Out` +* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) +* @param {Float64Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} out - output matrix +* @param {integer} strideOut1 - stride length for the first dimension of `Out` +* @param {integer} strideOut2 - stride length for the second dimension of `Out` +* @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +function dvander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + var do0; + var do1; + var rm; + var S0; + var S1; + var sx; + var io; + var ix; + var i0; + var i1; + + if ( M === 0 || N === 0 ) { + return out; + } + + // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... + rm = isRowMajor( [ strideOut1, strideOut2 ] ); + + // Extract loop variables for loop interchange... + if ( rm ) { + S0 = N; + S1 = M; + do0 = strideOut2; // offset increment for innermost loop + do1 = strideOut1 - ( S0*strideOut2 ); // offset increment for outermost loop + } else { // order === 'column-major' + S0 = M; + S1 = N; + do0 = strideOut1; // offset increment for innermost loop + do1 = strideOut2 - ( S0*strideOut1 ); // offset increment for outermost loop + } + sx = strideX; + io = offsetOut; + + // For a Vandermonde matrix, each row `i` contains powers of `x[i]`: + if ( rm ) { + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + if ( mode > 0 ) { + // Increasing: x^0, x^1, ..., x^(N-1) + out[ io ] = 1.0; + io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + out[ io ] = out[ io - do0 ] * x[ ix ]; + io += do0; + } + } else { + // Decreasing: x^(N-1), x^(N-2), ..., x^0 + out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; + for ( i0 = S0 - 2; i0 >= 0; i0-- ) { + out[ io + ( i0*do0 ) ] = out[ io + ( (i0+1)*do0 ) ] * x[ ix ]; + } + io += S0 * do0; + } + ix += sx; + io += do1; + } + } else if ( mode > 0 ) { + // Increasing: column j contains x^j + dfill( S0, 1.0, out, do0, io ); + io += ( S0 * do0 ) + do1; + for ( i1 = 1; i1 < S1; i1++ ) { + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + out[ io ] = out[ io - strideOut2 ] * x[ ix ]; + ix += sx; + io += do0; + } + io += do1; + } + } else { + // Decreasing: column 0 contains x^(N-1), last column all ones + dfill( S0, 1.0, out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + for ( i1 = S1 - 2; i1 >= 0; i1-- ) { + io = offsetOut + ( i1 * strideOut2 ); + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + out[ io ] = out[ io + strideOut2 ] * x[ ix ]; + ix += sx; + io += do0; + } + } + } + return out; +} + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js new file mode 100644 index 000000000000..2eb15905db3c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @param {NonNegativeInteger} M - number of rows in the matrix `Out` +* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) +* @param {Float64Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} out - output matrix +* @param {integer} strideOut1 - stride length for the first dimension of `Out` +* @param {integer} strideOut2 - stride length for the second dimension of `Out` +* @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +function dvander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + addon.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); + return out; +} + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json new file mode 100644 index 000000000000..2a3544a8a583 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json @@ -0,0 +1,85 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/dfill", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/dfill", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/dfill", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json b/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json new file mode 100644 index 000000000000..e0c9d1a30afb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/dvander", + "version": "0.0.0", + "description": "Generate a double-precision floating-point Vandermonde matrix.", + "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", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "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", + "dvander", + "vandermonde", + "matrix", + "linear", + "algebra", + "array", + "ndarray", + "float64", + "float", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c new file mode 100644 index 000000000000..241f1288034c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c @@ -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. +*/ + +#include "stdlib/blas/ext/base/dvander.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); + STDLIB_NAPI_ARGV_INT64( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); + API_SUFFIX(stdlib_strided_dvander)( order, M, N, mode, X, strideX, Out, LDO ); + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut1, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut2, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 9 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); + API_SUFFIX(stdlib_strided_dvander_ndarray)( M, N, mode, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c new file mode 100644 index 000000000000..7fbdff6b624a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -0,0 +1,156 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/dvander.h" +#include "stdlib/blas/ext/base/dfill.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @param order storage layout +* @param M number of rows in the matrix `Out` +* @param N number of columns in the matrix `Out` +* @param mode specifies whether powers are increasing (1) or decreasing (-1) +* @param X input vector +* @param strideX stride length for `X` +* @param Out output matrix +* @param LDO leading dimension of `Out` +*/ +void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + + ox = stdlib_strided_stride2offset( M, strideX ); + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDO; + } else { // order == CblasRowMajor + sa1 = LDO; + sa2 = 1; + } + API_SUFFIX(stdlib_strided_dvander_ndarray)( M, N, mode, X, strideX, ox, Out, sa1, sa2, 0 ); +} + +/** +* Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. +* +* @param M number of rows in the matrix `Out` +* @param N number of columns in the matrix `Out` +* @param mode specifies whether powers are increasing (1) or decreasing (-1) +* @param X input vector +* @param strideX stride length for `X` +* @param offsetX starting index for `X` +* @param Out output matrix +* @param strideOut1 stride length for the first dimension of `Out` +* @param strideOut2 stride length for the second dimension of `Out` +* @param offsetOut starting index for `Out` +*/ +void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { + CBLAS_INT sa[ 2 ]; + CBLAS_INT do0; + CBLAS_INT do1; + CBLAS_INT rm; + CBLAS_INT S0; + CBLAS_INT S1; + CBLAS_INT sx; + CBLAS_INT io; + CBLAS_INT ix; + CBLAS_INT i0; + CBLAS_INT i1; + + if ( M == 0 || N == 0 ) { + return; + } + + // Determine whether the matrix is row-major... + sa[ 0 ] = strideOut1; + sa[ 1 ] = strideOut2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + rm = 1; + } else { + rm = 0; + } + + // Extract loop variables for loop interchange... + if ( rm ) { + S0 = N; + S1 = M; + do0 = strideOut2; + do1 = strideOut1 - ( S0 * strideOut2 ); + } else { + S0 = M; + S1 = N; + do0 = strideOut1; + do1 = strideOut2 - ( S0 * strideOut1 ); + } + sx = strideX; + io = offsetOut; + + if ( rm ) { + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + if ( mode > 0 ) { + // Increasing: x^0, x^1, ..., x^(N-1) + Out[ io ] = 1.0; + io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + Out[ io ] = Out[ io - do0 ] * X[ ix ]; + io += do0; + } + } else { + // Decreasing: x^(N-1), x^(N-2), ..., x^0 + Out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; + for ( i0 = S0 - 2; i0 >= 0; i0-- ) { + Out[ io + ( i0*do0 ) ] = Out[ io + ( (i0+1)*do0 ) ] * X[ ix ]; + } + io += S0 * do0; + } + ix += sx; + io += do1; + } + } else if ( mode > 0 ) { + // Increasing: column j contains x^j + API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, io ); + io += ( S0 * do0 ) + do1; + for ( i1 = 1; i1 < S1; i1++ ) { + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + Out[ io ] = Out[ io - strideOut2 ] * X[ ix ]; + ix += sx; + io += do0; + } + io += do1; + } + } else { + // Decreasing: column 0 contains x^(N-1), last column all ones + API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + for ( i1 = S1 - 2; i1 >= 0; i1-- ) { + io = offsetOut + ( i1 * strideOut2 ); + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + Out[ io ] = Out[ io + strideOut2 ] * X[ ix ]; + ix += sx; + io += do0; + } + } + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js new file mode 100644 index 000000000000..c31a755fd6ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js @@ -0,0 +1,437 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dvander = require( './../lib/dvander.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dvander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dvander.length, 8, 'has expected arity' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var out; + var x; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( value, 2, 2, -1, x, 1, out, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + t.throws( function badValue() { + dvander( 'row-major', -1, 2, -1, x, 1, out, 2 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + t.throws( function badValue() { + dvander( 'row-major', 2, -1, -1, x, 1, out, 2 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + t.throws( function badValue() { + dvander( 'row-major', 2, 2, -1, x, 0, out, 2 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + t.throws( function badValue() { + dvander( 'row-major', 2, 3, -1, x, 1, out, 2 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid eighth argument (column-major)', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + t.throws( function badValue() { + dvander( 'column-major', 3, 2, -1, x, 1, out, 2 ); + }, RangeError, 'throws an error' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 4.0, + 2.0, + 1.0, + 9.0, + 3.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 9.0, + 1.0, + 2.0, + 3.0, + 1.0, + 1.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 1.0, + 4.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + v = dvander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` equal to `0`, the function early returns', function test( t ) { + var out; + var x; + + x = new Float64Array( [] ); + out = new Float64Array( [] ); + + dvander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` equal to `0`, the function early returns', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( [] ); + + dvander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (row-major)', function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (row-major)', function test( t ) { + var expected; + var out; + var x; + + // Negative stride: starts from last and goes backward + x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (column-major)', function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (column-major)', function test( t ) { + var expected; + var out; + var x; + + // Negative stride: starts from last and goes backward + x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `LDO` larger than the matrix dimension (row-major)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 10 ); + + // 2x3 row-major with LDO=5 (padding of 2 per row) + dvander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `LDO` larger than the matrix dimension (column-major)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 12 ); + + // 2x3 column-major with LDO=4 (padding of 2 per column) + dvander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, row-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + + // 3x2 matrix, decreasing: + expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + + // 2x4 matrix, increasing: + expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js new file mode 100644 index 000000000000..bc07a608095e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js @@ -0,0 +1,354 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dvander = tryRequire( resolve( __dirname, './../lib/dvander.native.js' ) ); +var opts = { + 'skip': ( dvander instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dvander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( dvander.length, 8, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 4.0, + 2.0, + 1.0, + 9.0, + 3.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 9.0, + 1.0, + 2.0, + 3.0, + 1.0, + 1.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 1.0, + 4.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array', opts, function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + v = dvander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` equal to `0`, the function early returns', opts, function test( t ) { + var out; + var x; + + x = new Float64Array( [] ); + out = new Float64Array( [] ); + + dvander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` equal to `0`, the function early returns', opts, function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( [] ); + + dvander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (row-major)', opts, function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (row-major)', opts, function test( t ) { + var expected; + var out; + var x; + + // Negative stride: starts from last and goes backward + x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + // Negative stride: starts from last and goes backward + x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `LDO` larger than the matrix dimension (row-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 10 ); + + // 2x3 row-major with LDO=5 (padding of 2 per row) + dvander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `LDO` larger than the matrix dimension (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 12 ); + + // 2x3 column-major with LDO=4 (padding of 2 per column) + dvander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, row-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + + // 3x2 matrix, decreasing: + expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + + // 2x4 matrix, increasing: + expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.js new file mode 100644 index 000000000000..5b704b284a78 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dvander = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dvander, '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 dvander.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 dvander = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dvander, 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 dvander; + var main; + + main = require( './../lib/main.js' ); + + dvander = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dvander, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js new file mode 100644 index 000000000000..7fad83408fe8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js @@ -0,0 +1,378 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dvander = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dvander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dvander.length, 10, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 4.0, + 2.0, + 1.0, + 9.0, + 3.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + // Column-major: strideOut1=1, strideOut2=3 + dvander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 9.0, + 1.0, + 2.0, + 3.0, + 1.0, + 1.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + // Column-major: strideOut1=1, strideOut2=3 + dvander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 1.0, + 4.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + v = dvander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` equal to `0`, the function early returns', function test( t ) { + var out; + var x; + + x = new Float64Array( [] ); + out = new Float64Array( [] ); + + dvander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` equal to `0`, the function early returns', function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( [] ); + + dvander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 999.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + + expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an output offset', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + + // Starting at offset 2: + expected = new Float64Array( [ 0.0, 0.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output strides with padding (row-major)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 10 ); + + // 2x3 row-major with strideOut1=5 (padding of 2 per row) + dvander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output strides with padding (column-major)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 12 ); + + // 2x3 column-major with strideOut2=4 (padding of 2 per column) + dvander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, row-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + // 3x2 matrix, decreasing: + expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + + // 2x4 matrix, increasing: + expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, column-major, decreasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + // 3x2 column-major: strideOut1=1, strideOut2=3 + dvander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, column-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + // 2x4 column-major: strideOut1=1, strideOut2=2 + dvander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 2.0, 3.0, 4.0, 9.0, 8.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js new file mode 100644 index 000000000000..389a8fa624ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js @@ -0,0 +1,385 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var dvander = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( dvander instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dvander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( dvander.length, 10, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 4.0, + 2.0, + 1.0, + 9.0, + 3.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 9.0, + 1.0, + 2.0, + 3.0, + 1.0, + 1.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 9 ); + + dvander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 1.0, + 4.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array', opts, function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 4 ); + + v = dvander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` equal to `0`, the function early returns', opts, function test( t ) { + var out; + var x; + + x = new Float64Array( [] ); + out = new Float64Array( [] ); + + dvander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` equal to `0`, the function early returns', opts, function test( t ) { + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( [] ); + + dvander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + + t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 999.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + + expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an output offset', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + + // Starting at offset 2: + expected = new Float64Array( [ 0.0, 0.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output strides with padding (row-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 10 ); + + // 2x3 row-major with strideOut1=5 (padding of 2 per row) + dvander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output strides with padding (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 12 ); + + // 2x3 column-major with strideOut2=4 (padding of 2 per column) + dvander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + + expected = new Float64Array([ + 1.0, + 4.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, row-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + dvander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + // 3x2 matrix, decreasing: + expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + dvander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + + // 2x4 matrix, increasing: + expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, column-major, decreasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float64Array( 6 ); + + // 3x2 column-major: strideOut1=1, strideOut2=3 + dvander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, column-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 2.0, 3.0 ] ); + out = new Float64Array( 8 ); + + // 2x4 column-major: strideOut1=1, strideOut2=2 + dvander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 2.0, 3.0, 4.0, 9.0, 8.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From fc7f92dd4b35e4eab1ad50ec5a4582f6cc17fbcf Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 14 Mar 2026 23:41:27 +0500 Subject: [PATCH 02/12] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 66 ++-- .../ext/base/dvander/benchmark/benchmark.js | 2 +- .../dvander/benchmark/benchmark.native.js | 2 +- .../dvander/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../dvander/benchmark/c/benchmark.length.c | 4 +- .../blas/ext/base/dvander/docs/repl.txt | 39 +- .../ext/base/dvander/docs/types/index.d.ts | 40 +-- .../blas/ext/base/dvander/docs/types/test.ts | 334 +++++++++--------- .../ext/base/dvander/examples/c/example.c | 6 +- .../blas/ext/base/dvander/examples/index.js | 14 +- .../include/stdlib/blas/ext/base/dvander.h | 4 +- .../blas/ext/base/dvander/lib/dvander.js | 59 +--- .../ext/base/dvander/lib/dvander.native.js | 16 +- .../blas/ext/base/dvander/lib/index.js | 4 +- .../blas/ext/base/dvander/lib/ndarray.js | 14 +- .../ext/base/dvander/lib/ndarray.native.js | 14 +- .../@stdlib/blas/ext/base/dvander/src/addon.c | 16 +- .../@stdlib/blas/ext/base/dvander/src/main.c | 23 +- .../ext/base/dvander/test/test.dvander.js | 122 +------ .../base/dvander/test/test.dvander.native.js | 30 +- .../ext/base/dvander/test/test.ndarray.js | 34 +- .../base/dvander/test/test.ndarray.native.js | 34 +- 23 files changed, 368 insertions(+), 513 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md index 125ea9f26a5d..eedd179a1f17 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -30,7 +30,7 @@ limitations under the License. var dvander = require( '@stdlib/blas/ext/base/dvander' ); ``` -#### dvander( order, M, N, mode, x, strideX, out, LDO ) +#### dvander( order, mode, M, N, x, strideX, out, LDO ) Generates a double-precision floating-point Vandermonde matrix. @@ -40,22 +40,22 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var out = new Float64Array( 9 ); -dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ``` The function has the following parameters: - **order**: storage layout. +- **mode**: specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`). - **M**: number of rows in the matrix `out`. - **N**: number of columns in the matrix `out`. -- **mode**: specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`). - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: stride length for `x`. - **out**: output [`Float64Array`][@stdlib/array/float64]. -- **LDO**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`). +- **LDO**: stride length for the leading dimension of `out`. -The stride parameter determines which elements in the input vector are accessed at runtime. For example, to use every other element in `x`, +The stride parameter determines which elements in the input array are accessed at runtime. For example, to use every other element in `x`, ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -63,7 +63,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); var out = new Float64Array( 9 ); -dvander( 'row-major', 3, 3, -1, x, 2, out, 3 ); +dvander( 'row-major', -1, 3, 3, x, 2, out, 3 ); // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ``` @@ -82,13 +82,13 @@ var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd var out = new Float64Array( 9 ); -dvander( 'row-major', 3, 3, -1, x1, 1, out, 3 ); +dvander( 'row-major', -1, 3, 3, x1, 1, out, 3 ); // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ``` -#### dvander.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) +#### dvander.ndarray( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) @@ -100,7 +100,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); var out = new Float64Array( 9 ); -dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +dvander.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ``` @@ -119,7 +119,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); var out = new Float64Array( 9 ); -dvander.ndarray( 3, 3, -1, x, 1, 1, out, 3, 1, 0 ); +dvander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 ); // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ``` @@ -148,21 +148,15 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var dvander = require( '@stdlib/blas/ext/base/dvander' ); -var opts = { - 'dtype': 'float64' -}; - var M = 3; var N = 4; -var x = discreteUniform( M, 0, 10, opts ); +var x = discreteUniform( M, 0, 10, { + 'dtype': 'float64' +}); var out = new Float64Array( M*N ); -dvander( 'row-major', M, N, -1, x, 1, out, N ); -console.log( out ); - -out = new Float64Array( M*N ); -dvander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +dvander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); ``` @@ -196,7 +190,7 @@ console.log( out ); #include "stdlib/blas/ext/base/dvander.h" ``` -#### stdlib_strided_dvander( order, M, N, mode, \*X, strideX, \*Out, LDO ) +#### stdlib_strided_dvander( order, mode, M, N, \*X, strideX, \*Out, LDO ) Generates a double-precision floating-point Vandermonde matrix. @@ -206,27 +200,27 @@ Generates a double-precision floating-point Vandermonde matrix. const double x[ 3 ] = { 1.0, 2.0, 3.0 }; double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; -stdlib_strided_dvander( CblasRowMajor, 3, 3, -1.0, x, 1, Out, 3 ); +stdlib_strided_dvander( CblasRowMajor, -1.0, 3, 3, x, 1, Out, 3 ); ``` The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. +- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). - **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. - **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. -- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **X**: `[in] double*` input vector. +- **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **Out**: `[out] double*` output matrix. -- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`). +- **Out**: `[out] double*` output array. +- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `out`. ```c -void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); +void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); ``` -#### stdlib_strided_dvander_ndarray( M, N, mode, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) +#### stdlib_strided_dvander_ndarray( mode, M, N, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) @@ -238,24 +232,24 @@ Generates a double-precision floating-point Vandermonde matrix using alternative const double x[ 3 ] = { 1.0, 2.0, 3.0 }; double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; -stdlib_strided_dvander_ndarray( 3, 3, -1.0, x, 1, 0, Out, 3, 1, 0 ); +stdlib_strided_dvander_ndarray( -1.0, 3, 3, x, 1, 0, Out, 3, 1, 0 ); ``` The function accepts the following arguments: +- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). - **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. - **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. -- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **X**: `[in] double*` input vector. +- **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **Out**: `[out] double*` output matrix. +- **Out**: `[out] double*` output array. - **strideOut1**: `[in] CBLAS_INT` stride of the first dimension of `Out`. - **strideOut2**: `[in] CBLAS_INT` stride of the second dimension of `Out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. ```c -void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); ``` @@ -282,10 +276,10 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_ #include int main( void ) { - // Define the input vector: + // Define the input array: const double x[ 3 ] = { 1.0, 2.0, 3.0 }; - // Define a 3x3 output matrix stored in row-major order: + // Define a 3x3 output array stored in row-major order: double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Specify the number of rows and columns: @@ -293,7 +287,7 @@ int main( void ) { const int N = 3; // Perform operation: - stdlib_strided_dvander( CblasRowMajor, M, N, -1.0, x, 1, Out, N ); + stdlib_strided_dvander( CblasRowMajor, -1.0, M, N, x, 1, Out, N ); // Print the result: for ( int i = 0; i < M; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js index e3333b140daa..1b6e6e555353 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js @@ -67,7 +67,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( 'row-major', N, N, -1, x, 1, out, N ); + z = dvander( 'row-major', -1, N, N, x, 1, out, N ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js index 8a8e4c80ce42..ccba26f3627f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js @@ -72,7 +72,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( 'row-major', N, N, -1, x, 1, out, N ); + z = dvander( 'row-major', -1, N, N, x, 1, out, N ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js index 27cdf0d263dc..f6246188b76c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js @@ -67,7 +67,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + z = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js index 7601c4435b2f..0d026d96ccd7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js @@ -72,7 +72,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + z = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c index 8f34297c0b24..edb0a1a71472 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -110,7 +110,7 @@ static double benchmark1( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - stdlib_strided_dvander( CblasRowMajor, len, len, -1.0, x, 1, out, len ); + stdlib_strided_dvander( CblasRowMajor, -1.0, len, len, x, 1, out, len ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -147,7 +147,7 @@ static double benchmark2( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - stdlib_strided_dvander_ndarray( len, len, -1.0, x, 1, 0, out, len, 1, 0 ); + stdlib_strided_dvander_ndarray( -1.0, len, len, x, 1, 0, out, len, 1, 0 ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt index 76d8859cd9f7..c4e20240f483 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( order, M, N, mode, x, strideX, out, LDO ) +{{alias}}( order, mode, M, N, x, strideX, out, LDO ) Generates a double-precision floating-point Vandermonde matrix. Indexing is relative to the first index. To introduce an offset, use typed @@ -12,44 +12,43 @@ order: string Row-major (C-style) or column-major (Fortran-style) order. + mode: number + Specifies whether columns should contain powers that are increasing + (`1`) or decreasing (`-1`). + M: integer Number of rows in `out`. N: integer Number of columns in `out`. - mode: number - Specifies whether columns should contain powers that are increasing - (`1`) or decreasing (`-1`). - x: Float64Array - Input vector. + Input array. strideX: integer Stride length for `x`. out: Float64Array - Output matrix. + Output array. LDO: integer - Stride of the first dimension of `out` (a.k.a., leading dimension of - the matrix `out`). + Stride length for the leading dimension of `out`. Returns ------- out: Float64Array - Output matrix. + Output array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float64}}( 9 ); - > {{alias}}( 'row-major', 3, 3, -1, x, 1, out, 3 ) + > {{alias}}( 'row-major', -1, 3, 3, x, 1, out, 3 ) [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] -{{alias}}.ndarray( M, N, mode, x, strideX, offsetX, out, so1, so2, oo ) +{{alias}}.ndarray( mode, M, N, x, strideX, offsetX, out, so1, so2, oo ) Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. @@ -59,18 +58,18 @@ Parameters ---------- + mode: number + Specifies whether columns should contain powers that are increasing + (`1`) or decreasing (`-1`). + M: integer Number of rows in `out`. N: integer Number of columns in `out`. - mode: number - Specifies whether columns should contain powers that are increasing - (`1`) or decreasing (`-1`). - x: Float64Array - Input vector. + Input array. strideX: integer Stride length for `x`. @@ -79,7 +78,7 @@ Starting index for `x`. out: Float64Array - Output matrix. + Output array. so1: integer Stride of the first dimension of `out`. @@ -93,14 +92,14 @@ Returns ------- out: Float64Array - Output matrix. + Output array. Examples -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float64}}( 9 ); - > {{alias}}.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ) + > {{alias}}.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ) [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts index 06ebd14cf0f0..ecf04a63306c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts @@ -30,14 +30,14 @@ interface Routine { * Generates a double-precision floating-point Vandermonde matrix. * * @param order - storage layout + * @param mode - specifies whether columns should contain powers that are increasing or decreasing * @param M - number of rows in the matrix `Out` * @param N - number of columns in the matrix `Out` - * @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) - * @param x - input vector + * @param x - input array * @param strideX - stride length for `x` - * @param out - output matrix - * @param LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) - * @returns output matrix + * @param out - output array + * @param LDO - stride length for the leading dimension of `Out` + * @returns output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -45,25 +45,25 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * - * dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + * dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ - ( order: Layout, M: number, N: number, mode: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array; + ( order: Layout, mode: number, M: number, N: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array; /** * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * + * @param mode - specifies whether columns should contain powers that are increasing or decreasing * @param M - number of rows in the matrix `Out` * @param N - number of columns in the matrix `Out` - * @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) - * @param x - input vector + * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` - * @param out - output matrix + * @param out - output array * @param strideOut1 - stride of the first dimension of `Out` * @param strideOut2 - stride of the second dimension of `Out` * @param offsetOut - starting index for `Out` - * @returns output matrix + * @returns output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -71,24 +71,24 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * - * dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + * dvander.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ - ndarray( M: number, N: number, mode: number, x: Float64Array, strideX: number, offsetX: number, out: Float64Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float64Array; + ndarray( mode: number, M: number, N: number, x: Float64Array, strideX: number, offsetX: number, out: Float64Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float64Array; } /** * Generates a double-precision floating-point Vandermonde matrix. * * @param order - storage layout +* @param mode - specifies whether columns should contain powers that are increasing or decreasing * @param M - number of rows in the matrix `Out` * @param N - number of columns in the matrix `Out` -* @param mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) -* @param x - input vector +* @param x - input array * @param strideX - stride length for `x` -* @param out - output matrix -* @param LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) -* @returns output matrix +* @param out - output array +* @param LDO - stride length for the leading dimension of `Out` +* @returns output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -96,7 +96,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] * * @example @@ -105,7 +105,7 @@ interface Routine { * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* dvander.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ declare var dvander: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts index c04785f93e40..d99b01fc104d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts @@ -26,7 +26,7 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', 10, 10, -1, x, 1, out, 10 ); // $ExpectType Float64Array + dvander( 'row-major', -1, 10, 10, x, 1, out, 10 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -34,14 +34,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 10, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( true, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( false, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( null, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( undefined, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( [], 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( {}, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( ( x: number ): number => x, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 10, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( true, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( false, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( null, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( undefined, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( [], -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( {}, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( ( x: number ): number => x, -1, 10, 10, x, 1, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -49,14 +49,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', '10', 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', true, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', false, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', null, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', undefined, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', [], 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', {}, 10, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', ( x: number ): number => x, 10, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', '10', 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', true, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', false, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', null, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', undefined, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', [], 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', {}, 10, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', ( x: number ): number => x, 10, 10, x, 1, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -64,14 +64,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', 10, '10', -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, true, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, false, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, null, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, undefined, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, [], -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, {}, -1, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, ( x: number ): number => x, -1, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, '10', 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, true, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, false, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, null, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, undefined, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, [], 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, {}, 10, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, ( x: number ): number => x, 10, x, 1, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -79,29 +79,29 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', 10, 10, '10', x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, true, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, false, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, null, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, undefined, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, [], x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, {}, x, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, ( x: number ): number => x, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, '10', x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, true, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, false, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, null, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, undefined, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, [], x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, {}, x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, ( x: number ): number => x, x, 1, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... { const out = new Float64Array( 100 ); - dvander( 'row-major', 10, 10, -1, 10, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, '10', 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, true, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, false, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, null, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, undefined, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, [ '1' ], 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, {}, 1, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, ( x: number ): number => x, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, 10, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, '10', 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, true, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, false, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, null, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, undefined, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, [ '1' ], 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, {}, 1, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, ( x: number ): number => x, 1, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... @@ -109,29 +109,29 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', 10, 10, -1, x, '10', out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, true, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, false, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, null, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, undefined, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, [], out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, {}, out, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, ( x: number ): number => x, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, '10', out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, true, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, false, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, null, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, undefined, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, [], out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, {}, out, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, ( x: number ): number => x, out, 10 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); - dvander( 'row-major', 10, 10, -1, x, 1, 10, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, '10', 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, true, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, false, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, null, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, undefined, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, [ '1' ], 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, {}, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, ( x: number ): number => x, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, 10, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, '10', 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, true, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, false, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, null, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, undefined, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, [ '1' ], 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, {}, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, ( x: number ): number => x, 10 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not a number... @@ -139,14 +139,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander( 'row-major', 10, 10, -1, x, 1, out, '10' ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, true ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, false ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, null ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, undefined ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, [] ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, {} ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, ( x: number ): number => x ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, '10' ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, true ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, false ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, null ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, undefined ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, [] ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, {} ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -156,13 +156,13 @@ import dvander = require( './index' ); dvander(); // $ExpectError dvander( 'row-major' ); // $ExpectError - dvander( 'row-major', 10 ); // $ExpectError - dvander( 'row-major', 10, 10 ); // $ExpectError - dvander( 'row-major', 10, 10, -1 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1 ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out ); // $ExpectError - dvander( 'row-major', 10, 10, -1, x, 1, out, 10, 10 ); // $ExpectError + dvander( 'row-major', -1 ); // $ExpectError + dvander( 'row-major', -1, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1 ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out ); // $ExpectError + dvander( 'row-major', -1, 10, 10, x, 1, out, 10, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float64Array... @@ -170,7 +170,7 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float64Array + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... @@ -178,14 +178,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( '10', 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( true, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( false, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( null, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( undefined, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( [], 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( {}, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( ( x: number ): number => x, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( '10', 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( true, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( false, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( null, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( undefined, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( [], 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( {}, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( ( x: number ): number => x, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -193,14 +193,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, '10', -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, true, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, false, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, null, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, undefined, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, [], -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, {}, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, ( x: number ): number => x, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, '10', 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, true, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, false, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, null, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, undefined, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, [], 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, {}, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, ( x: number ): number => x, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... @@ -208,29 +208,29 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, ( x: number ): number => x, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, ( x: number ): number => x, x, 1, 0, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Float64Array... { const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, true, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, false, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, null, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, ( x: number ): number => x, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, true, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, false, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, null, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, ( x: number ): number => x, 1, 0, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -238,14 +238,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, '10', 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, true, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, false, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, null, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, [], 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, {}, 0, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, ( x: number ): number => x, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, '10', 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, true, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, false, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, null, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, [], 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, {}, 0, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, ( x: number ): number => x, 0, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... @@ -253,29 +253,29 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, 1, '10', out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, true, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, false, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, null, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, [], out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, {}, out, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, ( x: number ): number => x, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, '10', out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, true, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, false, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, null, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, [], out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, {}, out, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, ( x: number ): number => x, out, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); - dvander.ndarray( 10, 10, -1, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, true, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, false, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, null, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... @@ -283,14 +283,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, 1, 0, out, '10', 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, true, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, false, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, null, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, [], 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, {}, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, '10', 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, true, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, false, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, null, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, [], 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, {}, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... @@ -298,14 +298,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, '10', 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, true, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, false, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, null, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, [], 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, {}, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, ( x: number ): number => x, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, '10', 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, true, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, false, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, null, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, [], 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, {}, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... @@ -313,14 +313,14 @@ import dvander = require( './index' ); const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, '10' ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, true ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, false ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, null ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, undefined ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, [] ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, {} ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, ( x: number ): number => x ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, '10' ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, true ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, false ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, null ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, undefined ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, [] ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, {} ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -329,14 +329,14 @@ import dvander = require( './index' ); const out = new Float64Array( 100 ); dvander.ndarray(); // $ExpectError - dvander.ndarray( 10 ); // $ExpectError - dvander.ndarray( 10, 10 ); // $ExpectError - dvander.ndarray( 10, 10, -1 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1 ); // $ExpectError - dvander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError + dvander.ndarray( -1 ); // $ExpectError + dvander.ndarray( -1, 10 ); // $ExpectError + dvander.ndarray( -1, 10, 10 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1 ); // $ExpectError + dvander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c index ca907c81ba48..70249a414e53 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/c/example.c @@ -21,10 +21,10 @@ #include int main( void ) { - // Define a 3x3 output matrix stored in row-major order: + // Define a 3x3 output array stored in row-major order: double Out[ 3*3 ] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Define the input vector: + // Define the input array: const double x[ 3 ] = { 1.0, 2.0, 3.0 }; // Specify the number of rows and columns: @@ -32,7 +32,7 @@ int main( void ) { const int N = 3; // Generate the Vandermonde matrix: - stdlib_strided_dvander( CblasRowMajor, M, N, -1.0, x, 1, Out, N ); + stdlib_strided_dvander( CblasRowMajor, -1.0, M, N, x, 1, Out, N ); // Print the result: for ( int i = 0; i < M; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js index 24a7c1675dee..fdc7181591a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/examples/index.js @@ -22,19 +22,13 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float64Array = require( '@stdlib/array/float64' ); var dvander = require( './../lib' ); -var opts = { - 'dtype': 'float64' -}; - var M = 3; var N = 4; -var x = discreteUniform( M, 0, 10, opts ); +var x = discreteUniform( M, 0, 10, { + 'dtype': 'float64' +}); var out = new Float64Array( M*N ); -dvander( 'row-major', M, N, -1, x, 1, out, N ); -console.log( out ); - -out = new Float64Array( M*N ); -dvander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +dvander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/include/stdlib/blas/ext/base/dvander.h b/lib/node_modules/@stdlib/blas/ext/base/dvander/include/stdlib/blas/ext/base/dvander.h index 9e7e1d8170a5..144763481a25 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/include/stdlib/blas/ext/base/dvander.h +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/include/stdlib/blas/ext/base/dvander.h @@ -34,12 +34,12 @@ extern "C" { /** * Generates a double-precision floating-point Vandermonde matrix. */ -void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); +void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); /** * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js index c4ee5c792fa9..8f6f49e51c85 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js @@ -21,9 +21,7 @@ // MODULES // var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var format = require( '@stdlib/string/format' ); var ndarray = require( './ndarray.js' ); @@ -33,19 +31,14 @@ var ndarray = require( './ndarray.js' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {string} order - storage layout +* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing * @param {NonNegativeInteger} M - number of rows in the matrix `Out` * @param {NonNegativeInteger} N - number of columns in the matrix `Out` -* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) -* @param {Float64Array} x - input vector +* @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float64Array} out - output matrix -* @param {PositiveInteger} LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) -* @throws {TypeError} first argument must be a valid order -* @throws {RangeError} second argument must be a nonnegative integer -* @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} sixth argument must be non-zero -* @throws {RangeError} eighth argument must be a valid stride -* @returns {Float64Array} output matrix +* @param {Float64Array} out - output array +* @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @returns {Float64Array} output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -53,57 +46,23 @@ var ndarray = require( './ndarray.js' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( order, M, N, mode, x, strideX, out, LDO ) { - var iscm; - var vala; +function dvander( order, mode, M, N, x, strideX, out, LDO ) { var sa1; var sa2; var ox; - if ( !isLayout( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); - } - - if ( M < 0 ) { - throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); - } - - if ( N < 0 ) { - throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); - } - - if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); - } - - // Check if we can early return... - if ( M === 0 || N === 0 ) { - return out; - } - - iscm = isColumnMajor( order ); - if ( iscm ) { - vala = M; - } else { - vala = N; - } - - if ( LDO < vala ) { - throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', vala, LDO ) ); - } - ox = stride2offset( M, strideX ); - if ( iscm ) { + if ( isColumnMajor( order ) ) { sa1 = 1; sa2 = LDO; } else { // order === 'row-major' sa1 = LDO; sa2 = 1; } - return ndarray( M, N, mode, x, strideX, ox, out, sa1, sa2, 0 ); + return ndarray( mode, M, N, x, strideX, ox, out, sa1, sa2, 0 ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js index 36273f42df0a..f18e49547abf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -30,14 +30,14 @@ var addon = require( './../src/addon.node' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {string} order - storage layout +* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing * @param {NonNegativeInteger} M - number of rows in the matrix `Out` * @param {NonNegativeInteger} N - number of columns in the matrix `Out` -* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) -* @param {Float64Array} x - input vector +* @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float64Array} out - output matrix -* @param {PositiveInteger} LDO - stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) -* @returns {Float64Array} output matrix +* @param {Float64Array} out - output array +* @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @returns {Float64Array} output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -45,11 +45,11 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( order, M, N, mode, x, strideX, out, LDO ) { - addon( resolve( order ), M, N, mode, x, strideX, out, LDO ); +function dvander( order, mode, M, N, x, strideX, out, LDO ) { + addon( resolve( order ), mode, M, N, x, strideX, out, LDO ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js index 3abe655b8b56..186fd2b8a087 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] * * @example @@ -40,7 +40,7 @@ * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* dvander.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js index 31d7aa0fbf12..f220799d58f9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -31,17 +31,17 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; /** * Generates a double-precision floating-point Vandermonde matrix. * +* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing * @param {NonNegativeInteger} M - number of rows in the matrix `Out` * @param {NonNegativeInteger} N - number of columns in the matrix `Out` -* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) -* @param {Float64Array} x - input vector +* @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float64Array} out - output matrix +* @param {Float64Array} out - output array * @param {integer} strideOut1 - stride length for the first dimension of `Out` * @param {integer} strideOut2 - stride length for the second dimension of `Out` * @param {NonNegativeInteger} offsetOut - starting index for `Out` -* @returns {Float64Array} output matrix +* @returns {Float64Array} output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -49,10 +49,10 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* dvander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { +function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { var do0; var do1; var rm; @@ -64,7 +64,7 @@ function dvander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, var i0; var i1; - if ( M === 0 || N === 0 ) { + if ( M <= 0 || N <= 0 ) { return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js index 2eb15905db3c..7fb5987a6498 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -30,17 +30,17 @@ var addon = require( './../src/addon.node' ); /** * Generates a double-precision floating-point Vandermonde matrix. * +* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing * @param {NonNegativeInteger} M - number of rows in the matrix `Out` * @param {NonNegativeInteger} N - number of columns in the matrix `Out` -* @param {number} mode - specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`) -* @param {Float64Array} x - input vector +* @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float64Array} out - output matrix +* @param {Float64Array} out - output array * @param {integer} strideOut1 - stride length for the first dimension of `Out` * @param {integer} strideOut2 - stride length for the second dimension of `Out` * @param {NonNegativeInteger} offsetOut - starting index for `Out` -* @returns {Float64Array} output matrix +* @returns {Float64Array} output array * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -48,11 +48,11 @@ var addon = require( './../src/addon.node' ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float64Array( 9 ); * -* dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* dvander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { - addon.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); +function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + addon.ndarray( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c index 241f1288034c..f8f1e425a774 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c @@ -35,14 +35,14 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); STDLIB_NAPI_ARGV_INT64( env, order, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); - STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); - STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 3 ); + STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); - API_SUFFIX(stdlib_strided_dvander)( order, M, N, mode, X, strideX, Out, LDO ); + API_SUFFIX(stdlib_strided_dvander)( order, mode, M, N, X, strideX, Out, LDO ); return NULL; } @@ -55,9 +55,9 @@ static napi_value addon( napi_env env, napi_callback_info info ) { */ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 10 ); - STDLIB_NAPI_ARGV_INT64( env, M, argv, 0 ); - STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); - STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 2 ); + STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 3 ); @@ -65,7 +65,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideOut2, argv, 8 ); STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 9 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); - API_SUFFIX(stdlib_strided_dvander_ndarray)( M, N, mode, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); + API_SUFFIX(stdlib_strided_dvander_ndarray)( mode, M, N, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index 7fbdff6b624a..4034a696018a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -21,20 +21,21 @@ #include "stdlib/ndarray/base/assert/is_row_major.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/stride2offset.h" +#include /** * Generates a double-precision floating-point Vandermonde matrix. * * @param order storage layout +* @param mode specifies whether powers are increasing (1) or decreasing (-1) * @param M number of rows in the matrix `Out` * @param N number of columns in the matrix `Out` -* @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param X input vector +* @param X input array * @param strideX stride length for `X` -* @param Out output matrix -* @param LDO leading dimension of `Out` +* @param Out output array +* @param LDO stride length for the leading dimension of `Out` */ -void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ) { +void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ) { CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; @@ -47,25 +48,25 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const CBLAS_I sa1 = LDO; sa2 = 1; } - API_SUFFIX(stdlib_strided_dvander_ndarray)( M, N, mode, X, strideX, ox, Out, sa1, sa2, 0 ); + API_SUFFIX(stdlib_strided_dvander_ndarray)( mode, M, N, X, strideX, ox, Out, sa1, sa2, 0 ); } /** * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * +* @param mode specifies whether powers are increasing (1) or decreasing (-1) * @param M number of rows in the matrix `Out` * @param N number of columns in the matrix `Out` -* @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param X input vector +* @param X input array * @param strideX stride length for `X` * @param offsetX starting index for `X` -* @param Out output matrix +* @param Out output array * @param strideOut1 stride length for the first dimension of `Out` * @param strideOut2 stride length for the second dimension of `Out` * @param offsetOut starting index for `Out` */ -void API_SUFFIX(stdlib_strided_dvander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const double mode, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { - CBLAS_INT sa[ 2 ]; +void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { + int64_t sa[ 2 ]; CBLAS_INT do0; CBLAS_INT do1; CBLAS_INT rm; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js index c31a755fd6ae..f838c08ba166 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js @@ -38,98 +38,6 @@ tape( 'the function has an arity of 8', function test( t ) { t.end(); }); -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { - var values; - var out; - var x; - var i; - - values = [ - 'foo', - 'bar', - 'beep', - 'boop' - ]; - x = new Float64Array( [ 1.0, 2.0 ] ); - out = new Float64Array( 4 ); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - dvander( value, 2, 2, -1, x, 1, out, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid second argument', function test( t ) { - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0 ] ); - out = new Float64Array( 4 ); - - t.throws( function badValue() { - dvander( 'row-major', -1, 2, -1, x, 1, out, 2 ); - }, RangeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid third argument', function test( t ) { - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0 ] ); - out = new Float64Array( 4 ); - - t.throws( function badValue() { - dvander( 'row-major', 2, -1, -1, x, 1, out, 2 ); - }, RangeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0 ] ); - out = new Float64Array( 4 ); - - t.throws( function badValue() { - dvander( 'row-major', 2, 2, -1, x, 0, out, 2 ); - }, RangeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0 ] ); - out = new Float64Array( 4 ); - - t.throws( function badValue() { - dvander( 'row-major', 2, 3, -1, x, 1, out, 2 ); - }, RangeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid eighth argument (column-major)', function test( t ) { - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = new Float64Array( 6 ); - - t.throws( function badValue() { - dvander( 'column-major', 3, 2, -1, x, 1, out, 2 ); - }, RangeError, 'throws an error' ); - t.end(); -}); - tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { var expected; var out; @@ -138,7 +46,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', fun x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -164,7 +72,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', fun x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + dvander( 'row-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -190,7 +98,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + dvander( 'column-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -216,7 +124,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + dvander( 'column-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -242,7 +150,7 @@ tape( 'the function returns the output array', function test( t ) { x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 4 ); - v = dvander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + v = dvander( 'row-major', -1, 2, 2, x, 1, out, 2 ); t.strictEqual( v, out, 'returns expected value' ); t.end(); @@ -255,7 +163,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', function te x = new Float64Array( [] ); out = new Float64Array( [] ); - dvander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + dvander( 'row-major', -1, 0, 3, x, 1, out, 3 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -268,7 +176,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', function te x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + dvander( 'row-major', -1, 2, 0, x, 1, out, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -283,7 +191,7 @@ tape( 'the function supports specifying a stride (row-major)', function test( t x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + dvander( 'row-major', -1, 2, 3, x, 2, out, 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -300,7 +208,7 @@ tape( 'the function supports specifying a negative stride (row-major)', function x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + dvander( 'row-major', -1, 2, 3, x, -2, out, 3 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -318,7 +226,7 @@ tape( 'the function supports specifying a stride (column-major)', function test( x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float64Array( 6 ); - dvander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + dvander( 'column-major', -1, 2, 3, x, 2, out, 2 ); expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -335,7 +243,7 @@ tape( 'the function supports specifying a negative stride (column-major)', funct x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + dvander( 'column-major', -1, 2, 3, x, -2, out, 2 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -353,7 +261,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo out = new Float64Array( 10 ); // 2x3 row-major with LDO=5 (padding of 2 per row) - dvander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + dvander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float64Array([ 1.0, @@ -381,7 +289,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m out = new Float64Array( 12 ); // 2x3 column-major with LDO=4 (padding of 2 per column) - dvander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + dvander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float64Array([ 1.0, @@ -410,7 +318,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + dvander( 'row-major', -1, 3, 2, x, 1, out, 2 ); // 3x2 matrix, decreasing: expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -427,7 +335,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + dvander( 'row-major', 1, 2, 4, x, 1, out, 4 ); // 2x4 matrix, increasing: expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js index bc07a608095e..25276422be6e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js @@ -55,7 +55,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opt x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -81,7 +81,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opt x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + dvander( 'row-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -107,7 +107,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + dvander( 'column-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -133,7 +133,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + dvander( 'column-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float64Array([ 1.0, @@ -159,7 +159,7 @@ tape( 'the function returns the output array', opts, function test( t ) { x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 4 ); - v = dvander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + v = dvander( 'row-major', -1, 2, 2, x, 1, out, 2 ); t.strictEqual( v, out, 'returns expected value' ); t.end(); @@ -172,7 +172,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', opts, funct x = new Float64Array( [] ); out = new Float64Array( [] ); - dvander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + dvander( 'row-major', -1, 0, 3, x, 1, out, 3 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -185,7 +185,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', opts, funct x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + dvander( 'row-major', -1, 2, 0, x, 1, out, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -200,7 +200,7 @@ tape( 'the function supports specifying a stride (row-major)', opts, function te x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + dvander( 'row-major', -1, 2, 3, x, 2, out, 3 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -217,7 +217,7 @@ tape( 'the function supports specifying a negative stride (row-major)', opts, fu x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + dvander( 'row-major', -1, 2, 3, x, -2, out, 3 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -235,7 +235,7 @@ tape( 'the function supports specifying a stride (column-major)', opts, function x = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float64Array( 6 ); - dvander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + dvander( 'column-major', -1, 2, 3, x, 2, out, 2 ); expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -252,7 +252,7 @@ tape( 'the function supports specifying a negative stride (column-major)', opts, x = new Float64Array( [ 3.0, 0.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + dvander( 'column-major', -1, 2, 3, x, -2, out, 2 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -270,7 +270,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo out = new Float64Array( 10 ); // 2x3 row-major with LDO=5 (padding of 2 per row) - dvander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + dvander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float64Array([ 1.0, @@ -298,7 +298,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m out = new Float64Array( 12 ); // 2x3 column-major with LDO=4 (padding of 2 per column) - dvander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + dvander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float64Array([ 1.0, @@ -327,7 +327,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + dvander( 'row-major', -1, 3, 2, x, 1, out, 2 ); // 3x2 matrix, decreasing: expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -344,7 +344,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + dvander( 'row-major', 1, 2, 4, x, 1, out, 4 ); // 2x4 matrix, increasing: expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js index 7fad83408fe8..8aa7b719ccaa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js @@ -46,7 +46,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', fun x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + dvander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float64Array([ 1.0, @@ -72,7 +72,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', fun x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + dvander( 1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float64Array([ 1.0, @@ -99,7 +99,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', out = new Float64Array( 9 ); // Column-major: strideOut1=1, strideOut2=3 - dvander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + dvander( -1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array([ 1.0, @@ -126,7 +126,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', out = new Float64Array( 9 ); // Column-major: strideOut1=1, strideOut2=3 - dvander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + dvander( 1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array([ 1.0, @@ -152,7 +152,7 @@ tape( 'the function returns the output array', function test( t ) { x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 4 ); - v = dvander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + v = dvander( -1, 2, 2, x, 1, 0, out, 2, 1, 0 ); t.strictEqual( v, out, 'returns expected value' ); t.end(); @@ -165,7 +165,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', function te x = new Float64Array( [] ); out = new Float64Array( [] ); - dvander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + dvander( -1, 0, 3, x, 1, 0, out, 3, 1, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -178,7 +178,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', function te x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + dvander( -1, 2, 0, x, 1, 0, out, 0, 1, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -193,7 +193,7 @@ tape( 'the function supports an `x` stride', function test( t ) { x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, 2, 0, out, 3, 1, 0 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -209,7 +209,7 @@ tape( 'the function supports a negative `x` stride', function test( t ) { x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, -2, 2, out, 3, 1, 0 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -226,7 +226,7 @@ tape( 'the function supports an `x` offset', function test( t ) { x = new Float64Array( [ 999.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, 1, 1, out, 3, 1, 0 ); expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -242,7 +242,7 @@ tape( 'the function supports an output offset', function test( t ) { x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + dvander( -1, 2, 3, x, 1, 0, out, 3, 1, 2 ); // Starting at offset 2: expected = new Float64Array( [ 0.0, 0.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -260,7 +260,7 @@ tape( 'the function supports output strides with padding (row-major)', function out = new Float64Array( 10 ); // 2x3 row-major with strideOut1=5 (padding of 2 per row) - dvander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + dvander( -1, 2, 3, x, 1, 0, out, 5, 1, 0 ); expected = new Float64Array([ 1.0, @@ -288,7 +288,7 @@ tape( 'the function supports output strides with padding (column-major)', functi out = new Float64Array( 12 ); // 2x3 column-major with strideOut2=4 (padding of 2 per column) - dvander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + dvander( -1, 2, 3, x, 1, 0, out, 1, 4, 0 ); expected = new Float64Array([ 1.0, @@ -317,7 +317,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + dvander( -1, 3, 2, x, 1, 0, out, 2, 1, 0 ); // 3x2 matrix, decreasing: expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -334,7 +334,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + dvander( 1, 2, 4, x, 1, 0, out, 4, 1, 0 ); // 2x4 matrix, increasing: expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); @@ -352,7 +352,7 @@ tape( 'the function supports non-square matrices (M > N, column-major, decreasin out = new Float64Array( 6 ); // 3x2 column-major: strideOut1=1, strideOut2=3 - dvander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + dvander( -1, 3, 2, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); @@ -369,7 +369,7 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin out = new Float64Array( 8 ); // 2x4 column-major: strideOut1=1, strideOut2=2 - dvander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + dvander( 1, 2, 4, x, 1, 0, out, 1, 2, 0 ); expected = new Float64Array( [ 1.0, 1.0, 2.0, 3.0, 4.0, 9.0, 8.0, 27.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js index 389a8fa624ab..7c055db39379 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js @@ -55,7 +55,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opt x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + dvander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float64Array([ 1.0, @@ -81,7 +81,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opt x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + dvander( 1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float64Array([ 1.0, @@ -107,7 +107,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + dvander( -1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array([ 1.0, @@ -133,7 +133,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 9 ); - dvander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + dvander( 1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array([ 1.0, @@ -159,7 +159,7 @@ tape( 'the function returns the output array', opts, function test( t ) { x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 4 ); - v = dvander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + v = dvander( -1, 2, 2, x, 1, 0, out, 2, 1, 0 ); t.strictEqual( v, out, 'returns expected value' ); t.end(); @@ -172,7 +172,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', opts, funct x = new Float64Array( [] ); out = new Float64Array( [] ); - dvander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + dvander( -1, 0, 3, x, 1, 0, out, 3, 1, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -185,7 +185,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', opts, funct x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + dvander( -1, 2, 0, x, 1, 0, out, 0, 1, 0 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); @@ -200,7 +200,7 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, 2, 0, out, 3, 1, 0 ); expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -216,7 +216,7 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) { x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, -2, 2, out, 3, 1, 0 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float64Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -233,7 +233,7 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { x = new Float64Array( [ 999.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + dvander( -1, 2, 3, x, 1, 1, out, 3, 1, 0 ); expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -249,7 +249,7 @@ tape( 'the function supports an output offset', opts, function test( t ) { x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + dvander( -1, 2, 3, x, 1, 0, out, 3, 1, 2 ); // Starting at offset 2: expected = new Float64Array( [ 0.0, 0.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -267,7 +267,7 @@ tape( 'the function supports output strides with padding (row-major)', opts, fun out = new Float64Array( 10 ); // 2x3 row-major with strideOut1=5 (padding of 2 per row) - dvander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + dvander( -1, 2, 3, x, 1, 0, out, 5, 1, 0 ); expected = new Float64Array([ 1.0, @@ -295,7 +295,7 @@ tape( 'the function supports output strides with padding (column-major)', opts, out = new Float64Array( 12 ); // 2x3 column-major with strideOut2=4 (padding of 2 per column) - dvander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + dvander( -1, 2, 3, x, 1, 0, out, 1, 4, 0 ); expected = new Float64Array([ 1.0, @@ -324,7 +324,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); out = new Float64Array( 6 ); - dvander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + dvander( -1, 3, 2, x, 1, 0, out, 2, 1, 0 ); // 3x2 matrix, decreasing: expected = new Float64Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -341,7 +341,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float64Array( [ 2.0, 3.0 ] ); out = new Float64Array( 8 ); - dvander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + dvander( 1, 2, 4, x, 1, 0, out, 4, 1, 0 ); // 2x4 matrix, increasing: expected = new Float64Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); @@ -359,7 +359,7 @@ tape( 'the function supports non-square matrices (M > N, column-major, decreasin out = new Float64Array( 6 ); // 3x2 column-major: strideOut1=1, strideOut2=3 - dvander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + dvander( -1, 3, 2, x, 1, 0, out, 1, 3, 0 ); expected = new Float64Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); @@ -376,7 +376,7 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin out = new Float64Array( 8 ); // 2x4 column-major: strideOut1=1, strideOut2=2 - dvander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + dvander( 1, 2, 4, x, 1, 0, out, 1, 2, 0 ); expected = new Float64Array( [ 1.0, 1.0, 2.0, 3.0, 4.0, 9.0, 8.0, 27.0 ] ); From a07fb24bcefe4f871da23d13520262930c574e91 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 15 Mar 2026 00:32:57 +0500 Subject: [PATCH 03/12] docs: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 12 ++++++------ .../blas/ext/base/dvander/docs/types/index.d.ts | 12 ++++++------ .../@stdlib/blas/ext/base/dvander/lib/dvander.js | 4 ++-- .../blas/ext/base/dvander/lib/dvander.native.js | 4 ++-- .../@stdlib/blas/ext/base/dvander/lib/ndarray.js | 4 ++-- .../blas/ext/base/dvander/lib/ndarray.native.js | 4 ++-- .../@stdlib/blas/ext/base/dvander/src/main.c | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md index eedd179a1f17..66a12a36e0ba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -48,8 +48,8 @@ The function has the following parameters: - **order**: storage layout. - **mode**: specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`). -- **M**: number of rows in the matrix `out`. -- **N**: number of columns in the matrix `out`. +- **M**: number of rows in `out`. +- **N**: number of columns in `out`. - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: stride length for `x`. - **out**: output [`Float64Array`][@stdlib/array/float64]. @@ -207,8 +207,8 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. -- **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. +- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Out**: `[out] double*` output array. @@ -238,8 +238,8 @@ stdlib_strided_dvander_ndarray( -1.0, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: - **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in the matrix `Out`. -- **N**: `[in] CBLAS_INT` number of columns in the matrix `Out`. +- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts index ecf04a63306c..a4909a6bfc94 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts @@ -31,8 +31,8 @@ interface Routine { * * @param order - storage layout * @param mode - specifies whether columns should contain powers that are increasing or decreasing - * @param M - number of rows in the matrix `Out` - * @param N - number of columns in the matrix `Out` + * @param M - number of rows in `out` + * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param out - output array @@ -54,8 +54,8 @@ interface Routine { * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode - specifies whether columns should contain powers that are increasing or decreasing - * @param M - number of rows in the matrix `Out` - * @param N - number of columns in the matrix `Out` + * @param M - number of rows in `out` + * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` @@ -82,8 +82,8 @@ interface Routine { * * @param order - storage layout * @param mode - specifies whether columns should contain powers that are increasing or decreasing -* @param M - number of rows in the matrix `Out` -* @param N - number of columns in the matrix `Out` +* @param M - number of rows in `out` +* @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js index 8f6f49e51c85..7c8eadc0175b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js @@ -32,8 +32,8 @@ var ndarray = require( './ndarray.js' ); * * @param {string} order - storage layout * @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in the matrix `Out` -* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {NonNegativeInteger} M - number of rows in `out` +* @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js index f18e49547abf..15313147e7fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -31,8 +31,8 @@ var addon = require( './../src/addon.node' ); * * @param {string} order - storage layout * @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in the matrix `Out` -* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {NonNegativeInteger} M - number of rows in `out` +* @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js index f220799d58f9..df615b082e8b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -32,8 +32,8 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * Generates a double-precision floating-point Vandermonde matrix. * * @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in the matrix `Out` -* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {NonNegativeInteger} M - number of rows in `out` +* @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js index 7fb5987a6498..a2288212243d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -31,8 +31,8 @@ var addon = require( './../src/addon.node' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in the matrix `Out` -* @param {NonNegativeInteger} N - number of columns in the matrix `Out` +* @param {NonNegativeInteger} M - number of rows in `out` +* @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index 4034a696018a..335e8bfda130 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -28,8 +28,8 @@ * * @param order storage layout * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in the matrix `Out` -* @param N number of columns in the matrix `Out` +* @param M number of rows in `out` +* @param N number of columns in `out` * @param X input array * @param strideX stride length for `X` * @param Out output array @@ -55,8 +55,8 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in the matrix `Out` -* @param N number of columns in the matrix `Out` +* @param M number of rows in `out` +* @param N number of columns in `out` * @param X input array * @param strideX stride length for `X` * @param offsetX starting index for `X` From efad4c2d27136cda21bf1fc0730d1a696c752249 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 15 Mar 2026 17:18:17 +0500 Subject: [PATCH 04/12] refactor: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/lib/base.js | 141 ++++++++++++++++++ .../blas/ext/base/dvander/lib/dvander.js | 44 +++++- .../ext/base/dvander/lib/dvander.native.js | 38 +++++ .../blas/ext/base/dvander/lib/ndarray.js | 97 ++---------- .../ext/base/dvander/lib/ndarray.native.js | 18 +++ .../blas/ext/base/dvander/manifest.json | 3 + .../@stdlib/blas/ext/base/dvander/src/main.c | 54 +++++++ .../ext/base/dvander/test/test.dvander.js | 113 +++++++++++++- .../base/dvander/test/test.dvander.native.js | 113 +++++++++++++- .../ext/base/dvander/test/test.ndarray.js | 64 ++++++++ .../base/dvander/test/test.ndarray.native.js | 64 ++++++++ 11 files changed, 663 insertions(+), 86 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js new file mode 100644 index 000000000000..8a140b91e654 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js @@ -0,0 +1,141 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; + + +// MAIN // + +/** +* Generates a double-precision floating-point Vandermonde matrix. +* +* @private +* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing +* @param {NonNegativeInteger} M - number of rows in `out` +* @param {NonNegativeInteger} N - number of columns in `out` +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} out - output array +* @param {integer} strideOut1 - stride length for the first dimension of `Out` +* @param {integer} strideOut2 - stride length for the second dimension of `Out` +* @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float64Array( 9 ); +* +* dvander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] +*/ +function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + var do0; + var do1; + var rm; + var S0; + var S1; + var sx; + var io; + var ix; + var i0; + var i1; + + // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... + rm = isRowMajor( [ strideOut1, strideOut2 ] ); + + // Extract loop variables for loop interchange... + if ( rm ) { + S0 = N; + S1 = M; + do0 = strideOut2; // offset increment for innermost loop + do1 = strideOut1 - ( S0*strideOut2 ); // offset increment for outermost loop + } else { // order === 'column-major' + S0 = M; + S1 = N; + do0 = strideOut1; // offset increment for innermost loop + do1 = strideOut2 - ( S0*strideOut1 ); // offset increment for outermost loop + } + sx = strideX; + io = offsetOut; + + // For a Vandermonde matrix, each row `i` contains powers of `x[i]`: + if ( rm ) { + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + if ( mode > 0 ) { + // Increasing: x^0, x^1, ..., x^(N-1) + out[ io ] = 1.0; + io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + out[ io ] = out[ io - do0 ] * x[ ix ]; + io += do0; + } + } else { + // Decreasing: x^(N-1), x^(N-2), ..., x^0 + out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; + for ( i0 = S0 - 2; i0 >= 0; i0-- ) { + out[ io + ( i0*do0 ) ] = out[ io + ( (i0+1)*do0 ) ] * x[ ix ]; + } + io += S0 * do0; + } + ix += sx; + io += do1; + } + } else if ( mode > 0 ) { + // Increasing: column j contains x^j + dfill( S0, 1.0, out, do0, io ); + io += ( S0 * do0 ) + do1; + for ( i1 = 1; i1 < S1; i1++ ) { + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + out[ io ] = out[ io - strideOut2 ] * x[ ix ]; + ix += sx; + io += do0; + } + io += do1; + } + } else { + // Decreasing: column 0 contains x^(N-1), last column all ones + dfill( S0, 1.0, out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + for ( i1 = S1 - 2; i1 >= 0; i1-- ) { + io = offsetOut + ( i1 * strideOut2 ); + ix = offsetX; + for ( i0 = 0; i0 < S0; i0++ ) { + out[ io ] = out[ io + strideOut2 ] * x[ ix ]; + ix += sx; + io += do0; + } + } + } + return out; +} + + +// EXPORTS // + +module.exports = dvander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js index 7c8eadc0175b..01046eeafdda 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js @@ -21,8 +21,11 @@ // MODULES // var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); -var ndarray = require( './ndarray.js' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); // MAIN // @@ -38,6 +41,11 @@ var ndarray = require( './ndarray.js' ); * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output array * @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} output array * * @example @@ -50,19 +58,49 @@ var ndarray = require( './ndarray.js' ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( order, mode, M, N, x, strideX, out, LDO ) { + var iscm; var sa1; var sa2; var ox; + var k; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + + iscm = isColumnMajor( order ); + if ( iscm ) { + k = M; + } else { + k = N; + } + + if ( LDO < max( 1, k ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, LDO ) ); + } + + if ( M === 0 || N === 0 ) { + return out; + } ox = stride2offset( M, strideX ); - if ( isColumnMajor( order ) ) { + if ( iscm ) { sa1 = 1; sa2 = LDO; } else { // order === 'row-major' sa1 = LDO; sa2 = 1; } - return ndarray( mode, M, N, x, strideX, ox, out, sa1, sa2, 0 ); + return base( mode, M, N, x, strideX, ox, out, sa1, sa2, 0 ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js index 15313147e7fb..2d7aba3538f6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -20,7 +20,11 @@ // MODULES // +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var resolve = require( '@stdlib/blas/base/layout-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -37,6 +41,11 @@ var addon = require( './../src/addon.node' ); * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output array * @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} output array * * @example @@ -49,6 +58,35 @@ var addon = require( './../src/addon.node' ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( order, mode, M, N, x, strideX, out, LDO ) { + var k; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + + if ( isColumnMajor( order ) ) { + k = M; + } else { + k = N; + } + + if ( LDO < max( 1, k ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, LDO ) ); + } + + if ( M === 0 || N === 0 ) { + return out; + } + addon( resolve( order ), mode, M, N, x, strideX, out, LDO ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js index df615b082e8b..20df802c60d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -22,8 +22,8 @@ // MODULES // -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); // MAIN // @@ -41,6 +41,9 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * @param {integer} strideOut1 - stride length for the first dimension of `Out` * @param {integer} strideOut2 - stride length for the second dimension of `Out` * @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero * @returns {Float64Array} output array * * @example @@ -53,89 +56,21 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { - var do0; - var do1; - var rm; - var S0; - var S1; - var sx; - var io; - var ix; - var i0; - var i1; - - if ( M <= 0 || N <= 0 ) { - return out; + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); } - - // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... - rm = isRowMajor( [ strideOut1, strideOut2 ] ); - - // Extract loop variables for loop interchange... - if ( rm ) { - S0 = N; - S1 = M; - do0 = strideOut2; // offset increment for innermost loop - do1 = strideOut1 - ( S0*strideOut2 ); // offset increment for outermost loop - } else { // order === 'column-major' - S0 = M; - S1 = N; - do0 = strideOut1; // offset increment for innermost loop - do1 = strideOut2 - ( S0*strideOut1 ); // offset increment for outermost loop + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); } - sx = strideX; - io = offsetOut; - // For a Vandermonde matrix, each row `i` contains powers of `x[i]`: - if ( rm ) { - ix = offsetX; - for ( i1 = 0; i1 < S1; i1++ ) { - if ( mode > 0 ) { - // Increasing: x^0, x^1, ..., x^(N-1) - out[ io ] = 1.0; - io += do0; - for ( i0 = 1; i0 < S0; i0++ ) { - out[ io ] = out[ io - do0 ] * x[ ix ]; - io += do0; - } - } else { - // Decreasing: x^(N-1), x^(N-2), ..., x^0 - out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; - for ( i0 = S0 - 2; i0 >= 0; i0-- ) { - out[ io + ( i0*do0 ) ] = out[ io + ( (i0+1)*do0 ) ] * x[ ix ]; - } - io += S0 * do0; - } - ix += sx; - io += do1; - } - } else if ( mode > 0 ) { - // Increasing: column j contains x^j - dfill( S0, 1.0, out, do0, io ); - io += ( S0 * do0 ) + do1; - for ( i1 = 1; i1 < S1; i1++ ) { - ix = offsetX; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = out[ io - strideOut2 ] * x[ ix ]; - ix += sx; - io += do0; - } - io += do1; - } - } else { - // Decreasing: column 0 contains x^(N-1), last column all ones - dfill( S0, 1.0, out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); - for ( i1 = S1 - 2; i1 >= 0; i1-- ) { - io = offsetOut + ( i1 * strideOut2 ); - ix = offsetX; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = out[ io + strideOut2 ] * x[ ix ]; - ix += sx; - io += do0; - } - } + if ( M === 0 || N === 0 ) { + return out; } - return out; + + return base( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js index a2288212243d..dd46c2858412 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -22,6 +22,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var addon = require( './../src/addon.node' ); @@ -40,6 +41,9 @@ var addon = require( './../src/addon.node' ); * @param {integer} strideOut1 - stride length for the first dimension of `Out` * @param {integer} strideOut2 - stride length for the second dimension of `Out` * @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero * @returns {Float64Array} output array * * @example @@ -52,6 +56,20 @@ var addon = require( './../src/addon.node' ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + if ( M < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', M ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); + } + + if ( M === 0 || N === 0 ) { + return out; + } + addon.ndarray( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json index 2a3544a8a583..d3baf8619f49 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json @@ -37,6 +37,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/ext/base/dfill", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/strided/base/stride2offset", @@ -59,6 +60,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/ext/base/dfill", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/strided/base/stride2offset" @@ -76,6 +78,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/ext/base/dfill", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/strided/base/stride2offset" diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index 335e8bfda130..a40af64b4fba 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -18,6 +18,7 @@ #include "stdlib/blas/ext/base/dvander.h" #include "stdlib/blas/ext/base/dfill.h" +#include "stdlib/blas/base/xerbla.h" #include "stdlib/ndarray/base/assert/is_row_major.h" #include "stdlib/blas/base/shared.h" #include "stdlib/strided/base/stride2offset.h" @@ -39,6 +40,46 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; + CBLAS_INT k; + CBLAS_INT v; + + if ( order != CblasRowMajor && order != CblasColMajor ) { + c_xerbla( 1, "stdlib_strided_dvander", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", order ); + return; + } + if ( M < 0 ) { + c_xerbla( 3, "stdlib_strided_dvander", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 4, "stdlib_strided_dvander", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 6, "stdlib_strided_dvander", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + + if ( order == CblasColMajor ) { + v = M; + } else { + v = N; + } + + if ( v < 1 ) { + k = 1; + } else { + k = v; + } + + if ( LDO < k ) { + c_xerbla( 8, "stdlib_strided_dvander", "Error: invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.", v, LDO ); + return; + } + + if ( M == 0 || N == 0 ) { + return; + } ox = stdlib_strided_stride2offset( M, strideX ); if ( order == CblasColMajor ) { @@ -78,6 +119,19 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ CBLAS_INT i0; CBLAS_INT i1; + if ( M < 0 ) { + c_xerbla( 2, "stdlib_strided_dvander_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 3, "stdlib_strided_dvander_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "stdlib_strided_dvander_ndarray", "Error: invalid argument. Fifth argument must be nonzero. Value: `%d`.", strideX ); + return; + } + if ( M == 0 || N == 0 ) { return; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js index f838c08ba166..2690acb4ba4d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js @@ -38,6 +38,117 @@ tape( 'the function has an arity of 8', function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( value, -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, value, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, value, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var i; + + values = [ + -3, + -2, + -1, + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), value ); + }; + } +}); + tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { var expected; var out; @@ -176,7 +287,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', function te x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 'row-major', -1, 2, 0, x, 1, out, 0 ); + dvander( 'row-major', -1, 2, 0, x, 1, out, 1 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js index 25276422be6e..ace2d7d8faf3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js @@ -47,6 +47,117 @@ tape( 'the function has an arity of 8', opts, function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( value, -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, value, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', opts, function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, value, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', opts, function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, new Float64Array( 9 ), 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { + var values; + var i; + + values = [ + -3, + -2, + -1, + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float64Array( 9 ), value ); + }; + } +}); + tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { var expected; var out; @@ -185,7 +296,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', opts, funct x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( [] ); - dvander( 'row-major', -1, 2, 0, x, 1, out, 0 ); + dvander( 'row-major', -1, 2, 0, x, 1, out, 1 ); t.deepEqual( out, new Float64Array( [] ), 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js index 8aa7b719ccaa..155ed101fcf2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js @@ -38,6 +38,70 @@ tape( 'the function has an arity of 10', function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, value, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, 3, value, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { var expected; var out; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js index 7c055db39379..b0f74aff7c85 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js @@ -47,6 +47,70 @@ tape( 'the function has an arity of 10', opts, function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid second argument', opts, function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, value, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', opts, function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, 3, value, new Float64Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', opts, function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dvander( -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len + }; + } +}); + tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { var expected; var out; From 791abf2edf98a05dbca8a75c4470d6826d5cfbbf Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 20 Mar 2026 19:45:50 +0500 Subject: [PATCH 05/12] refactor: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 93 ++++++------------- .../blas/ext/base/dvander/docs/repl.txt | 59 +++++++----- .../ext/base/dvander/docs/types/index.d.ts | 36 +++---- .../@stdlib/blas/ext/base/dvander/lib/base.js | 84 +++++++++-------- .../blas/ext/base/dvander/lib/dvander.js | 23 ++--- .../ext/base/dvander/lib/dvander.native.js | 21 ++--- .../blas/ext/base/dvander/lib/ndarray.js | 15 ++- .../ext/base/dvander/lib/ndarray.native.js | 15 ++- .../@stdlib/blas/ext/base/dvander/src/main.c | 78 +++++++++------- .../ext/base/dvander/test/test.dvander.js | 10 +- .../base/dvander/test/test.dvander.native.js | 10 +- .../ext/base/dvander/test/test.ndarray.js | 2 +- .../base/dvander/test/test.ndarray.native.js | 2 +- 13 files changed, 219 insertions(+), 229 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md index 66a12a36e0ba..76c59f2d8efe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -22,6 +22,12 @@ limitations under the License. > Generate a double-precision floating-point Vandermonde matrix. +
+ +
+ + +
## Usage @@ -30,7 +36,7 @@ limitations under the License. var dvander = require( '@stdlib/blas/ext/base/dvander' ); ``` -#### dvander( order, mode, M, N, x, strideX, out, LDO ) +#### dvander( order, mode, M, N, x, strideX, out, ldo ) Generates a double-precision floating-point Vandermonde matrix. @@ -46,45 +52,14 @@ dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); The function has the following parameters: -- **order**: storage layout. -- **mode**: specifies whether columns should contain powers that are increasing (`1`) or decreasing (`-1`). -- **M**: number of rows in `out`. +- **order**: row-major (C-style) or column-major (Fortran-style) order. +- **mode**: mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. +- **M**: number of rows in `out` and number of indexed elements in `x`. - **N**: number of columns in `out`. - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: stride length for `x`. -- **out**: output [`Float64Array`][@stdlib/array/float64]. -- **LDO**: stride length for the leading dimension of `out`. - -The stride parameter determines which elements in the input array are accessed at runtime. For example, to use every other element in `x`, - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); -var out = new Float64Array( 9 ); - -dvander( 'row-major', -1, 3, 3, x, 2, out, 3 ); -// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] -``` - -Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -// Initial array... -var x0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); - -// Create an offset view... -var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - -var out = new Float64Array( 9 ); - -dvander( 'row-major', -1, 3, 3, x1, 1, out, 3 ); -// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] -``` +- **out**: output matrix stored in linear memory as a [`Float64Array`][@stdlib/array/float64]. +- **ldo**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`). @@ -107,22 +82,10 @@ dvander.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); The function has the following additional parameters: - **offsetX**: starting index for `x`. -- **strideOut1**: stride of the first dimension of `out`. -- **strideOut2**: stride of the second dimension of `out`. +- **strideOut1**: stride length for the first dimension of `out`. +- **strideOut2**: stride length for the second dimension of `out`. - **offsetOut**: starting index for `out`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); -var out = new Float64Array( 9 ); - -dvander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 ); -// out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] -``` -
@@ -131,7 +94,7 @@ dvander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 ); ## Notes -- If `M` or `N` is equal to `0`, both functions return `out` unchanged. +- If `M <= 0` or `N <= 0`, both functions return the output matrix unchanged. @@ -206,13 +169,13 @@ stdlib_strided_dvander( CblasRowMajor, -1.0, 3, 3, x, 1, Out, 3 ); The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. -- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. +- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`. - **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **Out**: `[out] double*` output array. -- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `out`. +- **Out**: `[out] double*` output matrix. +- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`). ```c void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); @@ -237,15 +200,15 @@ stdlib_strided_dvander_ndarray( -1.0, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: -- **mode**: `[in] double` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. +- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`. - **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **Out**: `[out] double*` output array. -- **strideOut1**: `[in] CBLAS_INT` stride of the first dimension of `Out`. -- **strideOut2**: `[in] CBLAS_INT` stride of the second dimension of `Out`. +- **Out**: `[out] double*` output matrix. +- **strideOut1**: `[in] CBLAS_INT` stride length for the first dimension of `Out`. +- **strideOut2**: `[in] CBLAS_INT` stride length for the second dimension of `Out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. ```c @@ -306,6 +269,12 @@ int main( void ) { +
+ +
+ + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt index c4e20240f483..cf530f7b9823 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt @@ -1,11 +1,29 @@ -{{alias}}( order, mode, M, N, x, strideX, out, LDO ) +{{alias}}( order, mode, M, N, x, strideX, out, ldo ) Generates a double-precision floating-point Vandermonde matrix. - Indexing is relative to the first index. To introduce an offset, use typed - array views. + When the mode is positive, the matrix is generated such that - If `M` or `N` is equal to `0`, the function returns `out` unchanged. + [ + 1 x_0^1 x_0^2 ... x_0^N + 1 x_1^1 x_1^2 ... x_1^N + ... + ] + + with increasing powers along the rows. + + When the mode is negative, the matrix is generated such that + + [ + x_0^N ... x_0^2 x_0^1 1 + x_1^N ... x_1^2 x_1^1 1 + ... + ] + + with decreasing powers along the rows. + + If `M <= 0` or `N <= 0`, the function returns the output matrix + unchanged. Parameters ---------- @@ -13,11 +31,11 @@ Row-major (C-style) or column-major (Fortran-style) order. mode: number - Specifies whether columns should contain powers that are increasing - (`1`) or decreasing (`-1`). + Mode. If `mode < 0`, the function generates decreasing powers. If + `mode > 0`, the function generates increasing powers. M: integer - Number of rows in `out`. + Number of rows in `out` and number of indexed elements in `x`. N: integer Number of columns in `out`. @@ -29,15 +47,16 @@ Stride length for `x`. out: Float64Array - Output array. + Output matrix. - LDO: integer - Stride length for the leading dimension of `out`. + ldo: integer + Stride of the first dimension of `out` (a.k.a., leading dimension + of the matrix `out`). Returns ------- out: Float64Array - Output array. + Output matrix. Examples -------- @@ -52,18 +71,14 @@ Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. - While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on starting - indices. - Parameters ---------- mode: number - Specifies whether columns should contain powers that are increasing - (`1`) or decreasing (`-1`). + Mode. If `mode < 0`, the function generates decreasing powers. If + `mode > 0`, the function generates increasing powers. M: integer - Number of rows in `out`. + Number of rows in `out` and number of indexed elements in `x`. N: integer Number of columns in `out`. @@ -78,13 +93,13 @@ Starting index for `x`. out: Float64Array - Output array. + Output matrix. so1: integer - Stride of the first dimension of `out`. + Stride length for the first dimension of `out`. so2: integer - Stride of the second dimension of `out`. + Stride length for the second dimension of `out`. oo: integer Starting index for `out`. @@ -92,7 +107,7 @@ Returns ------- out: Float64Array - Output array. + Output matrix. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts index a4909a6bfc94..22af0dd2ee1d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts @@ -30,14 +30,14 @@ interface Routine { * Generates a double-precision floating-point Vandermonde matrix. * * @param order - storage layout - * @param mode - specifies whether columns should contain powers that are increasing or decreasing - * @param M - number of rows in `out` + * @param mode - mode indicating whether to generate increasing or decreasing powers + * @param M - number of rows in `out` and number of indexed elements in `x` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` - * @param out - output array - * @param LDO - stride length for the leading dimension of `Out` - * @returns output array + * @param out - output matrix + * @param ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) + * @returns output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -48,22 +48,22 @@ interface Routine { * dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ - ( order: Layout, mode: number, M: number, N: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array; + ( order: Layout, mode: number, M: number, N: number, x: Float64Array, strideX: number, out: Float64Array, ldo: number ): Float64Array; /** * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * - * @param mode - specifies whether columns should contain powers that are increasing or decreasing - * @param M - number of rows in `out` + * @param mode - mode indicating whether to generate increasing or decreasing powers + * @param M - number of rows in `out` and number of indexed elements in `x` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` - * @param out - output array - * @param strideOut1 - stride of the first dimension of `Out` - * @param strideOut2 - stride of the second dimension of `Out` - * @param offsetOut - starting index for `Out` - * @returns output array + * @param out - output matrix + * @param strideOut1 - stride length for the first dimension of `out` + * @param strideOut2 - stride length for the second dimension of `out` + * @param offsetOut - starting index for `out` + * @returns output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -81,14 +81,14 @@ interface Routine { * Generates a double-precision floating-point Vandermonde matrix. * * @param order - storage layout -* @param mode - specifies whether columns should contain powers that are increasing or decreasing -* @param M - number of rows in `out` +* @param mode - mode indicating whether to generate increasing or decreasing powers +* @param M - number of rows in `out` and number of indexed elements in `x` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` -* @param out - output array -* @param LDO - stride length for the leading dimension of `Out` -* @returns output array +* @param out - output matrix +* @param ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) +* @returns output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js index 8a140b91e654..9e17e188d9c7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js @@ -32,17 +32,17 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * Generates a double-precision floating-point Vandermonde matrix. * * @private -* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in `out` +* @param {integer} mode - mode indicating whether to generate increasing or decreasing powers +* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float64Array} out - output array -* @param {integer} strideOut1 - stride length for the first dimension of `Out` -* @param {integer} strideOut2 - stride length for the second dimension of `Out` -* @param {NonNegativeInteger} offsetOut - starting index for `Out` -* @returns {Float64Array} output array +* @param {Float64Array} out - output matrix +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Float64Array} output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -67,47 +67,52 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... rm = isRowMajor( [ strideOut1, strideOut2 ] ); - - // Extract loop variables for loop interchange... - if ( rm ) { - S0 = N; - S1 = M; - do0 = strideOut2; // offset increment for innermost loop - do1 = strideOut1 - ( S0*strideOut2 ); // offset increment for outermost loop - } else { // order === 'column-major' - S0 = M; - S1 = N; - do0 = strideOut1; // offset increment for innermost loop - do1 = strideOut2 - ( S0*strideOut1 ); // offset increment for outermost loop - } sx = strideX; - io = offsetOut; // For a Vandermonde matrix, each row `i` contains powers of `x[i]`: - if ( rm ) { + if ( rm && mode > 0 ) { + // Row-major, increasing: x^0, x^1, ..., x^(N-1) + S0 = N; + S1 = M; + do0 = strideOut2; + do1 = strideOut1 - ( S0*strideOut2 ); + io = offsetOut; ix = offsetX; for ( i1 = 0; i1 < S1; i1++ ) { - if ( mode > 0 ) { - // Increasing: x^0, x^1, ..., x^(N-1) - out[ io ] = 1.0; + out[ io ] = 1.0; + io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + out[ io ] = out[ io - do0 ] * x[ ix ]; io += do0; - for ( i0 = 1; i0 < S0; i0++ ) { - out[ io ] = out[ io - do0 ] * x[ ix ]; - io += do0; - } - } else { - // Decreasing: x^(N-1), x^(N-2), ..., x^0 - out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; - for ( i0 = S0 - 2; i0 >= 0; i0-- ) { - out[ io + ( i0*do0 ) ] = out[ io + ( (i0+1)*do0 ) ] * x[ ix ]; - } - io += S0 * do0; + } + ix += sx; + io += do1; + } + } else if ( rm ) { + // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 + S0 = N; + S1 = M; + do0 = strideOut2; + do1 = strideOut1 + ( S0*strideOut2 ); + io = offsetOut + ( ( S0-1 ) * do0 ); + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + out[ io ] = 1.0; + io -= do0; + for ( i0 = 1; i0 < S0; i0++ ) { + out[ io ] = out[ io + do0 ] * x[ ix ]; + io -= do0; } ix += sx; io += do1; } } else if ( mode > 0 ) { - // Increasing: column j contains x^j + // Column-major, increasing: column j contains x^j + S0 = M; + S1 = N; + do0 = strideOut1; + do1 = strideOut2 - ( S0*strideOut1 ); + io = offsetOut; dfill( S0, 1.0, out, do0, io ); io += ( S0 * do0 ) + do1; for ( i1 = 1; i1 < S1; i1++ ) { @@ -120,7 +125,10 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, io += do1; } } else { - // Decreasing: column 0 contains x^(N-1), last column all ones + // Column-major, decreasing: column 0 contains x^(N-1), last column all ones + S0 = M; + S1 = N; + do0 = strideOut1; dfill( S0, 1.0, out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); for ( i1 = S1 - 2; i1 >= 0; i1-- ) { io = offsetOut + ( i1 * strideOut2 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js index 01046eeafdda..c684cf9a9b9b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js @@ -34,19 +34,19 @@ var base = require( './base.js' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {string} order - storage layout -* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in `out` +* @param {integer} mode - mode indicating whether to generate increasing or decreasing powers +* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float64Array} out - output array -* @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @param {Float64Array} out - output matrix +* @param {PositiveInteger} ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be a valid stride -* @returns {Float64Array} output array +* @returns {Float64Array} output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -57,7 +57,7 @@ var base = require( './base.js' ); * dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( order, mode, M, N, x, strideX, out, LDO ) { +function dvander( order, mode, M, N, x, strideX, out, ldo ) { var iscm; var sa1; var sa2; @@ -76,18 +76,15 @@ function dvander( order, mode, M, N, x, strideX, out, LDO ) { if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); } - iscm = isColumnMajor( order ); if ( iscm ) { k = M; } else { k = N; } - - if ( LDO < max( 1, k ) ) { - throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, LDO ) ); + if ( ldo < max( 1, k ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, ldo ) ); } - if ( M === 0 || N === 0 ) { return out; } @@ -95,9 +92,9 @@ function dvander( order, mode, M, N, x, strideX, out, LDO ) { ox = stride2offset( M, strideX ); if ( iscm ) { sa1 = 1; - sa2 = LDO; + sa2 = ldo; } else { // order === 'row-major' - sa1 = LDO; + sa1 = ldo; sa2 = 1; } return base( mode, M, N, x, strideX, ox, out, sa1, sa2, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js index 2d7aba3538f6..35b5996bcedc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -34,19 +34,19 @@ var addon = require( './../src/addon.node' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {string} order - storage layout -* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in `out` +* @param {integer} mode - mode indicating whether to generate increasing or decreasing powers +* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float64Array} out - output array -* @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @param {Float64Array} out - output matrix +* @param {PositiveInteger} ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be a valid stride -* @returns {Float64Array} output array +* @returns {Float64Array} output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -57,7 +57,7 @@ var addon = require( './../src/addon.node' ); * dvander( 'row-major', -1, 3, 3, x, 1, out, 3 ); * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ -function dvander( order, mode, M, N, x, strideX, out, LDO ) { +function dvander( order, mode, M, N, x, strideX, out, ldo ) { var k; if ( !isLayout( order ) ) { @@ -72,22 +72,19 @@ function dvander( order, mode, M, N, x, strideX, out, LDO ) { if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); } - if ( isColumnMajor( order ) ) { k = M; } else { k = N; } - - if ( LDO < max( 1, k ) ) { - throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, LDO ) ); + if ( ldo < max( 1, k ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', k, ldo ) ); } - if ( M === 0 || N === 0 ) { return out; } - addon( resolve( order ), mode, M, N, x, strideX, out, LDO ); + addon( resolve( order ), mode, M, N, x, strideX, out, ldo ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js index 20df802c60d7..e8499542c5a3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -31,20 +31,20 @@ var base = require( './base.js' ); /** * Generates a double-precision floating-point Vandermonde matrix. * -* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in `out` +* @param {integer} mode - mode indicating whether to generate increasing or decreasing powers +* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float64Array} out - output array -* @param {integer} strideOut1 - stride length for the first dimension of `Out` -* @param {integer} strideOut2 - stride length for the second dimension of `Out` -* @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @param {Float64Array} out - output matrix +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` * @throws {RangeError} second argument must be a nonnegative integer * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fifth argument must be non-zero -* @returns {Float64Array} output array +* @returns {Float64Array} output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -65,7 +65,6 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); } - if ( M === 0 || N === 0 ) { return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js index dd46c2858412..314a39272e94 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -31,20 +31,20 @@ var addon = require( './../src/addon.node' ); /** * Generates a double-precision floating-point Vandermonde matrix. * -* @param {integer} mode - specifies whether columns should contain powers that are increasing or decreasing -* @param {NonNegativeInteger} M - number of rows in `out` +* @param {integer} mode - mode indicating whether to generate increasing or decreasing powers +* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float64Array} out - output array -* @param {integer} strideOut1 - stride length for the first dimension of `Out` -* @param {integer} strideOut2 - stride length for the second dimension of `Out` -* @param {NonNegativeInteger} offsetOut - starting index for `Out` +* @param {Float64Array} out - output matrix +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` * @throws {RangeError} second argument must be a nonnegative integer * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fifth argument must be non-zero -* @returns {Float64Array} output array +* @returns {Float64Array} output matrix * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -65,7 +65,6 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); } - if ( M === 0 || N === 0 ) { return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index a40af64b4fba..828cd30e15b1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -29,12 +29,12 @@ * * @param order storage layout * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in `out` -* @param N number of columns in `out` +* @param M number of rows in `Out` and number of indexed elements in `X` +* @param N number of columns in `Out` * @param X input array * @param strideX stride length for `X` -* @param Out output array -* @param LDO stride length for the leading dimension of `Out` +* @param Out output matrix +* @param LDO stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) */ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ) { CBLAS_INT sa1; @@ -96,12 +96,12 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in `out` -* @param N number of columns in `out` +* @param M number of rows in `Out` and number of indexed elements in `X` +* @param N number of columns in `Out` * @param X input array * @param strideX stride length for `X` * @param offsetX starting index for `X` -* @param Out output array +* @param Out output matrix * @param strideOut1 stride length for the first dimension of `Out` * @param strideOut2 stride length for the second dimension of `Out` * @param offsetOut starting index for `Out` @@ -144,46 +144,51 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ } else { rm = 0; } + sx = strideX; - // Extract loop variables for loop interchange... - if ( rm ) { + if ( rm && mode > 0 ) { + // Row-major, increasing: x^0, x^1, ..., x^(N-1) S0 = N; S1 = M; do0 = strideOut2; do1 = strideOut1 - ( S0 * strideOut2 ); - } else { - S0 = M; - S1 = N; - do0 = strideOut1; - do1 = strideOut2 - ( S0 * strideOut1 ); - } - sx = strideX; - io = offsetOut; - - if ( rm ) { + io = offsetOut; ix = offsetX; for ( i1 = 0; i1 < S1; i1++ ) { - if ( mode > 0 ) { - // Increasing: x^0, x^1, ..., x^(N-1) - Out[ io ] = 1.0; + Out[ io ] = 1.0; + io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + Out[ io ] = Out[ io - do0 ] * X[ ix ]; io += do0; - for ( i0 = 1; i0 < S0; i0++ ) { - Out[ io ] = Out[ io - do0 ] * X[ ix ]; - io += do0; - } - } else { - // Decreasing: x^(N-1), x^(N-2), ..., x^0 - Out[ io + ( ( S0-1 ) * do0 ) ] = 1.0; - for ( i0 = S0 - 2; i0 >= 0; i0-- ) { - Out[ io + ( i0*do0 ) ] = Out[ io + ( (i0+1)*do0 ) ] * X[ ix ]; - } - io += S0 * do0; + } + ix += sx; + io += do1; + } + } else if ( rm ) { + // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 + S0 = N; + S1 = M; + do0 = strideOut2; + do1 = strideOut1 + ( S0 * strideOut2 ); + io = offsetOut + ( ( S0-1 ) * do0 ); + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + Out[ io ] = 1.0; + io -= do0; + for ( i0 = 1; i0 < S0; i0++ ) { + Out[ io ] = Out[ io + do0 ] * X[ ix ]; + io -= do0; } ix += sx; io += do1; } } else if ( mode > 0 ) { - // Increasing: column j contains x^j + // Column-major, increasing: column j contains x^j + S0 = M; + S1 = N; + do0 = strideOut1; + do1 = strideOut2 - ( S0 * strideOut1 ); + io = offsetOut; API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, io ); io += ( S0 * do0 ) + do1; for ( i1 = 1; i1 < S1; i1++ ) { @@ -196,7 +201,10 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ io += do1; } } else { - // Decreasing: column 0 contains x^(N-1), last column all ones + // Column-major, decreasing: column 0 contains x^(N-1), last column all ones + S0 = M; + S1 = N; + do0 = strideOut1; API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); for ( i1 = S1 - 2; i1 >= 0; i1-- ) { io = offsetOut + ( i1 * strideOut2 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js index 2690acb4ba4d..f9d3938426be 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js @@ -253,7 +253,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', t.end(); }); -tape( 'the function returns the output array', function test( t ) { +tape( 'the function returns the output matrix', function test( t ) { var out; var x; var v; @@ -363,7 +363,7 @@ tape( 'the function supports specifying a negative stride (column-major)', funct t.end(); }); -tape( 'the function supports an `LDO` larger than the matrix dimension (row-major)', function test( t ) { +tape( 'the function supports an `ldo` larger than the matrix dimension (row-major)', function test( t ) { var expected; var out; var x; @@ -371,7 +371,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 10 ); - // 2x3 row-major with LDO=5 (padding of 2 per row) + // 2x3 row-major with ldo=5 (padding of 2 per row) dvander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float64Array([ @@ -391,7 +391,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo t.end(); }); -tape( 'the function supports an `LDO` larger than the matrix dimension (column-major)', function test( t ) { +tape( 'the function supports an `ldo` larger than the matrix dimension (column-major)', function test( t ) { var expected; var out; var x; @@ -399,7 +399,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 12 ); - // 2x3 column-major with LDO=4 (padding of 2 per column) + // 2x3 column-major with ldo=4 (padding of 2 per column) dvander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float64Array([ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js index ace2d7d8faf3..ed0011744122 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js @@ -262,7 +262,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', t.end(); }); -tape( 'the function returns the output array', opts, function test( t ) { +tape( 'the function returns the output matrix', opts, function test( t ) { var out; var x; var v; @@ -372,7 +372,7 @@ tape( 'the function supports specifying a negative stride (column-major)', opts, t.end(); }); -tape( 'the function supports an `LDO` larger than the matrix dimension (row-major)', opts, function test( t ) { +tape( 'the function supports an `ldo` larger than the matrix dimension (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -380,7 +380,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 10 ); - // 2x3 row-major with LDO=5 (padding of 2 per row) + // 2x3 row-major with ldo=5 (padding of 2 per row) dvander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float64Array([ @@ -400,7 +400,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo t.end(); }); -tape( 'the function supports an `LDO` larger than the matrix dimension (column-major)', opts, function test( t ) { +tape( 'the function supports an `ldo` larger than the matrix dimension (column-major)', opts, function test( t ) { var expected; var out; var x; @@ -408,7 +408,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m x = new Float64Array( [ 1.0, 2.0 ] ); out = new Float64Array( 12 ); - // 2x3 column-major with LDO=4 (padding of 2 per column) + // 2x3 column-major with ldo=4 (padding of 2 per column) dvander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float64Array([ diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js index 155ed101fcf2..a045f133074c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js @@ -208,7 +208,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', t.end(); }); -tape( 'the function returns the output array', function test( t ) { +tape( 'the function returns the output matrix', function test( t ) { var out; var x; var v; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js index b0f74aff7c85..388c77fb6f31 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js @@ -215,7 +215,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', t.end(); }); -tape( 'the function returns the output array', opts, function test( t ) { +tape( 'the function returns the output matrix', opts, function test( t ) { var out; var x; var v; From fb19b1a731e59d116a19c7f74a672cce4c85c431 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 22 Mar 2026 21:41:57 +0500 Subject: [PATCH 06/12] refactor: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/lib/base.js | 16 +++++++--------- .../@stdlib/blas/ext/base/dvander/src/main.c | 17 ++++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js index 9e17e188d9c7..5039298a8a54 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js @@ -54,9 +54,9 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { + var isrm; var do0; var do1; - var rm; var S0; var S1; var sx; @@ -66,11 +66,10 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, var i1; // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... - rm = isRowMajor( [ strideOut1, strideOut2 ] ); + isrm = isRowMajor( [ strideOut1, strideOut2 ] ); sx = strideX; - // For a Vandermonde matrix, each row `i` contains powers of `x[i]`: - if ( rm && mode > 0 ) { + if ( isrm && mode > 0 ) { // Row-major, increasing: x^0, x^1, ..., x^(N-1) S0 = N; S1 = M; @@ -88,7 +87,7 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, ix += sx; io += do1; } - } else if ( rm ) { + } else if ( isrm ) { // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 S0 = N; S1 = M; @@ -114,7 +113,7 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, do1 = strideOut2 - ( S0*strideOut1 ); io = offsetOut; dfill( S0, 1.0, out, do0, io ); - io += ( S0 * do0 ) + do1; + io += strideOut2; for ( i1 = 1; i1 < S1; i1++ ) { ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { @@ -128,15 +127,14 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, // Column-major, decreasing: column 0 contains x^(N-1), last column all ones S0 = M; S1 = N; - do0 = strideOut1; - dfill( S0, 1.0, out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + dfill( S0, 1.0, out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); for ( i1 = S1 - 2; i1 >= 0; i1-- ) { io = offsetOut + ( i1 * strideOut2 ); ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { out[ io ] = out[ io + strideOut2 ] * x[ ix ]; ix += sx; - io += do0; + io += strideOut1; } } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index 828cd30e15b1..35798097cb62 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -108,9 +108,9 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double */ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { int64_t sa[ 2 ]; + CBLAS_INT isrm; CBLAS_INT do0; CBLAS_INT do1; - CBLAS_INT rm; CBLAS_INT S0; CBLAS_INT S1; CBLAS_INT sx; @@ -140,13 +140,13 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ sa[ 0 ] = strideOut1; sa[ 1 ] = strideOut2; if ( stdlib_ndarray_is_row_major( 2, sa ) ) { - rm = 1; + isrm = 1; } else { - rm = 0; + isrm = 0; } sx = strideX; - if ( rm && mode > 0 ) { + if ( isrm && mode > 0 ) { // Row-major, increasing: x^0, x^1, ..., x^(N-1) S0 = N; S1 = M; @@ -164,7 +164,7 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ ix += sx; io += do1; } - } else if ( rm ) { + } else if ( isrm ) { // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 S0 = N; S1 = M; @@ -190,7 +190,7 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ do1 = strideOut2 - ( S0 * strideOut1 ); io = offsetOut; API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, io ); - io += ( S0 * do0 ) + do1; + io += strideOut2; for ( i1 = 1; i1 < S1; i1++ ) { ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { @@ -204,15 +204,14 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ // Column-major, decreasing: column 0 contains x^(N-1), last column all ones S0 = M; S1 = N; - do0 = strideOut1; - API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); for ( i1 = S1 - 2; i1 >= 0; i1-- ) { io = offsetOut + ( i1 * strideOut2 ); ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { Out[ io ] = Out[ io + strideOut2 ] * X[ ix ]; ix += sx; - io += do0; + io += strideOut1; } } } From a458ee9d92f57080b1dd952af6a1f4dd0c682ef5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 15 Apr 2026 16:07:39 +0500 Subject: [PATCH 07/12] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 34 +++- .../ext/base/dvander/benchmark/benchmark.js | 29 ++-- .../dvander/benchmark/benchmark.native.js | 29 ++-- .../dvander/benchmark/benchmark.ndarray.js | 29 ++-- .../benchmark/benchmark.ndarray.native.js | 29 ++-- .../dvander/benchmark/c/benchmark.length.c | 8 +- .../blas/ext/base/dvander/docs/repl.txt | 40 +++-- .../ext/base/dvander/docs/types/index.d.ts | 10 +- .../blas/ext/base/dvander/docs/types/test.ts | 3 +- .../@stdlib/blas/ext/base/dvander/lib/base.js | 106 ++++++------ .../blas/ext/base/dvander/lib/dvander.js | 9 +- .../ext/base/dvander/lib/dvander.native.js | 9 +- .../blas/ext/base/dvander/lib/ndarray.js | 7 +- .../ext/base/dvander/lib/ndarray.native.js | 7 +- .../blas/ext/base/dvander/package.json | 3 +- .../@stdlib/blas/ext/base/dvander/src/main.c | 21 +-- .../ext/base/dvander/test/test.dvander.js | 114 ++++++++++--- .../base/dvander/test/test.dvander.native.js | 114 ++++++++++--- .../ext/base/dvander/test/test.ndarray.js | 154 +++++++++++++++--- .../base/dvander/test/test.ndarray.native.js | 154 +++++++++++++++--- 20 files changed, 614 insertions(+), 295 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md index 76c59f2d8efe..636a3349f188 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -54,12 +54,36 @@ The function has the following parameters: - **order**: row-major (C-style) or column-major (Fortran-style) order. - **mode**: mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. -- **M**: number of rows in `out` and number of indexed elements in `x`. +- **M**: number of rows in `out`. - **N**: number of columns in `out`. - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: stride length for `x`. - **out**: output matrix stored in linear memory as a [`Float64Array`][@stdlib/array/float64]. -- **ldo**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`). +- **ldo**: stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`). + +When the mode is positive, the matrix is generated such that + +```text +[ + 1 x_0^1 x_0^2 ... x_0^(N-1) + 1 x_1^1 x_1^2 ... x_1^(N-1) + ... +] +``` + +with increasing powers along the rows. + +When the mode is negative, the matrix is generated such that + +```text +[ + x_0^(N-1) ... x_0^2 x_0^1 1 + x_1^(N-1) ... x_1^2 x_1^1 1 + ... +] +``` + +with decreasing powers along the rows. @@ -170,12 +194,12 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. -- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`. +- **M**: `[in] CBLAS_INT` number of rows in `Out`. - **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Out**: `[out] double*` output matrix. -- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`). +- **LDO**: `[in] CBLAS_INT` stride between successive contiguous vectors of the matrix `Out` (a.k.a., leading dimension of the matrix `Out`). ```c void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ); @@ -201,7 +225,7 @@ stdlib_strided_dvander_ndarray( -1.0, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: - **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. -- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`. +- **M**: `[in] CBLAS_INT` number of rows in `Out`. - **N**: `[in] CBLAS_INT` number of columns in `Out`. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js index 1b6e6e555353..eb1532ea6f7f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.js @@ -22,10 +22,9 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); +var zeros = require( '@stdlib/array/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var dvander = require( './../lib/dvander.js' ); @@ -44,15 +43,12 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark( N ) { - var out; - var x; - - x = uniform( N, -10.0, 10.0, options ); - out = zeros( N*N, 'float64' ); +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var x = uniform( len, -10, 10, options ); return benchmark; /** @@ -62,18 +58,19 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; + var v; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( 'row-major', -1, N, N, x, 1, out, N ); - if ( isnan( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = dvander( 'row-major', 1, len, len, x, 1, out, len ); + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -97,12 +94,12 @@ function main() { var i; min = 1; // 10^min - max = 6; // 10^max + max = 3; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s:size=%d', pkg, len*len ), f ); + bench( format( '%s:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js index ccba26f3627f..bb57a7222fb6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.native.js @@ -23,10 +23,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); +var zeros = require( '@stdlib/array/zeros' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -49,15 +48,12 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark( N ) { - var out; - var x; - - x = uniform( N, -10.0, 10.0, options ); - out = zeros( N*N, 'float64' ); +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var x = uniform( len, -10, 10, options ); return benchmark; /** @@ -67,18 +63,19 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; + var v; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( 'row-major', -1, N, N, x, 1, out, N ); - if ( isnan( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = dvander( 'row-major', 1, len, len, x, 1, out, len ); + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -102,12 +99,12 @@ function main() { var i; min = 1; // 10^min - max = 6; // 10^max + max = 3; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s::native:size=%d', pkg, len*len ), opts, f ); + bench( format( '%s::native:len=%d', pkg, len ), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js index f6246188b76c..df718a5c5e3f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.js @@ -22,10 +22,9 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); +var zeros = require( '@stdlib/array/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var dvander = require( './../lib/ndarray.js' ); @@ -44,15 +43,12 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark( N ) { - var out; - var x; - - x = uniform( N, -10.0, 10.0, options ); - out = zeros( N*N, 'float64' ); +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var x = uniform( len, -10, 10, options ); return benchmark; /** @@ -62,18 +58,19 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; + var v; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 ); - if ( isnan( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = dvander( 1, len, len, x, 1, 0, out, len, 1, 0 ); + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -97,12 +94,12 @@ function main() { var i; min = 1; // 10^min - max = 6; // 10^max + max = 3; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s:ndarray:size=%d', pkg, len*len ), f ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js index 0d026d96ccd7..d9d93fe63238 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/benchmark.ndarray.native.js @@ -23,10 +23,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); -var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); +var zeros = require( '@stdlib/array/zeros' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -49,15 +48,12 @@ var options = { * Creates a benchmark function. * * @private -* @param {PositiveInteger} N - array dimension size +* @param {PositiveInteger} len - array length * @returns {Function} benchmark function */ -function createBenchmark( N ) { - var out; - var x; - - x = uniform( N, -10.0, 10.0, options ); - out = zeros( N*N, 'float64' ); +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var x = uniform( len, -10, 10, options ); return benchmark; /** @@ -67,18 +63,19 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; + var v; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 ); - if ( isnan( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = dvander( 1, len, len, x, 1, 0, out, len, 1, 0 ); + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -102,12 +99,12 @@ function main() { var i; min = 1; // 10^min - max = 6; // 10^max + max = 3; // 10^max for ( i = min; i <= max; i++ ) { - len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s::native:ndarray:size=%d', pkg, len*len ), opts, f ); + bench( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c index edb0a1a71472..8281151f96aa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -110,7 +110,7 @@ static double benchmark1( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - stdlib_strided_dvander( CblasRowMajor, -1.0, len, len, x, 1, out, len ); + stdlib_strided_dvander( CblasRowMajor, 1.0, len, len, x, 1, out, len ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -147,7 +147,7 @@ static double benchmark2( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - stdlib_strided_dvander_ndarray( -1.0, len, len, x, 1, 0, out, len, 1, 0 ); + stdlib_strided_dvander_ndarray( 1.0, len, len, x, 1, 0, out, len, 1, 0 ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -179,7 +179,7 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = (int)sqrt( pow( 10, i ) ); + len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; @@ -190,7 +190,7 @@ int main( void ) { } } for ( i = MIN; i <= MAX; i++ ) { - len = (int)sqrt( pow( 10, i ) ); + len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt index cf530f7b9823..2408fecaad58 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/repl.txt @@ -5,8 +5,8 @@ When the mode is positive, the matrix is generated such that [ - 1 x_0^1 x_0^2 ... x_0^N - 1 x_1^1 x_1^2 ... x_1^N + 1 x_0^1 x_0^2 ... x_0^(N-1) + 1 x_1^1 x_1^2 ... x_1^(N-1) ... ] @@ -15,27 +15,26 @@ When the mode is negative, the matrix is generated such that [ - x_0^N ... x_0^2 x_0^1 1 - x_1^N ... x_1^2 x_1^1 1 + x_0^(N-1) ... x_0^2 x_0^1 1 + x_1^(N-1) ... x_1^2 x_1^1 1 ... ] with decreasing powers along the rows. - If `M <= 0` or `N <= 0`, the function returns the output matrix - unchanged. + If `M <= 0` or `N <= 0`, the function returns the output matrix unchanged. Parameters ---------- order: string Row-major (C-style) or column-major (Fortran-style) order. - mode: number + mode: integer Mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. M: integer - Number of rows in `out` and number of indexed elements in `x`. + Number of rows in `out`. N: integer Number of columns in `out`. @@ -50,8 +49,8 @@ Output matrix. ldo: integer - Stride of the first dimension of `out` (a.k.a., leading dimension - of the matrix `out`). + Stride between successive contiguous vectors of the matrix `out` + (a.k.a., leading dimension of the matrix `out`). Returns ------- @@ -63,6 +62,12 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}( 'row-major', 1, 3, 3, x, 1, out, 3 ) + [ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] + + // Decreasing mode: + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); + > out = new {{alias:@stdlib/array/float64}}( 9 ); > {{alias}}( 'row-major', -1, 3, 3, x, 1, out, 3 ) [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] @@ -73,12 +78,12 @@ Parameters ---------- - mode: number + mode: integer Mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers. M: integer - Number of rows in `out` and number of indexed elements in `x`. + Number of rows in `out`. N: integer Number of columns in `out`. @@ -114,8 +119,15 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float64}}( 9 ); - > {{alias}}.ndarray( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ) - [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] + > {{alias}}.ndarray( 1, 3, 3, x, 1, 0, out, 3, 1, 0 ) + [ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] + + // Advanced indexing: + > x = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ] ); + > out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}.ndarray( 1, 3, 3, x, 2, 1, out, 3, 1, 0 ) + [ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] See Also -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts index 22af0dd2ee1d..06143774066d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/index.d.ts @@ -31,12 +31,12 @@ interface Routine { * * @param order - storage layout * @param mode - mode indicating whether to generate increasing or decreasing powers - * @param M - number of rows in `out` and number of indexed elements in `x` + * @param M - number of rows in `out` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param out - output matrix - * @param ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) + * @param ldo - stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`) * @returns output matrix * * @example @@ -54,7 +54,7 @@ interface Routine { * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode - mode indicating whether to generate increasing or decreasing powers - * @param M - number of rows in `out` and number of indexed elements in `x` + * @param M - number of rows in `out` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` @@ -82,12 +82,12 @@ interface Routine { * * @param order - storage layout * @param mode - mode indicating whether to generate increasing or decreasing powers -* @param M - number of rows in `out` and number of indexed elements in `x` +* @param M - number of rows in `out` * @param N - number of columns in `out` * @param x - input array * @param strideX - stride length for `x` * @param out - output matrix -* @param ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) +* @param ldo - stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`) * @returns output matrix * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts index d99b01fc104d..22f18f6d47f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/docs/types/test.ts @@ -29,11 +29,12 @@ import dvander = require( './index' ); dvander( 'row-major', -1, 10, 10, x, 1, out, 10 ); // $ExpectType Float64Array } -// The compiler throws an error if the function is provided a first argument which is not a string... +// The compiler throws an error if the function is provided a first argument which is not a valid order... { const x = new Float64Array( 10 ); const out = new Float64Array( 100 ); + dvander( '10', -1, 10, 10, x, 1, out, 10 ); // $ExpectError dvander( 10, -1, 10, 10, x, 1, out, 10 ); // $ExpectError dvander( true, -1, 10, 10, x, 1, out, 10 ); // $ExpectError dvander( false, -1, 10, 10, x, 1, out, 10 ); // $ExpectError diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js index 5039298a8a54..b5d735adb41a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/base.js @@ -31,9 +31,13 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; /** * Generates a double-precision floating-point Vandermonde matrix. * +* ## Notes +* +* - The implementation uses recursive multiplication to generate successive powers, which carries risk of additional accumulated floating-point error; however, for most use cases, such additional error should be negligible and not problematic. +* * @private * @param {integer} mode - mode indicating whether to generate increasing or decreasing powers -* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` +* @param {NonNegativeInteger} M - number of rows in `out` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` @@ -54,89 +58,85 @@ var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { - var isrm; var do0; var do1; var S0; var S1; - var sx; var io; var ix; var i0; var i1; // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... - isrm = isRowMajor( [ strideOut1, strideOut2 ] ); - sx = strideX; - - if ( isrm && mode > 0 ) { - // Row-major, increasing: x^0, x^1, ..., x^(N-1) + if ( isRowMajor( [ strideOut1, strideOut2 ] ) ) { S0 = N; S1 = M; do0 = strideOut2; do1 = strideOut1 - ( S0*strideOut2 ); - io = offsetOut; - ix = offsetX; - for ( i1 = 0; i1 < S1; i1++ ) { - out[ io ] = 1.0; - io += do0; - for ( i0 = 1; i0 < S0; i0++ ) { - out[ io ] = out[ io - do0 ] * x[ ix ]; + + // Increasing: x^0, x^1, ..., x^(N-1) + if ( mode > 0 ) { + io = offsetOut; + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + out[ io ] = 1.0; io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + out[ io ] = out[ io-do0 ] * x[ ix ]; + io += do0; + } + ix += strideX; + io += do1; } - ix += sx; - io += do1; + return out; } - } else if ( isrm ) { - // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 - S0 = N; - S1 = M; - do0 = strideOut2; - do1 = strideOut1 + ( S0*strideOut2 ); - io = offsetOut + ( ( S0-1 ) * do0 ); - ix = offsetX; - for ( i1 = 0; i1 < S1; i1++ ) { + // Decreasing: x^(N-1), x^(N-2), ..., x^0 + io = offsetOut + ( ( S1-1 ) * strideOut1 ) + ( ( S0-1 ) * strideOut2 ); + ix = offsetX + ( ( S1-1 ) * strideX ); + for ( i1 = S1-1; i1 >= 0; i1-- ) { out[ io ] = 1.0; io -= do0; for ( i0 = 1; i0 < S0; i0++ ) { - out[ io ] = out[ io + do0 ] * x[ ix ]; + out[ io ] = out[ io+do0 ] * x[ ix ]; io -= do0; } - ix += sx; - io += do1; + ix -= strideX; + io -= do1; } - } else if ( mode > 0 ) { - // Column-major, increasing: column j contains x^j - S0 = M; - S1 = N; - do0 = strideOut1; - do1 = strideOut2 - ( S0*strideOut1 ); - io = offsetOut; - dfill( S0, 1.0, out, do0, io ); - io += strideOut2; + return out; + } + // Column-major... + S0 = M; + S1 = N; + do0 = strideOut1; + do1 = strideOut2 - ( S0*strideOut1 ); + + // Increasing: column j contains x^j + if ( mode > 0 ) { + dfill( S0, 1.0, out, strideOut1, offsetOut ); + io = offsetOut + strideOut2; for ( i1 = 1; i1 < S1; i1++ ) { ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = out[ io - strideOut2 ] * x[ ix ]; - ix += sx; + out[ io ] = out[ io-strideOut2 ] * x[ ix ]; + ix += strideX; io += do0; } io += do1; } - } else { - // Column-major, decreasing: column 0 contains x^(N-1), last column all ones - S0 = M; - S1 = N; - dfill( S0, 1.0, out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); - for ( i1 = S1 - 2; i1 >= 0; i1-- ) { - io = offsetOut + ( i1 * strideOut2 ); - ix = offsetX; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = out[ io + strideOut2 ] * x[ ix ]; - ix += sx; - io += strideOut1; - } + return out; + } + // Decreasing: column 0 contains x^(N-1), last column all ones + dfill( S0, 1.0, out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + io = offsetOut + ( ( S1-2 ) * strideOut2 ) + ( ( S0-1 ) * strideOut1 ); + for ( i1 = S1-2; i1 >= 0; i1-- ) { + ix = offsetX + ( ( S0-1 ) * strideX ); + for ( i0 = S0-1; i0 >= 0; i0-- ) { + out[ io ] = out[ io+strideOut2 ] * x[ ix ]; + ix -= strideX; + io -= do0; } + io -= do1; } return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js index c684cf9a9b9b..ca8396423053 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.js @@ -35,16 +35,15 @@ var base = require( './base.js' ); * * @param {string} order - storage layout * @param {integer} mode - mode indicating whether to generate increasing or decreasing powers -* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` +* @param {NonNegativeInteger} M - number of rows in `out` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output matrix -* @param {PositiveInteger} ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) +* @param {PositiveInteger} ldo - stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} output matrix * @@ -73,9 +72,6 @@ function dvander( order, mode, M, N, x, strideX, out, ldo ) { if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } - if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); - } iscm = isColumnMajor( order ); if ( iscm ) { k = M; @@ -88,7 +84,6 @@ function dvander( order, mode, M, N, x, strideX, out, ldo ) { if ( M === 0 || N === 0 ) { return out; } - ox = stride2offset( M, strideX ); if ( iscm ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js index 35b5996bcedc..c74853d70ba8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/dvander.native.js @@ -35,16 +35,15 @@ var addon = require( './../src/addon.node' ); * * @param {string} order - storage layout * @param {integer} mode - mode indicating whether to generate increasing or decreasing powers -* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` +* @param {NonNegativeInteger} M - number of rows in `out` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float64Array} out - output matrix -* @param {PositiveInteger} ldo - stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`) +* @param {PositiveInteger} ldo - stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be a valid stride * @returns {Float64Array} output matrix * @@ -69,9 +68,6 @@ function dvander( order, mode, M, N, x, strideX, out, ldo ) { if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', N ) ); } - if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); - } if ( isColumnMajor( order ) ) { k = M; } else { @@ -83,7 +79,6 @@ function dvander( order, mode, M, N, x, strideX, out, ldo ) { if ( M === 0 || N === 0 ) { return out; } - addon( resolve( order ), mode, M, N, x, strideX, out, ldo ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js index e8499542c5a3..5031d66b6673 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.js @@ -32,7 +32,7 @@ var base = require( './base.js' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {integer} mode - mode indicating whether to generate increasing or decreasing powers -* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` +* @param {NonNegativeInteger} M - number of rows in `out` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` @@ -43,7 +43,6 @@ var base = require( './base.js' ); * @param {NonNegativeInteger} offsetOut - starting index for `out` * @throws {RangeError} second argument must be a nonnegative integer * @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} fifth argument must be non-zero * @returns {Float64Array} output matrix * * @example @@ -62,13 +61,9 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); } - if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); - } if ( M === 0 || N === 0 ) { return out; } - return base( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js index 314a39272e94..f9b19df8c1e5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * Generates a double-precision floating-point Vandermonde matrix. * * @param {integer} mode - mode indicating whether to generate increasing or decreasing powers -* @param {NonNegativeInteger} M - number of rows in `out` and number of indexed elements in `x` +* @param {NonNegativeInteger} M - number of rows in `out` * @param {NonNegativeInteger} N - number of columns in `out` * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` @@ -43,7 +43,6 @@ var addon = require( './../src/addon.node' ); * @param {NonNegativeInteger} offsetOut - starting index for `out` * @throws {RangeError} second argument must be a nonnegative integer * @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} fifth argument must be non-zero * @returns {Float64Array} output matrix * * @example @@ -62,13 +61,9 @@ function dvander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); } - if ( strideX === 0 ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); - } if ( M === 0 || N === 0 ) { return out; } - addon.ndarray( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json b/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json index e0c9d1a30afb..5110693d018f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/package.json @@ -70,5 +70,6 @@ "float", "double", "float64array" - ] + ], + "__stdlib__": {} } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index 35798097cb62..cd24dca59333 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -29,12 +29,12 @@ * * @param order storage layout * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in `Out` and number of indexed elements in `X` +* @param M number of rows in `Out` * @param N number of columns in `Out` * @param X input array * @param strideX stride length for `X` * @param Out output matrix -* @param LDO stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`) +* @param LDO stride between successive contiguous vectors of the matrix `Out` (a.k.a., leading dimension of the matrix `Out`) */ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO ) { CBLAS_INT sa1; @@ -55,32 +55,23 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double c_xerbla( 4, "stdlib_strided_dvander", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( strideX == 0 ) { - c_xerbla( 6, "stdlib_strided_dvander", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); - return; - } - if ( order == CblasColMajor ) { v = M; } else { v = N; } - if ( v < 1 ) { k = 1; } else { k = v; } - if ( LDO < k ) { c_xerbla( 8, "stdlib_strided_dvander", "Error: invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.", v, LDO ); return; } - if ( M == 0 || N == 0 ) { return; } - ox = stdlib_strided_stride2offset( M, strideX ); if ( order == CblasColMajor ) { sa1 = 1; @@ -96,7 +87,7 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double * Generates a double-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode specifies whether powers are increasing (1) or decreasing (-1) -* @param M number of rows in `Out` and number of indexed elements in `X` +* @param M number of rows in `Out` * @param N number of columns in `Out` * @param X input array * @param strideX stride length for `X` @@ -127,11 +118,6 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ c_xerbla( 3, "stdlib_strided_dvander_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( strideX == 0 ) { - c_xerbla( 5, "stdlib_strided_dvander_ndarray", "Error: invalid argument. Fifth argument must be nonzero. Value: `%d`.", strideX ); - return; - } - if ( M == 0 || N == 0 ) { return; } @@ -145,7 +131,6 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ isrm = 0; } sx = strideX; - if ( isrm && mode > 0 ) { // Row-major, increasing: x^0, x^1, ..., x^(N-1) S0 = N; diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js index f9d3938426be..f69c546a7e38 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.js @@ -105,26 +105,6 @@ tape( 'the function throws an error if provided an invalid fourth argument', fun } }); -tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { - var values; - var i; - - values = [ - 0 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, new Float64Array( 9 ), 3 ); - }; - } -}); - tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { var values; var i; @@ -267,7 +247,7 @@ tape( 'the function returns the output matrix', function test( t ) { t.end(); }); -tape( 'if provided an `M` equal to `0`, the function early returns', function test( t ) { +tape( 'if provided an `M` equal to `0`, the function returns the output matrix unchanged', function test( t ) { var out; var x; @@ -280,7 +260,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', function te t.end(); }); -tape( 'if provided an `N` equal to `0`, the function early returns', function test( t ) { +tape( 'if provided an `N` equal to `0`, the function returns the output matrix unchanged', function test( t ) { var out; var x; @@ -293,7 +273,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', function te t.end(); }); -tape( 'the function supports specifying a stride (row-major)', function test( t ) { +tape( 'the function supports specifying a stride for `x` (row-major)', function test( t ) { var expected; var out; var x; @@ -310,7 +290,7 @@ tape( 'the function supports specifying a stride (row-major)', function test( t t.end(); }); -tape( 'the function supports specifying a negative stride (row-major)', function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (row-major)', function test( t ) { var expected; var out; var x; @@ -328,7 +308,7 @@ tape( 'the function supports specifying a negative stride (row-major)', function t.end(); }); -tape( 'the function supports specifying a stride (column-major)', function test( t ) { +tape( 'the function supports specifying a stride for `x` (column-major)', function test( t ) { var expected; var out; var x; @@ -345,7 +325,7 @@ tape( 'the function supports specifying a stride (column-major)', function test( t.end(); }); -tape( 'the function supports specifying a negative stride (column-major)', function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (column-major)', function test( t ) { var expected; var out; var x; @@ -454,3 +434,85 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var out; + var x0; + var x1; + + // Initial array: + x0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + + // Create an offset view: + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + out = new Float64Array( 9 ); + + dvander( 'row-major', 1, 3, 3, x1, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles zero values in the input array (row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 0.0, 2.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 1, 2, 3, x, 1, out, 3 ); + + expected = new Float64Array( [ 1.0, 0.0, 0.0, 1.0, 2.0, 4.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single column (N=1)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float64Array( 3 ); + + dvander( 'row-major', 1, 3, 1, x, 1, out, 1 ); + + // Single column: all x^0 = 1 + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single row (M=1)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0 ] ); + out = new Float64Array( 4 ); + + dvander( 'row-major', 1, 1, 4, x, 1, out, 4 ); + + // Single row: [ 3^0, 3^1, 3^2, 3^3 ] = [ 1, 3, 9, 27 ] + expected = new Float64Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js index ed0011744122..7af71164eca5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.dvander.native.js @@ -114,26 +114,6 @@ tape( 'the function throws an error if provided an invalid fourth argument', opt } }); -tape( 'the function throws an error if provided an invalid sixth argument', opts, function test( t ) { - var values; - var i; - - values = [ - 0 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - dvander( 'row-major', -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, new Float64Array( 9 ), 3 ); - }; - } -}); - tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) { var values; var i; @@ -276,7 +256,7 @@ tape( 'the function returns the output matrix', opts, function test( t ) { t.end(); }); -tape( 'if provided an `M` equal to `0`, the function early returns', opts, function test( t ) { +tape( 'if provided an `M` equal to `0`, the function returns the output matrix unchanged', opts, function test( t ) { var out; var x; @@ -289,7 +269,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', opts, funct t.end(); }); -tape( 'if provided an `N` equal to `0`, the function early returns', opts, function test( t ) { +tape( 'if provided an `N` equal to `0`, the function returns the output matrix unchanged', opts, function test( t ) { var out; var x; @@ -302,7 +282,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', opts, funct t.end(); }); -tape( 'the function supports specifying a stride (row-major)', opts, function test( t ) { +tape( 'the function supports specifying a stride for `x` (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -319,7 +299,7 @@ tape( 'the function supports specifying a stride (row-major)', opts, function te t.end(); }); -tape( 'the function supports specifying a negative stride (row-major)', opts, function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -337,7 +317,7 @@ tape( 'the function supports specifying a negative stride (row-major)', opts, fu t.end(); }); -tape( 'the function supports specifying a stride (column-major)', opts, function test( t ) { +tape( 'the function supports specifying a stride for `x` (column-major)', opts, function test( t ) { var expected; var out; var x; @@ -354,7 +334,7 @@ tape( 'the function supports specifying a stride (column-major)', opts, function t.end(); }); -tape( 'the function supports specifying a negative stride (column-major)', opts, function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (column-major)', opts, function test( t ) { var expected; var out; var x; @@ -463,3 +443,85 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports view offsets', opts, function test( t ) { + var expected; + var out; + var x0; + var x1; + + // Initial array: + x0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + + // Create an offset view: + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + out = new Float64Array( 9 ); + + dvander( 'row-major', 1, 3, 3, x1, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 4.0, + 1.0, + 3.0, + 9.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles zero values in the input array (row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 0.0, 2.0 ] ); + out = new Float64Array( 6 ); + + dvander( 'row-major', 1, 2, 3, x, 1, out, 3 ); + + expected = new Float64Array( [ 1.0, 0.0, 0.0, 1.0, 2.0, 4.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single column (N=1)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float64Array( 3 ); + + dvander( 'row-major', 1, 3, 1, x, 1, out, 1 ); + + // Single column: all x^0 = 1 + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single row (M=1)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0 ] ); + out = new Float64Array( 4 ); + + dvander( 'row-major', 1, 1, 4, x, 1, out, 4 ); + + // Single row: [ 3^0, 3^1, 3^2, 3^3 ] = [ 1, 3, 9, 27 ] + expected = new Float64Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js index a045f133074c..2b34022a0e22 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.js @@ -82,26 +82,6 @@ tape( 'the function throws an error if provided an invalid third argument', func } }); -tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { - var values; - var i; - - values = [ - 0 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - dvander( -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len - }; - } -}); - tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { var expected; var out; @@ -222,7 +202,7 @@ tape( 'the function returns the output matrix', function test( t ) { t.end(); }); -tape( 'if provided an `M` equal to `0`, the function early returns', function test( t ) { +tape( 'if provided an `M` equal to `0`, the function returns the output matrix unchanged', function test( t ) { var out; var x; @@ -235,7 +215,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', function te t.end(); }); -tape( 'if provided an `N` equal to `0`, the function early returns', function test( t ) { +tape( 'if provided an `N` equal to `0`, the function returns the output matrix unchanged', function test( t ) { var out; var x; @@ -248,7 +228,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', function te t.end(); }); -tape( 'the function supports an `x` stride', function test( t ) { +tape( 'the function supports specifying a stride for `x` (row-major)', function test( t ) { var expected; var out; var x; @@ -265,7 +245,7 @@ tape( 'the function supports an `x` stride', function test( t ) { t.end(); }); -tape( 'the function supports a negative `x` stride', function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (row-major)', function test( t ) { var expected; var out; var x; @@ -282,6 +262,40 @@ tape( 'the function supports a negative `x` stride', function test( t ) { t.end(); }); +tape( 'the function supports specifying a stride for `x` (column-major)', function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float64Array( 6 ); + + dvander( -1, 2, 3, x, 2, 0, out, 1, 2, 0 ); + + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x` (column-major)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( -1, 2, 3, x, -2, 2, out, 1, 2, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports an `x` offset', function test( t ) { var expected; var out; @@ -315,7 +329,7 @@ tape( 'the function supports an output offset', function test( t ) { t.end(); }); -tape( 'the function supports output strides with padding (row-major)', function test( t ) { +tape( 'the function supports output stride with padding (row-major)', function test( t ) { var expected; var out; var x; @@ -343,7 +357,7 @@ tape( 'the function supports output strides with padding (row-major)', function t.end(); }); -tape( 'the function supports output strides with padding (column-major)', function test( t ) { +tape( 'the function supports output stride with padding (column-major)', function test( t ) { var expected; var out; var x; @@ -440,3 +454,91 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array([ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]); + out = new Float64Array( 6 ); + + dvander( 1, 2, 3, x, 2, 1, out, 3, -1, 2 ); + + expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles zero values in the input array (row-major, increasing)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 0.0, 2.0 ] ); + out = new Float64Array( 6 ); + + dvander( 1, 2, 3, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array( [ 1.0, 0.0, 0.0, 1.0, 2.0, 4.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single column (N=1)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float64Array( 3 ); + + dvander( 1, 3, 1, x, 1, 0, out, 1, 1, 0 ); + + // Single column: all x^0 = 1 + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single row (M=1)', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0 ] ); + out = new Float64Array( 4 ); + + dvander( 1, 1, 4, x, 1, 0, out, 4, 1, 0 ); + + // Single row: [ 3^0, 3^1, 3^2, 3^3 ] = [ 1, 3, 9, 27 ] + expected = new Float64Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports column-major with output offset and stride', function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 8 ); + + // Column-major 2x2 starting at offset 2, with strideOut2=3 (padding of 1) + dvander( 1, 2, 2, x, 1, 0, out, 1, 3, 2 ); + + expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js index 388c77fb6f31..73061214ae7f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/test/test.ndarray.native.js @@ -91,26 +91,6 @@ tape( 'the function throws an error if provided an invalid third argument', opts } }); -tape( 'the function throws an error if provided an invalid fifth argument', opts, function test( t ) { - var values; - var i; - - values = [ - 0 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - dvander( -1, 3, 3, new Float64Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float64Array( 9 ), 3, 1, 0 ); // eslint-disable-line max-len - }; - } -}); - tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { var expected; var out; @@ -229,7 +209,7 @@ tape( 'the function returns the output matrix', opts, function test( t ) { t.end(); }); -tape( 'if provided an `M` equal to `0`, the function early returns', opts, function test( t ) { +tape( 'if provided an `M` equal to `0`, the function returns the output matrix unchanged', opts, function test( t ) { var out; var x; @@ -242,7 +222,7 @@ tape( 'if provided an `M` equal to `0`, the function early returns', opts, funct t.end(); }); -tape( 'if provided an `N` equal to `0`, the function early returns', opts, function test( t ) { +tape( 'if provided an `N` equal to `0`, the function returns the output matrix unchanged', opts, function test( t ) { var out; var x; @@ -255,7 +235,7 @@ tape( 'if provided an `N` equal to `0`, the function early returns', opts, funct t.end(); }); -tape( 'the function supports an `x` stride', opts, function test( t ) { +tape( 'the function supports specifying a stride for `x` (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -272,7 +252,7 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { t.end(); }); -tape( 'the function supports a negative `x` stride', opts, function test( t ) { +tape( 'the function supports specifying a negative stride for `x` (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -289,6 +269,40 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) { t.end(); }); +tape( 'the function supports specifying a stride for `x` (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + // Pick every other element: x[0]=1.0, x[2]=3.0 + x = new Float64Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float64Array( 6 ); + + dvander( -1, 2, 3, x, 2, 0, out, 1, 2, 0 ); + + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x` (column-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float64Array( 6 ); + + dvander( -1, 2, 3, x, -2, 2, out, 1, 2, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float64Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; var out; @@ -322,7 +336,7 @@ tape( 'the function supports an output offset', opts, function test( t ) { t.end(); }); -tape( 'the function supports output strides with padding (row-major)', opts, function test( t ) { +tape( 'the function supports output stride with padding (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -350,7 +364,7 @@ tape( 'the function supports output strides with padding (row-major)', opts, fun t.end(); }); -tape( 'the function supports output strides with padding (column-major)', opts, function test( t ) { +tape( 'the function supports output stride with padding (column-major)', opts, function test( t ) { var expected; var out; var x; @@ -447,3 +461,91 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array([ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]); + out = new Float64Array( 6 ); + + dvander( 1, 2, 3, x, 2, 1, out, 3, -1, 2 ); + + expected = new Float64Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles zero values in the input array (row-major, increasing)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 0.0, 2.0 ] ); + out = new Float64Array( 6 ); + + dvander( 1, 2, 3, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float64Array( [ 1.0, 0.0, 0.0, 1.0, 2.0, 4.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single column (N=1)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float64Array( 3 ); + + dvander( 1, 3, 1, x, 1, 0, out, 1, 1, 0 ); + + // Single column: all x^0 = 1 + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single row (M=1)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 3.0 ] ); + out = new Float64Array( 4 ); + + dvander( 1, 1, 4, x, 1, 0, out, 4, 1, 0 ); + + // Single row: [ 3^0, 3^1, 3^2, 3^3 ] = [ 1, 3, 9, 27 ] + expected = new Float64Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports column-major with output offset and stride', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float64Array( [ 1.0, 2.0 ] ); + out = new Float64Array( 8 ); + + // Column-major 2x2 starting at offset 2, with strideOut2=3 (padding of 1) + dvander( 1, 2, 2, x, 1, 0, out, 1, 3, 2 ); + + expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From cb2e640f314fec4c2030ed09d41be8075e104860 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 16 Apr 2026 00:28:24 -0700 Subject: [PATCH 08/12] bench: reduce array size Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/dvander/benchmark/c/benchmark.length.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c index 8281151f96aa..ac2f66a2016f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -28,7 +28,7 @@ #define ITERATIONS 1000000 #define REPEATS 3 #define MIN 1 -#define MAX 6 +#define MAX 3 /** * Prints the TAP version. From b1b3986d5dec321ed7da4528cf51c0da0bd2fe9b Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 16 Apr 2026 00:32:03 -0700 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/dvander/benchmark/c/benchmark.length.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c index ac2f66a2016f..df6e7515057b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -179,11 +179,11 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = (int)pow( 10, i ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::native::%s:size=%d\n", NAME, len*len ); + printf( "# c::native::%s:len=%d\n", NAME, len ); elapsed = benchmark1( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); @@ -194,7 +194,7 @@ int main( void ) { iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::native::%s:ndarray:size=%d\n", NAME, len*len ); + printf( "# c::native::%s:ndarray:len=%d\n", NAME, len ); elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); From cf7eb853fa446e9cf70bd141d8055037604a7f8e Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 16 Apr 2026 00:33:41 -0700 Subject: [PATCH 10/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/dvander/benchmark/c/benchmark.length.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c index df6e7515057b..25963eb13925 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c @@ -190,7 +190,7 @@ int main( void ) { } } for ( i = MIN; i <= MAX; i++ ) { - len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) ); + len = (int)pow( 10, i ); iter = ITERATIONS / pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; From 032d35035adb3d5c6d1579e369249975bc456050 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 16 Apr 2026 14:50:16 +0500 Subject: [PATCH 11/12] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/README.md | 33 ++++++ .../blas/ext/base/dvander/manifest.json | 3 +- .../@stdlib/blas/ext/base/dvander/src/addon.c | 5 +- .../@stdlib/blas/ext/base/dvander/src/main.c | 103 ++++++++---------- 4 files changed, 86 insertions(+), 58 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md index 636a3349f188..3b76b8638082 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/README.md @@ -61,6 +61,25 @@ The function has the following parameters: - **out**: output matrix stored in linear memory as a [`Float64Array`][@stdlib/array/float64]. - **ldo**: stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`). +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays: +var x0 = new Float64Array( [ 999.0, 1.0, 2.0, 3.0 ] ); +var out0 = new Float64Array( 10 ); + +// Create offset views: +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dvander( 'row-major', 1, 3, 3, x1, 1, out1, 3 ); +// out0 => [ 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] +``` + When the mode is positive, the matrix is generated such that ```text @@ -110,6 +129,18 @@ The function has the following additional parameters: - **strideOut2**: stride length for the second dimension of `out`. - **offsetOut**: starting index for `out`. +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to use every other element from the input array starting from the second element: + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ] ); +var out = new Float64Array( 9 ); + +dvander.ndarray( 1, 3, 3, x, 2, 1, out, 3, 1, 0 ); +// out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] +``` + @@ -313,6 +344,8 @@ int main( void ) { [@stdlib/array/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float64 +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray + diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json index d3baf8619f49..90f596c6acd7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/manifest.json @@ -45,7 +45,8 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-double", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array" + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/argv-strided-float64array2d" ] }, { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c index f8f1e425a774..766b1bef7e2e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c @@ -23,6 +23,7 @@ #include "stdlib/napi/argv_double.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float64array.h" +#include "stdlib/napi/argv_strided_float64array2d.h" #include /** @@ -41,7 +42,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, Out, M, N, LDO, 1, argv, 6 ); API_SUFFIX(stdlib_strided_dvander)( order, mode, M, N, X, strideX, Out, LDO ); return NULL; } @@ -64,7 +65,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideOut1, argv, 7 ); STDLIB_NAPI_ARGV_INT64( env, strideOut2, argv, 8 ); STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 9 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, M*N, 1, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, Out, M, N, strideOut1, strideOut2, argv, 6 ); API_SUFFIX(stdlib_strided_dvander_ndarray)( mode, M, N, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c index cd24dca59333..7fa0c8f1f1d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/main.c @@ -99,12 +99,10 @@ void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double */ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { int64_t sa[ 2 ]; - CBLAS_INT isrm; CBLAS_INT do0; CBLAS_INT do1; CBLAS_INT S0; CBLAS_INT S1; - CBLAS_INT sx; CBLAS_INT io; CBLAS_INT ix; CBLAS_INT i0; @@ -126,78 +124,73 @@ void API_SUFFIX(stdlib_strided_dvander_ndarray)( const double mode, const CBLAS_ sa[ 0 ] = strideOut1; sa[ 1 ] = strideOut2; if ( stdlib_ndarray_is_row_major( 2, sa ) ) { - isrm = 1; - } else { - isrm = 0; - } - sx = strideX; - if ( isrm && mode > 0 ) { - // Row-major, increasing: x^0, x^1, ..., x^(N-1) S0 = N; S1 = M; do0 = strideOut2; - do1 = strideOut1 - ( S0 * strideOut2 ); - io = offsetOut; - ix = offsetX; - for ( i1 = 0; i1 < S1; i1++ ) { - Out[ io ] = 1.0; - io += do0; - for ( i0 = 1; i0 < S0; i0++ ) { - Out[ io ] = Out[ io - do0 ] * X[ ix ]; + do1 = strideOut1 - ( S0*strideOut2 ); + + // Increasing: x^0, x^1, ..., x^(N-1) + if ( mode > 0 ) { + io = offsetOut; + ix = offsetX; + for ( i1 = 0; i1 < S1; i1++ ) { + Out[ io ] = 1.0; io += do0; + for ( i0 = 1; i0 < S0; i0++ ) { + Out[ io ] = Out[ io-do0 ] * X[ ix ]; + io += do0; + } + ix += strideX; + io += do1; } - ix += sx; - io += do1; + return; } - } else if ( isrm ) { - // Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0 - S0 = N; - S1 = M; - do0 = strideOut2; - do1 = strideOut1 + ( S0 * strideOut2 ); - io = offsetOut + ( ( S0-1 ) * do0 ); - ix = offsetX; - for ( i1 = 0; i1 < S1; i1++ ) { + // Decreasing: x^(N-1), x^(N-2), ..., x^0 + io = offsetOut + ( ( S1-1 ) * strideOut1 ) + ( ( S0-1 ) * strideOut2 ); + ix = offsetX + ( ( S1-1 ) * strideX ); + for ( i1 = S1-1; i1 >= 0; i1-- ) { Out[ io ] = 1.0; io -= do0; for ( i0 = 1; i0 < S0; i0++ ) { - Out[ io ] = Out[ io + do0 ] * X[ ix ]; + Out[ io ] = Out[ io+do0 ] * X[ ix ]; io -= do0; } - ix += sx; - io += do1; + ix -= strideX; + io -= do1; } - } else if ( mode > 0 ) { - // Column-major, increasing: column j contains x^j - S0 = M; - S1 = N; - do0 = strideOut1; - do1 = strideOut2 - ( S0 * strideOut1 ); - io = offsetOut; - API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, do0, io ); - io += strideOut2; + return; + } + // Column-major... + S0 = M; + S1 = N; + do0 = strideOut1; + do1 = strideOut2 - ( S0*strideOut1 ); + + // Increasing: column j contains x^j + if ( mode > 0 ) { + API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, strideOut1, offsetOut ); + io = offsetOut + strideOut2; for ( i1 = 1; i1 < S1; i1++ ) { ix = offsetX; for ( i0 = 0; i0 < S0; i0++ ) { - Out[ io ] = Out[ io - strideOut2 ] * X[ ix ]; - ix += sx; + Out[ io ] = Out[ io-strideOut2 ] * X[ ix ]; + ix += strideX; io += do0; } io += do1; } - } else { - // Column-major, decreasing: column 0 contains x^(N-1), last column all ones - S0 = M; - S1 = N; - API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); - for ( i1 = S1 - 2; i1 >= 0; i1-- ) { - io = offsetOut + ( i1 * strideOut2 ); - ix = offsetX; - for ( i0 = 0; i0 < S0; i0++ ) { - Out[ io ] = Out[ io + strideOut2 ] * X[ ix ]; - ix += sx; - io += strideOut1; - } + return; + } + // Decreasing: column 0 contains x^(N-1), last column all ones + API_SUFFIX(stdlib_strided_dfill_ndarray)( S0, 1.0, Out, strideOut1, offsetOut + ( ( S1-1 ) * strideOut2 ) ); + io = offsetOut + ( ( S1-2 ) * strideOut2 ) + ( ( S0-1 ) * strideOut1 ); + for ( i1 = S1-2; i1 >= 0; i1-- ) { + ix = offsetX + ( ( S0-1 ) * strideX ); + for ( i0 = S0-1; i0 >= 0; i0-- ) { + Out[ io ] = Out[ io+strideOut2 ] * X[ ix ]; + ix -= strideX; + io -= do0; } + io -= do1; } } From d0e2fe66ff4462b7313ed9f29fc8c2c9da8a7471 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 17 Apr 2026 17:50:51 +0500 Subject: [PATCH 12/12] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/dvander/src/addon.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c index 766b1bef7e2e..e959d2637d18 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dvander/src/addon.c @@ -34,16 +34,29 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); STDLIB_NAPI_ARGV_INT64( env, order, argv, 0 ); STDLIB_NAPI_ARGV_DOUBLE( env, mode, argv, 1 ); STDLIB_NAPI_ARGV_INT64( env, M, argv, 2 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 3 ); STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, Out, M, N, LDO, 1, argv, 6 ); + + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDO; + } else { // order == CblasRowMajor + sa1 = LDO; + sa2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY2D( env, Out, M, N, sa1, sa2, argv, 6 ); + API_SUFFIX(stdlib_strided_dvander)( order, mode, M, N, X, strideX, Out, LDO ); + return NULL; }