From 627c455cd002972025e5e11b4b105e627ad62de1 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 14 Mar 2026 06:56:51 +0500 Subject: [PATCH 01/13] feat: add blas/ext/base/svander --- 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/svander/README.md | 333 +++++++++++++ .../ext/base/svander/benchmark/benchmark.js | 109 +++++ .../svander/benchmark/benchmark.native.js | 114 +++++ .../svander/benchmark/benchmark.ndarray.js | 109 +++++ .../benchmark/benchmark.ndarray.native.js | 114 +++++ .../ext/base/svander/benchmark/c/Makefile | 146 ++++++ .../svander/benchmark/c/benchmark.length.c | 204 ++++++++ .../@stdlib/blas/ext/base/svander/binding.gyp | 170 +++++++ .../blas/ext/base/svander/docs/repl.txt | 106 +++++ .../ext/base/svander/docs/types/index.d.ts | 116 +++++ .../blas/ext/base/svander/docs/types/test.ts | 342 ++++++++++++++ .../blas/ext/base/svander/examples/c/Makefile | 146 ++++++ .../ext/base/svander/examples/c/example.c | 43 ++ .../blas/ext/base/svander/examples/index.js | 40 ++ .../blas/ext/base/svander/include.gypi | 53 +++ .../include/stdlib/blas/ext/base/svander.h | 48 ++ .../blas/ext/base/svander/lib/index.js | 70 +++ .../@stdlib/blas/ext/base/svander/lib/main.js | 35 ++ .../blas/ext/base/svander/lib/native.js | 35 ++ .../blas/ext/base/svander/lib/ndarray.js | 144 ++++++ .../ext/base/svander/lib/ndarray.native.js | 62 +++ .../blas/ext/base/svander/lib/svander.js | 112 +++++ .../ext/base/svander/lib/svander.native.js | 59 +++ .../blas/ext/base/svander/manifest.json | 85 ++++ .../blas/ext/base/svander/package.json | 74 +++ .../blas/ext/base/svander/src/Makefile | 70 +++ .../@stdlib/blas/ext/base/svander/src/addon.c | 72 +++ .../@stdlib/blas/ext/base/svander/src/main.c | 157 +++++++ .../blas/ext/base/svander/test/test.js | 82 ++++ .../ext/base/svander/test/test.ndarray.js | 378 +++++++++++++++ .../base/svander/test/test.ndarray.native.js | 376 +++++++++++++++ .../ext/base/svander/test/test.svander.js | 437 ++++++++++++++++++ .../base/svander/test/test.svander.native.js | 344 ++++++++++++++ 33 files changed, 4785 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/include/stdlib/blas/ext/base/svander.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md new file mode 100644 index 000000000000..f7b2459e3269 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md @@ -0,0 +1,333 @@ + + +# svander + +> Generate a single-precision floating-point Vandermonde matrix. + +
+ +## Usage + +```javascript +var svander = require( '@stdlib/blas/ext/base/svander' ); +``` + +#### svander( order, M, N, mode, x, strideX, out, LDO ) + +Generates a single-precision floating-point Vandermonde matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var out = new Float32Array( 9 ); + +svander( '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 [`Float32Array`][@stdlib/array/float32]. +- **strideX**: stride length for `x`. +- **out**: output [`Float32Array`][@stdlib/array/float32]. +- **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`, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); +var out = new Float32Array( 9 ); + +svander( '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 Float32Array = require( '@stdlib/array/float32' ); + +// Initial array... +var x0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + +// Create an offset view... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = new Float32Array( 9 ); + +svander( '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 ] +``` + + + +#### svander.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) + + + +Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var out = new Float32Array( 9 ); + +svander.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 Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); +var out = new Float32Array( 9 ); + +svander.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 Float32Array = require( '@stdlib/array/float32' ); +var svander = require( '@stdlib/blas/ext/base/svander' ); + +var opts = { + 'dtype': 'float32' +}; + +var M = 3; +var N = 4; + +var x = discreteUniform( M, 0, 10, opts ); +var out = new Float32Array( M*N ); + +svander( 'row-major', M, N, -1, x, 1, out, N ); +console.log( out ); + +out = new Float32Array( M*N ); +svander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/svander.h" +``` + +#### stdlib_strided_svander( order, M, N, mode, \*X, strideX, \*Out, LDO ) + +Generates a single-precision floating-point Vandermonde matrix. + +```c +#include "stdlib/blas/base/shared.h" + +const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; +float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_svander( CblasRowMajor, 3, 3, -1.0f, 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] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). +- **X**: `[in] float*` input vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Out**: `[out] float*` output matrix. +- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`. + +```c +void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); +``` + + + +#### stdlib_strided_svander_ndarray( M, N, mode, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) + + + +Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" + +const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; +float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_svander_ndarray( 3, 3, -1.0f, 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] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). +- **X**: `[in] float*` input vector. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Out**: `[out] float*` 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_svander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/svander.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define the input vector: + const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; + + // Define a 3x3 output matrix stored in row-major order: + float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of rows and columns: + const int M = 3; + const int N = 3; + + // Perform operation: + stdlib_strided_svander( CblasRowMajor, M, N, -1.0f, 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] = %f\n", i, j, Out[ (i*N)+j ] ); + } + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js new file mode 100644 index 000000000000..e24ac8bc737b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 svander = require( './../lib/svander.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// 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, 'float32' ); + 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 = svander( 'row-major', N, N, -1, x, 1, out, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/svander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js new file mode 100644 index 000000000000..9b39ff79dc1f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 svander = tryRequire( resolve( __dirname, './../lib/svander.native.js' ) ); +var opts = { + 'skip': ( svander instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// 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, 'float32' ); + 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 = svander( 'row-major', N, N, -1, x, 1, out, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/svander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..2b16cbdadd74 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 svander = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// 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, 'float32' ); + 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 = svander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/svander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..f349653c8f4b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +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 svander = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( svander instanceof Error ) +}; +var options = { + 'dtype': 'float32' +}; + + +// 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, 'float32' ); + 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 = svander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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/svander/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..c8a713fb7980 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander.h" +#include "stdlib/blas/base/shared.h" +#include +#include +#include +#include +#include + +#define NAME "svander" +#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 float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* 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; + float *out; + float *x; + double t; + int i; + + x = (float *)malloc( len * sizeof( float ) ); + out = (float *)malloc( len * len * sizeof( float ) ); + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float() * 20.0f ) - 10.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_svander( CblasRowMajor, len, len, -1.0f, 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; + float *out; + float *x; + double t; + int i; + + x = (float *)malloc( len * sizeof( float ) ); + out = (float *)malloc( len * len * sizeof( float ) ); + for ( i = 0; i < len; i++ ) { + x[ i ] = ( rand_float() * 20.0f ) - 10.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_svander_ndarray( len, len, -1.0f, 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/svander/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/svander/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt new file mode 100644 index 000000000000..e7be392e7e4d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt @@ -0,0 +1,106 @@ + +{{alias}}( order, M, N, mode, x, strideX, out, LDO ) + Generates a single-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: Float32Array + Input vector. + + strideX: integer + Stride length for `x`. + + out: Float32Array + Output matrix. + + LDO: integer + Stride length for the leading dimension of `out`. + + Returns + ------- + out: Float32Array + Output matrix. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float32}}( 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 single-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: Float32Array + Input vector. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + out: Float32Array + 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: Float32Array + Output matrix. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float32}}( 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/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts new file mode 100644 index 000000000000..cec946b8f9ce --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 `svander`. +*/ +interface Routine { + /** + * Generates a single-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 length for the leading dimension of `Out` + * @returns output matrix + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var out = new Float32Array( 9 ); + * + * svander( '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: Float32Array, strideX: number, out: Float32Array, LDO: number ): Float32Array; + + /** + * Generates a single-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 Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var out = new Float32Array( 9 ); + * + * svander.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: Float32Array, strideX: number, offsetX: number, out: Float32Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float32Array; +} + +/** +* Generates a single-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 length for the leading dimension of `Out` +* @returns output matrix +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( '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 Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander.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 svander: Routine; + + +// EXPORTS // + +export = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts new file mode 100644 index 000000000000..2814c8e41660 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 svander = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, 10, -1, x, 1, out, 10 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 10, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( true, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( false, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( null, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( undefined, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( [], 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( {}, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( ( 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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', '10', 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', true, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', false, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', null, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', undefined, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', [], 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', {}, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( '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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, '10', -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, true, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, false, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, null, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, undefined, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, [], -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, {}, -1, x, 1, out, 10 ); // $ExpectError + svander( '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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, 10, '10', x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, true, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, false, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, null, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, undefined, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, [], x, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, {}, x, 1, out, 10 ); // $ExpectError + svander( '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 Float32Array... +{ + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, 10, -1, 10, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, '10', 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, true, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, false, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, null, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, undefined, 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, [ '1' ], 1, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, {}, 1, out, 10 ); // $ExpectError + svander( '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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, 10, -1, x, '10', out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, true, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, false, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, null, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, undefined, out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, [], out, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, {}, out, 10 ); // $ExpectError + svander( '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 Float32Array... +{ + const x = new Float32Array( 10 ); + + svander( 'row-major', 10, 10, -1, x, 1, 10, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, '10', 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, true, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, false, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, null, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, undefined, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, [ '1' ], 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, {}, 10 ); // $ExpectError + svander( '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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander( 'row-major', 10, 10, -1, x, 1, out, '10' ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, true ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, false ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, null ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, undefined ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, [] ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, {} ); // $ExpectError + svander( '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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander(); // $ExpectError + svander( 'row-major' ); // $ExpectError + svander( 'row-major', 10 ); // $ExpectError + svander( 'row-major', 10, 10 ); // $ExpectError + svander( 'row-major', 10, 10, -1 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1 ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out ); // $ExpectError + svander( 'row-major', 10, 10, -1, x, 1, out, 10, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( '10', 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( true, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( false, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( null, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( undefined, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( [], 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( {}, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, '10', -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, true, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, false, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, null, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, undefined, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, [], -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, {}, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array... +{ + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, true, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, false, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, null, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, '10', 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, true, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, false, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, null, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, [], 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, {}, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, 1, '10', out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, true, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, false, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, null, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, [], out, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, {}, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array... +{ + const x = new Float32Array( 10 ); + + svander.ndarray( 10, 10, -1, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, 1, 0, out, '10', 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, true, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, false, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, null, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, [], 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, {}, 1, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, '10', 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, true, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, false, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, null, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, [], 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, {}, 0 ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, '10' ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, true ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, false ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, null ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, undefined ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, [] ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, {} ); // $ExpectError + svander.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 Float32Array( 10 ); + const out = new Float32Array( 100 ); + + svander.ndarray(); // $ExpectError + svander.ndarray( 10 ); // $ExpectError + svander.ndarray( 10, 10 ); // $ExpectError + svander.ndarray( 10, 10, -1 ); // $ExpectError + svander.ndarray( 10, 10, -1, x ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1 ); // $ExpectError + svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c new file mode 100644 index 000000000000..09b8a9474936 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Define a 3x3 output matrix stored in row-major order: + float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Define the input vector: + const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; + + // Specify the number of rows and columns: + const int M = 3; + const int N = 3; + + // Generate the Vandermonde matrix: + stdlib_strided_svander( CblasRowMajor, M, N, -1.0f, 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] = %f\n", i, j, Out[ (i*N)+j ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js new file mode 100644 index 000000000000..de48ac847084 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 Float32Array = require( '@stdlib/array/float32' ); +var svander = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var M = 3; +var N = 4; + +var x = discreteUniform( M, 0, 10, opts ); +var out = new Float32Array( M*N ); + +svander( 'row-major', M, N, -1, x, 1, out, N ); +console.log( out ); + +out = new Float32Array( M*N ); +svander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/svander/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var svander = require( '@stdlib/blas/ext/base/svander' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander.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 svander; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + svander = main; +} else { + svander = tmp; +} + + +// EXPORTS // + +module.exports = svander; + +// exports: { "ndarray": "svander.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/main.js new file mode 100644 index 000000000000..6370194729a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 svander = require( './svander.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( svander, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/native.js new file mode 100644 index 000000000000..3c2be654e96d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 svander = require( './svander.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( svander, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js new file mode 100644 index 000000000000..f2756365681c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; + + +// MAIN // + +/** +* Generates a single-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 {Float32Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} 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 {Float32Array} output matrix +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( 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 svander( 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 + sfill( 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 + sfill( 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 = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js new file mode 100644 index 000000000000..f8e733731d73 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 single-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 {Float32Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} 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 {Float32Array} output matrix +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( 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 svander( 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 = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js new file mode 100644 index 000000000000..b026800f4453 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js @@ -0,0 +1,112 @@ +/** +* @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 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' ); + + +// MAIN // + +/** +* Generates a single-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 {Float32Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {Float32Array} out - output matrix +* @param {PositiveInteger} LDO - stride length for the leading dimension of `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 {Float32Array} output matrix +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( '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 svander( 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 = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js new file mode 100644 index 000000000000..3f89efdf1a8f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 single-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 {Float32Array} x - input vector +* @param {integer} strideX - stride length for `x` +* @param {Float32Array} out - output matrix +* @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` +* @returns {Float32Array} output matrix +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( '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 svander( order, M, N, mode, x, strideX, out, LDO ) { + addon( resolve( order ), M, N, mode, x, strideX, out, LDO ); + return out; +} + + +// EXPORTS // + +module.exports = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json new file mode 100644 index 000000000000..8459008299c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/sfill", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/sfill", + "@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/sfill", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/package.json b/lib/node_modules/@stdlib/blas/ext/base/svander/package.json new file mode 100644 index 000000000000..9528f6673be1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/svander", + "version": "0.0.0", + "description": "Generate a single-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", + "svander", + "vandermonde", + "matrix", + "linear", + "algebra", + "array", + "ndarray", + "float32", + "float", + "single", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/svander/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c new file mode 100644 index 000000000000..602dc76bbc47 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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/svander.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.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_FLOAT( env, mode, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); + API_SUFFIX(stdlib_strided_svander)( 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_FLOAT( env, mode, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( 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_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); + API_SUFFIX(stdlib_strided_svander_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/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c new file mode 100644 index 000000000000..014c7940d34b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -0,0 +1,157 @@ +/** +* @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/svander.h" +#include "stdlib/blas/ext/base/sfill.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" +#include + +/** +* Generates a single-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 stride length for the leading dimension of `Out` +*/ +void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, float *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_svander_ndarray)( M, N, mode, X, strideX, ox, Out, sa1, sa2, 0 ); +} + +/** +* Generates a single-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_svander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *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; + 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.0f; + 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.0f; + 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_sfill_ndarray)( S0, 1.0f, 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_sfill_ndarray)( S0, 1.0f, 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/svander/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.js new file mode 100644 index 000000000000..874851e547b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 svander = 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 svander, '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 svander.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 svander = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( svander, 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 svander; + var main; + + main = require( './../lib/main.js' ); + + svander = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( svander, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js new file mode 100644 index 000000000000..cf563d7d677d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 Float32Array = require( '@stdlib/array/float32' ); +var svander = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof svander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( svander.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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + // Column-major: strideOut1=1, strideOut2=3 + svander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + // Column-major: strideOut1=1, strideOut2=3 + svander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + v = svander( 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 Float32Array( [] ); + out = new Float32Array( [] ); + + svander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( [] ); + + svander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float32Array( [ 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 Float32Array( [ 999.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + + // Starting at offset 2: + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 10 ); + + // 2x3 row-major with strideOut1=5 (padding of 2 per row) + svander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 12 ); + + // 2x3 column-major with strideOut2=4 (padding of 2 per column) + svander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + // 3x2 matrix, decreasing: + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + + // 2x4 matrix, increasing: + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + // 3x2 column-major: strideOut1=1, strideOut2=3 + svander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + // 2x4 column-major: strideOut1=1, strideOut2=2 + svander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + + expected = new Float32Array( [ 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/svander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js new file mode 100644 index 000000000000..f37065c59307 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js @@ -0,0 +1,376 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var svander = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( svander instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof svander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', opts, function test( t ) { + t.strictEqual( svander.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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + v = svander( 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 Float32Array( [] ); + out = new Float32Array( [] ); + + svander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( [] ); + + svander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + + t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 999.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 10 ); + + svander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 12 ); + + svander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + + expected = new Float32Array( [ 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/svander/test/test.svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js new file mode 100644 index 000000000000..c72e5a4607a2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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 Float32Array = require( '@stdlib/array/float32' ); +var svander = require( './../lib/svander.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof svander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( svander.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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 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() { + svander( 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + t.throws( function badValue() { + svander( '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + t.throws( function badValue() { + svander( '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + t.throws( function badValue() { + svander( '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + t.throws( function badValue() { + svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + t.throws( function badValue() { + svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + v = svander( '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 Float32Array( [] ); + out = new Float32Array( [] ); + + svander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( [] ); + + svander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float32Array( 6 ); + + svander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 10 ); + + // 2x3 row-major with LDO=5 (padding of 2 per row) + svander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 12 ); + + // 2x3 column-major with LDO=4 (padding of 2 per column) + svander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + + // 3x2 matrix, decreasing: + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + + // 2x4 matrix, increasing: + expected = new Float32Array( [ 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/svander/test/test.svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js new file mode 100644 index 000000000000..dd5c7a1f351c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js @@ -0,0 +1,344 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var svander = tryRequire( resolve( __dirname, './../lib/svander.native.js' ) ); +var opts = { + 'skip': ( svander instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof svander, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( svander.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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 9 ); + + svander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 4 ); + + v = svander( '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 Float32Array( [] ); + out = new Float32Array( [] ); + + svander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + + t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( [] ); + + svander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + + t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride (row-major)', opts, function test( t ) { + var expected; + var out; + var x; + + x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + + expected = new Float32Array( [ 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; + + x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + + expected = new Float32Array( [ 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; + + x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); + out = new Float32Array( 6 ); + + svander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + + expected = new Float32Array( [ 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; + + x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 10 ); + + svander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 12 ); + + svander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + + expected = new Float32Array([ + 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 Float32Array( [ 1.0, 2.0, 3.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); + out = new Float32Array( 8 ); + + svander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + + expected = new Float32Array( [ 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(); +}); From 32f1f374560e7049923e1ccdee71d772730afe71 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 14 Mar 2026 22:26:31 +0500 Subject: [PATCH 02/13] 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/svander/README.md | 46 ++- .../ext/base/svander/benchmark/benchmark.js | 2 +- .../svander/benchmark/benchmark.native.js | 2 +- .../svander/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../svander/benchmark/c/benchmark.length.c | 4 +- .../blas/ext/base/svander/docs/repl.txt | 24 +- .../ext/base/svander/docs/types/index.d.ts | 18 +- .../blas/ext/base/svander/docs/types/test.ts | 334 +++++++++--------- .../ext/base/svander/examples/c/example.c | 2 +- .../blas/ext/base/svander/examples/index.js | 12 +- .../include/stdlib/blas/ext/base/svander.h | 4 +- .../blas/ext/base/svander/lib/index.js | 4 +- .../blas/ext/base/svander/lib/ndarray.js | 8 +- .../ext/base/svander/lib/ndarray.native.js | 8 +- .../blas/ext/base/svander/lib/svander.js | 51 +-- .../ext/base/svander/lib/svander.native.js | 8 +- .../@stdlib/blas/ext/base/svander/src/addon.c | 16 +- .../@stdlib/blas/ext/base/svander/src/main.c | 12 +- .../ext/base/svander/test/test.ndarray.js | 34 +- .../base/svander/test/test.ndarray.native.js | 34 +- .../ext/base/svander/test/test.svander.js | 122 +------ .../base/svander/test/test.svander.native.js | 30 +- 23 files changed, 321 insertions(+), 458 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md index f7b2459e3269..ffc4facbc44d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md @@ -30,7 +30,7 @@ limitations under the License. var svander = require( '@stdlib/blas/ext/base/svander' ); ``` -#### svander( order, M, N, mode, x, strideX, out, LDO ) +#### svander( order, mode, M, N, x, strideX, out, LDO ) Generates a single-precision floating-point Vandermonde matrix. @@ -40,16 +40,16 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var out = new Float32Array( 9 ); -svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +svander( '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 [`Float32Array`][@stdlib/array/float32]. - **strideX**: stride length for `x`. - **out**: output [`Float32Array`][@stdlib/array/float32]. @@ -63,7 +63,7 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); var out = new Float32Array( 9 ); -svander( 'row-major', 3, 3, -1, x, 2, out, 3 ); +svander( '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 Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd var out = new Float32Array( 9 ); -svander( 'row-major', 3, 3, -1, x1, 1, out, 3 ); +svander( '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 ] ``` -#### svander.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) +#### svander.ndarray( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) @@ -100,7 +100,7 @@ var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var out = new Float32Array( 9 ); -svander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +svander.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 Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); var out = new Float32Array( 9 ); -svander.ndarray( 3, 3, -1, x, 1, 1, out, 3, 1, 0 ); +svander.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,19 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float32Array = require( '@stdlib/array/float32' ); var svander = require( '@stdlib/blas/ext/base/svander' ); -var opts = { - 'dtype': 'float32' -}; - var M = 3; var N = 4; -var x = discreteUniform( M, 0, 10, opts ); +var x = discreteUniform( M, 0, 10, { + 'dtype': 'float32' +}); var out = new Float32Array( M*N ); -svander( 'row-major', M, N, -1, x, 1, out, N ); +svander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); out = new Float32Array( M*N ); -svander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +svander.ndarray( -1, M, N, x, 1, 0, out, N, 1, 0 ); console.log( out ); ``` @@ -196,7 +194,7 @@ console.log( out ); #include "stdlib/blas/ext/base/svander.h" ``` -#### stdlib_strided_svander( order, M, N, mode, \*X, strideX, \*Out, LDO ) +#### stdlib_strided_svander( order, mode, M, N, \*X, strideX, \*Out, LDO ) Generates a single-precision floating-point Vandermonde matrix. @@ -206,27 +204,27 @@ Generates a single-precision floating-point Vandermonde matrix. const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -stdlib_strided_svander( CblasRowMajor, 3, 3, -1.0f, x, 1, Out, 3 ); +stdlib_strided_svander( CblasRowMajor, -1.0f, 3, 3, x, 1, Out, 3 ); ``` The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. +- **mode**: `[in] float` 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] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). - **X**: `[in] float*` input vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Out**: `[out] float*` output matrix. - **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`. ```c -void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); +void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); ``` -#### stdlib_strided_svander_ndarray( M, N, mode, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) +#### stdlib_strided_svander_ndarray( mode, M, N, \*X, strideX, offsetX, \*Out, strideOut1, strideOut2, offsetOut ) @@ -238,14 +236,14 @@ Generates a single-precision floating-point Vandermonde matrix using alternative const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -stdlib_strided_svander_ndarray( 3, 3, -1.0f, x, 1, 0, Out, 3, 1, 0 ); +stdlib_strided_svander_ndarray( -1.0f, 3, 3, x, 1, 0, Out, 3, 1, 0 ); ``` The function accepts the following arguments: +- **mode**: `[in] float` 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] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). - **X**: `[in] float*` input vector. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. @@ -255,7 +253,7 @@ The function accepts the following arguments: - **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. ```c -void API_SUFFIX(stdlib_strided_svander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); ``` @@ -293,7 +291,7 @@ int main( void ) { const int N = 3; // Perform operation: - stdlib_strided_svander( CblasRowMajor, M, N, -1.0f, x, 1, Out, N ); + stdlib_strided_svander( CblasRowMajor, -1.0f, 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/svander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js index e24ac8bc737b..f3998f5f2d29 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js @@ -67,7 +67,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = svander( 'row-major', N, N, -1, x, 1, out, N ); + z = svander( 'row-major', -1, N, N, x, 1, out, N ); if ( isnanf( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js index 9b39ff79dc1f..cdbfd72288bd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js @@ -72,7 +72,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = svander( 'row-major', N, N, -1, x, 1, out, N ); + z = svander( 'row-major', -1, N, N, x, 1, out, N ); if ( isnanf( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js index 2b16cbdadd74..ab91d986ff42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js @@ -67,7 +67,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = svander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + z = svander( -1, N, N, x, 1, 0, out, N, 1, 0 ); if ( isnanf( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js index f349653c8f4b..891bd0f1e2ef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js @@ -72,7 +72,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = svander( N, N, -1, x, 1, 0, out, N, 1, 0 ); + z = svander( -1, N, N, x, 1, 0, out, N, 1, 0 ); if ( isnanf( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c index c8a713fb7980..3d3573a18d5e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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_svander( CblasRowMajor, len, len, -1.0f, x, 1, out, len ); + stdlib_strided_svander( CblasRowMajor, -1.0f, 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_svander_ndarray( len, len, -1.0f, x, 1, 0, out, len, 1, 0 ); + stdlib_strided_svander_ndarray( -1.0f, 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/svander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt index e7be392e7e4d..54e5a309461e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 single-precision floating-point Vandermonde matrix. Indexing is relative to the first index. To introduce an offset, use typed @@ -12,16 +12,16 @@ 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: Float32Array Input vector. @@ -44,11 +44,11 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float32}}( 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 single-precision floating-point Vandermonde matrix using alternative indexing semantics. @@ -58,16 +58,16 @@ 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: Float32Array Input vector. @@ -99,7 +99,7 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float32}}( 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/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts index cec946b8f9ce..3b11f315321f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts @@ -30,9 +30,9 @@ interface Routine { * Generates a single-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 strideX - stride length for `x` * @param out - output matrix @@ -45,17 +45,17 @@ interface Routine { * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * - * svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + * svander( '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: Float32Array, strideX: number, out: Float32Array, LDO: number ): Float32Array; + ( order: Layout, mode: number, M: number, N: number, x: Float32Array, strideX: number, out: Float32Array, LDO: number ): Float32Array; /** * Generates a single-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 strideX - stride length for `x` * @param offsetX - starting index for `x` @@ -71,19 +71,19 @@ interface Routine { * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * - * svander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + * svander.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: Float32Array, strideX: number, offsetX: number, out: Float32Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float32Array; + ndarray( mode: number, M: number, N: number, x: Float32Array, strideX: number, offsetX: number, out: Float32Array, strideOut1: number, strideOut2: number, offsetOut: number ): Float32Array; } /** * Generates a single-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 strideX - stride length for `x` * @param out - output matrix @@ -96,7 +96,7 @@ interface Routine { * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* svander.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 svander: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts index 2814c8e41660..ca5a2514560d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts @@ -26,7 +26,7 @@ import svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', 10, 10, -1, x, 1, out, 10 ); // $ExpectType Float32Array + svander( 'row-major', -1, 10, 10, x, 1, out, 10 ); // $ExpectType Float32Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -34,14 +34,14 @@ import svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 10, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( true, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( false, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( null, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( undefined, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( [], 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( {}, 10, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( ( x: number ): number => x, 10, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 10, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( true, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( false, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( null, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( undefined, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( [], -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( {}, -1, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( ( 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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', '10', 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', true, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', false, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', null, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', undefined, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', [], 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', {}, 10, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', ( x: number ): number => x, 10, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', '10', 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', true, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', false, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', null, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', undefined, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', [], 10, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', {}, 10, 10, x, 1, out, 10 ); // $ExpectError + svander( '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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', 10, '10', -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, true, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, false, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, null, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, undefined, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, [], -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, {}, -1, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, ( x: number ): number => x, -1, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, '10', 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, true, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, false, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, null, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, undefined, 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, [], 10, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, {}, 10, x, 1, out, 10 ); // $ExpectError + svander( '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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', 10, 10, '10', x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, true, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, false, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, null, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, undefined, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, [], x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, {}, x, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, ( x: number ): number => x, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, '10', x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, true, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, false, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, null, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, undefined, x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, [], x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, {}, x, 1, out, 10 ); // $ExpectError + svander( '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 Float32Array... { const out = new Float32Array( 100 ); - svander( 'row-major', 10, 10, -1, 10, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, '10', 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, true, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, false, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, null, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, undefined, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, [ '1' ], 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, {}, 1, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, ( x: number ): number => x, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, 10, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, '10', 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, true, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, false, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, null, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, undefined, 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, [ '1' ], 1, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, {}, 1, out, 10 ); // $ExpectError + svander( '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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', 10, 10, -1, x, '10', out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, true, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, false, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, null, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, undefined, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, [], out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, {}, out, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, ( x: number ): number => x, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, '10', out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, true, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, false, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, null, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, undefined, out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, [], out, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, {}, out, 10 ); // $ExpectError + svander( '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 Float32Array... { const x = new Float32Array( 10 ); - svander( 'row-major', 10, 10, -1, x, 1, 10, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, '10', 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, true, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, false, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, null, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, undefined, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, [ '1' ], 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, {}, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, ( x: number ): number => x, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, 10, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, '10', 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, true, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, false, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, null, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, undefined, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, [ '1' ], 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, {}, 10 ); // $ExpectError + svander( '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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander( 'row-major', 10, 10, -1, x, 1, out, '10' ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, true ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, false ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, null ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, undefined ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, [] ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, {} ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, ( x: number ): number => x ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, '10' ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, true ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, false ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, null ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, undefined ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, [] ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, {} ); // $ExpectError + svander( '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 svander = require( './index' ); svander(); // $ExpectError svander( 'row-major' ); // $ExpectError - svander( 'row-major', 10 ); // $ExpectError - svander( 'row-major', 10, 10 ); // $ExpectError - svander( 'row-major', 10, 10, -1 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1 ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out ); // $ExpectError - svander( 'row-major', 10, 10, -1, x, 1, out, 10, 10 ); // $ExpectError + svander( 'row-major', -1 ); // $ExpectError + svander( 'row-major', -1, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1 ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out ); // $ExpectError + svander( 'row-major', -1, 10, 10, x, 1, out, 10, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float32Array... @@ -170,7 +170,7 @@ import svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float32Array + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectType Float32Array } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... @@ -178,14 +178,14 @@ import svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( '10', 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( true, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( false, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( null, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( undefined, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( [], 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( {}, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( ( x: number ): number => x, 10, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( '10', 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( true, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( false, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( null, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( undefined, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( [], 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( {}, 10, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, '10', -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, true, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, false, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, null, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, undefined, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, [], -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, {}, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, ( x: number ): number => x, -1, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, '10', 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, true, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, false, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, null, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, undefined, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, [], 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, {}, 10, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, ( x: number ): number => x, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, '10', x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, true, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, false, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, null, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, undefined, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, [], x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, {}, x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array... { const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, true, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, false, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, null, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, ( x: number ): number => x, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, 10, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, '10', 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, true, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, false, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, null, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, undefined, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, [ '1' ], 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, {}, 1, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, '10', 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, true, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, false, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, null, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, [], 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, {}, 0, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, ( x: number ): number => x, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, '10', 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, true, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, false, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, null, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, undefined, 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, [], 0, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, {}, 0, out, 10, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, 1, '10', out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, true, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, false, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, null, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, [], out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, {}, out, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, ( x: number ): number => x, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, '10', out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, true, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, false, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, null, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, undefined, out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, [], out, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, {}, out, 10, 1, 0 ); // $ExpectError + svander.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 Float32Array... { const x = new Float32Array( 10 ); - svander.ndarray( 10, 10, -1, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, true, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, false, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, null, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, 1, 0, out, '10', 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, true, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, false, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, null, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, [], 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, {}, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, '10', 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, true, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, false, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, null, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, undefined, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, [], 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, {}, 1, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, '10', 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, true, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, false, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, null, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, [], 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, {}, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, ( x: number ): number => x, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, '10', 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, true, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, false, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, null, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, undefined, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, [], 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, {}, 0 ); // $ExpectError + svander.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 svander = require( './index' ); const x = new Float32Array( 10 ); const out = new Float32Array( 100 ); - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, '10' ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, true ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, false ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, null ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, undefined ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, [] ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, {} ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, ( x: number ): number => x ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, '10' ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, true ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, false ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, null ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, undefined ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, [] ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, {} ); // $ExpectError + svander.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 svander = require( './index' ); const out = new Float32Array( 100 ); svander.ndarray(); // $ExpectError - svander.ndarray( 10 ); // $ExpectError - svander.ndarray( 10, 10 ); // $ExpectError - svander.ndarray( 10, 10, -1 ); // $ExpectError - svander.ndarray( 10, 10, -1, x ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1 ); // $ExpectError - svander.ndarray( 10, 10, -1, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError + svander.ndarray( -1 ); // $ExpectError + svander.ndarray( -1, 10 ); // $ExpectError + svander.ndarray( -1, 10, 10 ); // $ExpectError + svander.ndarray( -1, 10, 10, x ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1 ); // $ExpectError + svander.ndarray( -1, 10, 10, x, 1, 0, out, 10, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c index 09b8a9474936..fdd82051b8c8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c @@ -32,7 +32,7 @@ int main( void ) { const int N = 3; // Generate the Vandermonde matrix: - stdlib_strided_svander( CblasRowMajor, M, N, -1.0f, x, 1, Out, N ); + stdlib_strided_svander( CblasRowMajor, -1.0f, 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/svander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js index de48ac847084..cf57107b1f5c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js @@ -22,19 +22,17 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var Float32Array = require( '@stdlib/array/float32' ); var svander = require( './../lib' ); -var opts = { - 'dtype': 'float32' -}; - var M = 3; var N = 4; -var x = discreteUniform( M, 0, 10, opts ); +var x = discreteUniform( M, 0, 10, { + 'dtype': 'float32' +}); var out = new Float32Array( M*N ); -svander( 'row-major', M, N, -1, x, 1, out, N ); +svander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); out = new Float32Array( M*N ); -svander.ndarray( M, N, -1, x, 1, 0, out, N, 1, 0 ); +svander.ndarray( -1, M, N, x, 1, 0, out, N, 1, 0 ); console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/include/stdlib/blas/ext/base/svander.h b/lib/node_modules/@stdlib/blas/ext/base/svander/include/stdlib/blas/ext/base/svander.h index cb9e33c5b395..62f72393af53 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/include/stdlib/blas/ext/base/svander.h +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/include/stdlib/blas/ext/base/svander.h @@ -34,12 +34,12 @@ extern "C" { /** * Generates a single-precision floating-point Vandermonde matrix. */ -void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); +void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); /** * Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_svander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *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/svander/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/index.js index 4b6ee63cabbe..66e679fbc9a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/index.js @@ -30,7 +30,7 @@ * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander.ndarray( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* svander.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/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js index f2756365681c..c9e9fa453767 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js @@ -31,9 +31,9 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; /** * Generates a single-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 {Float32Array} x - input vector * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` @@ -49,10 +49,10 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* svander( -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 svander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { +function svander( mode, M, N, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { var do0; var do1; var rm; @@ -64,7 +64,7 @@ function svander( 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/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js index f8e733731d73..45c7a29796db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js @@ -30,9 +30,9 @@ var addon = require( './../src/addon.node' ); /** * Generates a single-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 {Float32Array} x - input vector * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` @@ -48,11 +48,11 @@ var addon = require( './../src/addon.node' ); * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); +* svander( -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 svander( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ) { - addon.ndarray( M, N, mode, x, strideX, offsetX, out, strideOut1, strideOut2, offsetOut ); +function svander( 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/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js index b026800f4453..02a2591df196 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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,18 +31,13 @@ var ndarray = require( './ndarray.js' ); * Generates a single-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 {Float32Array} x - input vector * @param {integer} strideX - stride length for `x` * @param {Float32Array} out - output matrix * @param {PositiveInteger} LDO - stride length for the leading dimension of `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 {Float32Array} output matrix * * @example @@ -53,57 +46,23 @@ var ndarray = require( './ndarray.js' ); * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* svander( '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 svander( order, M, N, mode, x, strideX, out, LDO ) { - var iscm; - var vala; +function svander( 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/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js index 3f89efdf1a8f..5f814f58c72a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js @@ -30,9 +30,9 @@ var addon = require( './../src/addon.node' ); * Generates a single-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 {Float32Array} x - input vector * @param {integer} strideX - stride length for `x` * @param {Float32Array} out - output matrix @@ -45,11 +45,11 @@ var addon = require( './../src/addon.node' ); * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var out = new Float32Array( 9 ); * -* svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); +* svander( '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 svander( order, M, N, mode, x, strideX, out, LDO ) { - addon( resolve( order ), M, N, mode, x, strideX, out, LDO ); +function svander( 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/svander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c index 602dc76bbc47..cc6092089bb0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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_FLOAT( env, mode, argv, 3 ); + STDLIB_NAPI_ARGV_FLOAT( 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_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); - API_SUFFIX(stdlib_strided_svander)( order, M, N, mode, X, strideX, Out, LDO ); + API_SUFFIX(stdlib_strided_svander)( 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_FLOAT( env, mode, argv, 2 ); + STDLIB_NAPI_ARGV_FLOAT( 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_FLOAT32ARRAY( 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_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); - API_SUFFIX(stdlib_strided_svander_ndarray)( M, N, mode, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); + API_SUFFIX(stdlib_strided_svander_ndarray)( mode, M, N, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c index 014c7940d34b..e7c2ff03502b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -27,15 +27,15 @@ * Generates a single-precision floating-point Vandermonde matrix. * * @param order storage layout +* @param mode specifies whether powers 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 powers are increasing (1) or decreasing (-1) * @param X input vector * @param strideX stride length for `X` * @param Out output matrix * @param LDO stride length for the leading dimension of `Out` */ -void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ) { +void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ) { CBLAS_INT sa1; CBLAS_INT sa2; CBLAS_INT ox; @@ -48,15 +48,15 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_I sa1 = LDO; sa2 = 1; } - API_SUFFIX(stdlib_strided_svander_ndarray)( M, N, mode, X, strideX, ox, Out, sa1, sa2, 0 ); + API_SUFFIX(stdlib_strided_svander_ndarray)( mode, M, N, X, strideX, ox, Out, sa1, sa2, 0 ); } /** * Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. * +* @param mode specifies whether powers 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 powers are increasing (1) or decreasing (-1) * @param X input vector * @param strideX stride length for `X` * @param offsetX starting index for `X` @@ -65,7 +65,7 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const CBLAS_I * @param strideOut2 stride length for the second dimension of `Out` * @param offsetOut starting index for `Out` */ -void API_SUFFIX(stdlib_strided_svander_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const float mode, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { +void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { int64_t sa[ 2 ]; CBLAS_INT do0; CBLAS_INT do1; @@ -78,7 +78,7 @@ void API_SUFFIX(stdlib_strided_svander_ndarray)( const CBLAS_INT M, const CBLAS_ CBLAS_INT i0; CBLAS_INT i1; - if ( M == 0 || N == 0 ) { + if ( M <= 0 || N <= 0 ) { return; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js index cf563d7d677d..d8f861b7896f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js @@ -46,7 +46,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', fun x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + svander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float32Array([ 1.0, @@ -72,7 +72,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', fun x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + svander( 1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float32Array([ 1.0, @@ -99,7 +99,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', out = new Float32Array( 9 ); // Column-major: strideOut1=1, strideOut2=3 - svander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + svander( -1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array([ 1.0, @@ -126,7 +126,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', out = new Float32Array( 9 ); // Column-major: strideOut1=1, strideOut2=3 - svander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + svander( 1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array([ 1.0, @@ -152,7 +152,7 @@ tape( 'the function returns the output array', function test( t ) { x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 4 ); - v = svander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + v = svander( -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 Float32Array( [] ); out = new Float32Array( [] ); - svander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + svander( -1, 0, 3, x, 1, 0, out, 3, 1, 0 ); t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + svander( -1, 2, 0, x, 1, 0, out, 0, 1, 0 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); @@ -193,7 +193,7 @@ tape( 'the function supports an `x` stride', function test( t ) { x = new Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + svander( -1, 2, 3, x, 2, 0, out, 3, 1, 0 ); expected = new Float32Array( [ 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 Float32Array( [ 3.0, 999.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + svander( -1, 2, 3, x, -2, 2, out, 3, 1, 0 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 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 Float32Array( [ 999.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + svander( -1, 2, 3, x, 1, 1, out, 3, 1, 0 ); expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + svander( -1, 2, 3, x, 1, 0, out, 3, 1, 2 ); // Starting at offset 2: expected = new Float32Array( [ 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 Float32Array( 10 ); // 2x3 row-major with strideOut1=5 (padding of 2 per row) - svander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + svander( -1, 2, 3, x, 1, 0, out, 5, 1, 0 ); expected = new Float32Array([ 1.0, @@ -288,7 +288,7 @@ tape( 'the function supports output strides with padding (column-major)', functi out = new Float32Array( 12 ); // 2x3 column-major with strideOut2=4 (padding of 2 per column) - svander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + svander( -1, 2, 3, x, 1, 0, out, 1, 4, 0 ); expected = new Float32Array([ 1.0, @@ -317,7 +317,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + svander( -1, 3, 2, x, 1, 0, out, 2, 1, 0 ); // 3x2 matrix, decreasing: expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + svander( 1, 2, 4, x, 1, 0, out, 4, 1, 0 ); // 2x4 matrix, increasing: expected = new Float32Array( [ 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 Float32Array( 6 ); // 3x2 column-major: strideOut1=1, strideOut2=3 - svander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + svander( -1, 3, 2, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array( [ 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 Float32Array( 8 ); // 2x4 column-major: strideOut1=1, strideOut2=2 - svander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + svander( 1, 2, 4, x, 1, 0, out, 1, 2, 0 ); expected = new Float32Array( [ 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/svander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js index f37065c59307..77b66fe2cde5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js @@ -55,7 +55,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opt x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, -1, x, 1, 0, out, 3, 1, 0 ); + svander( -1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float32Array([ 1.0, @@ -81,7 +81,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opt x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, 1, x, 1, 0, out, 3, 1, 0 ); + svander( 1, 3, 3, x, 1, 0, out, 3, 1, 0 ); expected = new Float32Array([ 1.0, @@ -107,7 +107,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, -1, x, 1, 0, out, 1, 3, 0 ); + svander( -1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array([ 1.0, @@ -133,7 +133,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 3, 3, 1, x, 1, 0, out, 1, 3, 0 ); + svander( 1, 3, 3, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array([ 1.0, @@ -159,7 +159,7 @@ tape( 'the function returns the output array', opts, function test( t ) { x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 4 ); - v = svander( 2, 2, -1, x, 1, 0, out, 2, 1, 0 ); + v = svander( -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 Float32Array( [] ); out = new Float32Array( [] ); - svander( 0, 3, -1, x, 1, 0, out, 3, 1, 0 ); + svander( -1, 0, 3, x, 1, 0, out, 3, 1, 0 ); t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 2, 0, -1, x, 1, 0, out, 0, 1, 0 ); + svander( -1, 2, 0, x, 1, 0, out, 0, 1, 0 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); @@ -199,7 +199,7 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { x = new Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, 2, 0, out, 3, 1, 0 ); + svander( -1, 2, 3, x, 2, 0, out, 3, 1, 0 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -215,7 +215,7 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) { x = new Float32Array( [ 3.0, 999.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, -2, 2, out, 3, 1, 0 ); + svander( -1, 2, 3, x, -2, 2, out, 3, 1, 0 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -231,7 +231,7 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { x = new Float32Array( [ 999.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 2, 3, -1, x, 1, 1, out, 3, 1, 0 ); + svander( -1, 2, 3, x, 1, 1, out, 3, 1, 0 ); expected = new Float32Array( [ 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -247,7 +247,7 @@ tape( 'the function supports an output offset', opts, function test( t ) { x = new Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 2, 3, -1, x, 1, 0, out, 3, 1, 2 ); + svander( -1, 2, 3, x, 1, 0, out, 3, 1, 2 ); expected = new Float32Array( [ 0.0, 0.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -263,7 +263,7 @@ tape( 'the function supports output strides with padding (row-major)', opts, fun x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 10 ); - svander( 2, 3, -1, x, 1, 0, out, 5, 1, 0 ); + svander( -1, 2, 3, x, 1, 0, out, 5, 1, 0 ); expected = new Float32Array([ 1.0, @@ -290,7 +290,7 @@ tape( 'the function supports output strides with padding (column-major)', opts, x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 12 ); - svander( 2, 3, -1, x, 1, 0, out, 1, 4, 0 ); + svander( -1, 2, 3, x, 1, 0, out, 1, 4, 0 ); expected = new Float32Array([ 1.0, @@ -319,7 +319,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 3, 2, -1, x, 1, 0, out, 2, 1, 0 ); + svander( -1, 3, 2, x, 1, 0, out, 2, 1, 0 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -335,7 +335,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 2, 4, 1, x, 1, 0, out, 4, 1, 0 ); + svander( 1, 2, 4, x, 1, 0, out, 4, 1, 0 ); expected = new Float32Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); @@ -351,7 +351,7 @@ tape( 'the function supports non-square matrices (M > N, column-major, decreasin x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 3, 2, -1, x, 1, 0, out, 1, 3, 0 ); + svander( -1, 3, 2, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); @@ -367,7 +367,7 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin x = new Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 2, 4, 1, x, 1, 0, out, 1, 2, 0 ); + svander( 1, 2, 4, x, 1, 0, out, 1, 2, 0 ); expected = new Float32Array( [ 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/svander/test/test.svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js index c72e5a4607a2..dd1a68fe78ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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 Float32Array( [ 1.0, 2.0 ] ); - out = new Float32Array( 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() { - svander( 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 Float32Array( [ 1.0, 2.0 ] ); - out = new Float32Array( 4 ); - - t.throws( function badValue() { - svander( '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 Float32Array( [ 1.0, 2.0 ] ); - out = new Float32Array( 4 ); - - t.throws( function badValue() { - svander( '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 Float32Array( [ 1.0, 2.0 ] ); - out = new Float32Array( 4 ); - - t.throws( function badValue() { - svander( '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 Float32Array( [ 1.0, 2.0 ] ); - out = new Float32Array( 4 ); - - t.throws( function badValue() { - svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = new Float32Array( 6 ); - - t.throws( function badValue() { - svander( '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 Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + svander( 'row-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -164,7 +72,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', fun x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + svander( 'row-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -190,7 +98,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + svander( 'column-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -216,7 +124,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + svander( 'column-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -242,7 +150,7 @@ tape( 'the function returns the output array', function test( t ) { x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 4 ); - v = svander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + v = svander( '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 Float32Array( [] ); out = new Float32Array( [] ); - svander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + svander( 'row-major', -1, 0, 3, x, 1, out, 3 ); t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + svander( 'row-major', -1, 2, 0, x, 1, out, 0 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); @@ -283,7 +191,7 @@ tape( 'the function supports specifying a stride (row-major)', function test( t x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + svander( 'row-major', -1, 2, 3, x, 2, out, 3 ); expected = new Float32Array( [ 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 Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + svander( 'row-major', -1, 2, 3, x, -2, out, 3 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 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 Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); - svander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + svander( 'column-major', -1, 2, 3, x, 2, out, 2 ); expected = new Float32Array( [ 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 Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + svander( 'column-major', -1, 2, 3, x, -2, out, 2 ); // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 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 Float32Array( 10 ); // 2x3 row-major with LDO=5 (padding of 2 per row) - svander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + svander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float32Array([ 1.0, @@ -381,7 +289,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m out = new Float32Array( 12 ); // 2x3 column-major with LDO=4 (padding of 2 per column) - svander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + svander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float32Array([ 1.0, @@ -410,7 +318,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + svander( 'row-major', -1, 3, 2, x, 1, out, 2 ); // 3x2 matrix, decreasing: expected = new Float32Array( [ 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 Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + svander( 'row-major', 1, 2, 4, x, 1, out, 4 ); // 2x4 matrix, increasing: expected = new Float32Array( [ 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/svander/test/test.svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js index dd5c7a1f351c..84641f19a23d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js @@ -55,7 +55,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opt x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'row-major', 3, 3, -1, x, 1, out, 3 ); + svander( 'row-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -81,7 +81,7 @@ tape( 'the function generates a Vandermonde matrix (row-major, increasing)', opt x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'row-major', 3, 3, 1, x, 1, out, 3 ); + svander( 'row-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -107,7 +107,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'column-major', 3, 3, -1, x, 1, out, 3 ); + svander( 'column-major', -1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -133,7 +133,7 @@ tape( 'the function generates a Vandermonde matrix (column-major, increasing)', x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 9 ); - svander( 'column-major', 3, 3, 1, x, 1, out, 3 ); + svander( 'column-major', 1, 3, 3, x, 1, out, 3 ); expected = new Float32Array([ 1.0, @@ -159,7 +159,7 @@ tape( 'the function returns the output array', opts, function test( t ) { x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 4 ); - v = svander( 'row-major', 2, 2, -1, x, 1, out, 2 ); + v = svander( '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 Float32Array( [] ); out = new Float32Array( [] ); - svander( 'row-major', 0, 3, -1, x, 1, out, 3 ); + svander( 'row-major', -1, 0, 3, x, 1, out, 3 ); t.deepEqual( out, new Float32Array( [] ), '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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 'row-major', 2, 0, -1, x, 1, out, 0 ); + svander( 'row-major', -1, 2, 0, x, 1, out, 0 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); @@ -199,7 +199,7 @@ tape( 'the function supports specifying a stride (row-major)', opts, function te x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 2, 3, -1, x, 2, out, 3 ); + svander( 'row-major', -1, 2, 3, x, 2, out, 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -215,7 +215,7 @@ tape( 'the function supports specifying a negative stride (row-major)', opts, fu x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 2, 3, -1, x, -2, out, 3 ); + svander( 'row-major', -1, 2, 3, x, -2, out, 3 ); expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); @@ -231,7 +231,7 @@ tape( 'the function supports specifying a stride (column-major)', opts, function x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); - svander( 'column-major', 2, 3, -1, x, 2, out, 2 ); + svander( 'column-major', -1, 2, 3, x, 2, out, 2 ); expected = new Float32Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -247,7 +247,7 @@ tape( 'the function supports specifying a negative stride (column-major)', opts, x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); - svander( 'column-major', 2, 3, -1, x, -2, out, 2 ); + svander( 'column-major', -1, 2, 3, x, -2, out, 2 ); expected = new Float32Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); @@ -263,7 +263,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (row-majo x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 10 ); - svander( 'row-major', 2, 3, -1, x, 1, out, 5 ); + svander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float32Array([ 1.0, @@ -290,7 +290,7 @@ tape( 'the function supports an `LDO` larger than the matrix dimension (column-m x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 12 ); - svander( 'column-major', 2, 3, -1, x, 1, out, 4 ); + svander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float32Array([ 1.0, @@ -319,7 +319,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); - svander( 'row-major', 3, 2, -1, x, 1, out, 2 ); + svander( 'row-major', -1, 3, 2, x, 1, out, 2 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); @@ -335,7 +335,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' x = new Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); - svander( 'row-major', 2, 4, 1, x, 1, out, 4 ); + svander( 'row-major', 1, 2, 4, x, 1, out, 4 ); expected = new Float32Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); From 57f64714d681c07eba486b88289481bfef75c2d4 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 14 Mar 2026 23:54:47 +0500 Subject: [PATCH 03/13] 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - 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/svander/README.md | 14 +++++++------- .../blas/ext/base/svander/docs/repl.txt | 8 ++++---- .../ext/base/svander/docs/types/index.d.ts | 18 +++++++++--------- .../blas/ext/base/svander/examples/c/example.c | 4 ++-- .../blas/ext/base/svander/lib/ndarray.js | 6 +++--- .../ext/base/svander/lib/ndarray.native.js | 6 +++--- .../blas/ext/base/svander/lib/svander.js | 6 +++--- .../ext/base/svander/lib/svander.native.js | 6 +++--- .../@stdlib/blas/ext/base/svander/src/main.c | 8 ++++---- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md index ffc4facbc44d..f50eb95a9741 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md @@ -55,7 +55,7 @@ The function has the following parameters: - **out**: output [`Float32Array`][@stdlib/array/float32]. - **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 Float32Array = require( '@stdlib/array/float32' ); @@ -213,9 +213,9 @@ The function accepts the following arguments: - **mode**: `[in] float` 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`. -- **X**: `[in] float*` input vector. +- **X**: `[in] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **Out**: `[out] float*` output matrix. +- **Out**: `[out] float*` output array. - **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`. ```c @@ -244,10 +244,10 @@ The function accepts the following arguments: - **mode**: `[in] float` 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`. -- **X**: `[in] float*` input vector. +- **X**: `[in] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **Out**: `[out] float*` output matrix. +- **Out**: `[out] float*` 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`. @@ -280,10 +280,10 @@ void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_I #include int main( void ) { - // Define the input vector: + // Define the input array: const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; - // Define a 3x3 output matrix stored in row-major order: + // Define a 3x3 output array stored in row-major order: float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; // Specify the number of rows and columns: diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt index 54e5a309461e..9aba2f449b46 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt @@ -29,7 +29,7 @@ Stride length for `x`. out: Float32Array - Output matrix. + Output array. LDO: integer Stride length for the leading dimension of `out`. @@ -37,7 +37,7 @@ Returns ------- out: Float32Array - Output matrix. + Output array. Examples -------- @@ -78,7 +78,7 @@ Starting index for `x`. out: Float32Array - Output matrix. + Output array. so1: integer Stride of the first dimension of `out`. @@ -92,7 +92,7 @@ Returns ------- out: Float32Array - Output matrix. + Output array. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts index 3b11f315321f..018d6bf02464 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts @@ -33,11 +33,11 @@ interface Routine { * @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 x - input vector + * @param x - input array * @param strideX - stride length for `x` - * @param out - output matrix + * @param out - output array * @param LDO - stride length for the leading dimension of `Out` - * @returns output matrix + * @returns output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -56,14 +56,14 @@ interface Routine { * @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 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 Float32Array = require( '@stdlib/array/float32' ); @@ -84,11 +84,11 @@ interface Routine { * @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 x - input vector +* @param x - input array * @param strideX - stride length for `x` -* @param out - output matrix +* @param out - output array * @param LDO - stride length for the leading dimension of `Out` -* @returns output matrix +* @returns output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c index fdd82051b8c8..fa1c61af0e57 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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: float Out[ 3*3 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - // Define the input vector: + // Define the input array: const float x[ 3 ] = { 1.0f, 2.0f, 3.0f }; // Specify the number of rows and columns: diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js index c9e9fa453767..16ef58cff3c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js @@ -34,14 +34,14 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * @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 {Float32Array} x - input vector +* @param {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float32Array} out - output matrix +* @param {Float32Array} 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 {Float32Array} output matrix +* @returns {Float32Array} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js index 45c7a29796db..f0ea15712ffd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js @@ -33,14 +33,14 @@ var addon = require( './../src/addon.node' ); * @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 {Float32Array} x - input vector +* @param {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {Float32Array} out - output matrix +* @param {Float32Array} 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 {Float32Array} output matrix +* @returns {Float32Array} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js index 02a2591df196..11188a2c2bad 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js @@ -34,11 +34,11 @@ var ndarray = require( './ndarray.js' ); * @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 {Float32Array} x - input vector +* @param {Float32Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float32Array} out - output matrix +* @param {Float32Array} out - output array * @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` -* @returns {Float32Array} output matrix +* @returns {Float32Array} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js index 5f814f58c72a..fa081d9931a6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js @@ -33,11 +33,11 @@ var addon = require( './../src/addon.node' ); * @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 {Float32Array} x - input vector +* @param {Float32Array} x - input array * @param {integer} strideX - stride length for `x` -* @param {Float32Array} out - output matrix +* @param {Float32Array} out - output array * @param {PositiveInteger} LDO - stride length for the leading dimension of `Out` -* @returns {Float32Array} output matrix +* @returns {Float32Array} output array * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c index e7c2ff03502b..1a01aca8ca82 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -30,9 +30,9 @@ * @param mode specifies whether powers are increasing or decreasing * @param M number of rows in the matrix `Out` * @param N number of columns in the matrix `Out` -* @param X input vector +* @param X input array * @param strideX stride length for `X` -* @param Out output matrix +* @param Out output array * @param LDO stride length for the leading dimension of `Out` */ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ) { @@ -57,10 +57,10 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float m * @param mode specifies whether powers are increasing or decreasing * @param M number of rows in the matrix `Out` * @param N number of columns in the matrix `Out` -* @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` From a92f4fbbf14a414965bf0033a08e6329226e4cf8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 15 Mar 2026 00:27:07 +0500 Subject: [PATCH 04/13] 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/svander/README.md | 12 ++++++------ .../blas/ext/base/svander/docs/types/index.d.ts | 12 ++++++------ .../@stdlib/blas/ext/base/svander/lib/ndarray.js | 4 ++-- .../blas/ext/base/svander/lib/ndarray.native.js | 4 ++-- .../@stdlib/blas/ext/base/svander/lib/svander.js | 4 ++-- .../blas/ext/base/svander/lib/svander.native.js | 4 ++-- .../@stdlib/blas/ext/base/svander/src/main.c | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md index f50eb95a9741..e24713646f71 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 [`Float32Array`][@stdlib/array/float32]. - **strideX**: stride length for `x`. - **out**: output [`Float32Array`][@stdlib/array/float32]. @@ -211,8 +211,8 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **mode**: `[in] float` 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] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Out**: `[out] float*` output array. @@ -242,8 +242,8 @@ stdlib_strided_svander_ndarray( -1.0f, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: - **mode**: `[in] float` 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] float*` 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/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts index 018d6bf02464..29e35b16dcc6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 single-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/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js index 16ef58cff3c5..46145ff15177 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js @@ -32,8 +32,8 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * Generates a single-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 {Float32Array} 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/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js index f0ea15712ffd..1d4f472b18db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js @@ -31,8 +31,8 @@ var addon = require( './../src/addon.node' ); * Generates a single-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 {Float32Array} 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/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js index 11188a2c2bad..c4d62ce51771 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float32Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js index fa081d9931a6..cc9010ac91a3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float32Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c index 1a01aca8ca82..cf43307584ef 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -28,8 +28,8 @@ * * @param order storage layout * @param mode specifies whether powers 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 @@ -55,8 +55,8 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float m * Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. * * @param mode specifies whether powers 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` From 5389eb5efa8fd256bc83a2eef74a5257c378596b Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 15 Mar 2026 21:31:24 +0500 Subject: [PATCH 05/13] 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/svander/lib/base.js | 141 ++++++++++++++++++ .../blas/ext/base/svander/lib/ndarray.js | 96 ++---------- .../ext/base/svander/lib/ndarray.native.js | 17 +++ .../blas/ext/base/svander/lib/svander.js | 44 +++++- .../ext/base/svander/lib/svander.native.js | 37 +++++ .../blas/ext/base/svander/manifest.json | 3 + .../@stdlib/blas/ext/base/svander/src/main.c | 56 ++++++- .../ext/base/svander/test/test.ndarray.js | 64 ++++++++ .../base/svander/test/test.ndarray.native.js | 64 ++++++++ .../ext/base/svander/test/test.svander.js | 113 +++++++++++++- .../base/svander/test/test.svander.native.js | 113 +++++++++++++- 11 files changed, 661 insertions(+), 87 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js new file mode 100644 index 000000000000..46175b7dace4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; + + +// MAIN // + +/** +* Generates a single-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 {Float32Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} 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 {Float32Array} output array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var out = new Float32Array( 9 ); +* +* svander( -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 svander( 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 + sfill( 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 + sfill( 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 = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js index 46145ff15177..b62b458ee626 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js @@ -22,8 +22,8 @@ // MODULES // -var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); // MAIN // @@ -41,6 +41,9 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).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 {Float32Array} output array * * @example @@ -53,89 +56,20 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function svander( 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 - sfill( 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 - sfill( 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/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js index 1d4f472b18db..0470d046ddca 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 {Float32Array} output array * * @example @@ -52,6 +56,19 @@ 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 svander( 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/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js index c4d62ce51771..0bbc13093d4b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} 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 {Float32Array} 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 svander( 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/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js index cc9010ac91a3..57567d60acea 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} 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 {Float32Array} output array * * @example @@ -49,6 +58,34 @@ 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 svander( 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/svander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json index 8459008299c2..61a25f920cd8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json @@ -37,6 +37,7 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", + "@stdlib/blas/base/xerbla", "@stdlib/blas/ext/base/sfill", "@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/sfill", "@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/sfill", "@stdlib/ndarray/base/assert/is-row-major", "@stdlib/strided/base/stride2offset" diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c index cf43307584ef..7bc623297708 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -18,6 +18,7 @@ #include "stdlib/blas/ext/base/svander.h" #include "stdlib/blas/ext/base/sfill.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_svander)( const CBLAS_LAYOUT order, const float m 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_svander", "Error: invalid argument. First argument must be a valid storage layout. Value: `%d`.", order ); + return; + } + if ( M < 0 ) { + c_xerbla( 3, "stdlib_strided_svander", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 4, "stdlib_strided_svander", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 6, "stdlib_strided_svander", "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_svander", "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,7 +119,20 @@ void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_I CBLAS_INT i0; CBLAS_INT i1; - if ( M <= 0 || N <= 0 ) { + if ( M < 0 ) { + c_xerbla( 2, "stdlib_strided_svander_ndarray", "Error: invalid argument. Second argument must be a nonnegative integer. Value: `%d`.", M ); + return; + } + if ( N < 0 ) { + c_xerbla( 3, "stdlib_strided_svander_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); + return; + } + if ( strideX == 0 ) { + c_xerbla( 5, "stdlib_strided_svander_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/svander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js index d8f861b7896f..961404d6a9ac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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() { + svander( -1, value, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + +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() { + svander( -1, 3, value, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + +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() { + svander( -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + 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/svander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js index 77b66fe2cde5..3cdeab58c412 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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() { + svander( -1, value, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + +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() { + svander( -1, 3, value, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + +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() { + svander( -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float32Array( 9 ), 3, 1, 0 ); + }; + } +}); + tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', opts, function test( t ) { var expected; var out; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js index dd1a68fe78ac..952d45497f5f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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() { + svander( value, -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 9 ), 3 ); + }; + } +}); + +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() { + svander( 'row-major', -1, value, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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() { + svander( 'row-major', -1, 3, value, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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() { + svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, new Float32Array( 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() { + svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 'row-major', -1, 2, 0, x, 1, out, 0 ); + svander( 'row-major', -1, 2, 0, x, 1, out, 1 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js index 84641f19a23d..62fb8fab3a48 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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() { + svander( value, -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 9 ), 3 ); + }; + } +}); + +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() { + svander( 'row-major', -1, value, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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() { + svander( 'row-major', -1, 3, value, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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() { + svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, new Float32Array( 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() { + svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, new Float32Array( 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 Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( [] ); - svander( 'row-major', -1, 2, 0, x, 1, out, 0 ); + svander( 'row-major', -1, 2, 0, x, 1, out, 1 ); t.deepEqual( out, new Float32Array( [] ), 'returns expected value' ); t.end(); From 3efcfbf8223b5553004a69ee532eadef516c888f Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 20 Mar 2026 18:53:44 +0500 Subject: [PATCH 06/13] 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/svander/README.md | 75 +++++++---------- .../blas/ext/base/svander/docs/repl.txt | 62 +++++++++----- .../ext/base/svander/docs/types/index.d.ts | 36 ++++---- .../@stdlib/blas/ext/base/svander/lib/base.js | 83 +++++++++--------- .../blas/ext/base/svander/lib/ndarray.js | 15 ++-- .../ext/base/svander/lib/ndarray.native.js | 15 ++-- .../blas/ext/base/svander/lib/svander.js | 24 +++--- .../ext/base/svander/lib/svander.native.js | 21 ++--- .../@stdlib/blas/ext/base/svander/src/main.c | 84 +++++++++---------- .../ext/base/svander/test/test.ndarray.js | 8 +- .../base/svander/test/test.ndarray.native.js | 8 +- .../ext/base/svander/test/test.svander.js | 12 +-- .../base/svander/test/test.svander.native.js | 8 +- 13 files changed, 224 insertions(+), 227 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md index e24713646f71..b9b9c8ec63b2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/README.md @@ -22,6 +22,12 @@ limitations under the License. > Generate a single-precision floating-point Vandermonde matrix. +
+ +
+ + +
## Usage @@ -30,7 +36,7 @@ limitations under the License. var svander = require( '@stdlib/blas/ext/base/svander' ); ``` -#### svander( order, mode, M, N, x, strideX, out, LDO ) +#### svander( order, mode, M, N, x, strideX, out, ldo ) Generates a single-precision floating-point Vandermonde matrix. @@ -46,45 +52,14 @@ svander( '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 [`Float32Array`][@stdlib/array/float32]. - **strideX**: stride length for `x`. -- **out**: output [`Float32Array`][@stdlib/array/float32]. -- **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 Float32Array = require( '@stdlib/array/float32' ); - -var x = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); -var out = new Float32Array( 9 ); - -svander( '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 Float32Array = require( '@stdlib/array/float32' ); - -// Initial array... -var x0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); - -// Create an offset view... -var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - -var out = new Float32Array( 9 ); - -svander( '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 [`Float32Array`][@stdlib/array/float32]. +- **ldo**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`). @@ -107,8 +82,8 @@ svander.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, @@ -131,7 +106,7 @@ svander.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 `out` unchanged.
@@ -211,12 +186,12 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **mode**: `[in] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **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] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **Out**: `[out] float*` output array. -- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`. +- **Out**: `[out] float*` 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_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); @@ -242,14 +217,14 @@ stdlib_strided_svander_ndarray( -1.0f, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: - **mode**: `[in] float` specifies whether powers are increasing (`1`) or decreasing (`-1`). -- **M**: `[in] CBLAS_INT` number of rows in `Out`. +- **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] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **Out**: `[out] float*` 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] float*` 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 @@ -310,6 +285,12 @@ int main( void ) { +
+ +
+ + + @@ -106,7 +149,7 @@ svander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 ); ## Notes -- If `M <= 0` or `N <= 0`, both functions return `out` unchanged. +- If `M <= 0` or `N <= 0`, both functions return the output matrix unchanged. @@ -133,10 +176,6 @@ var out = new Float32Array( M*N ); svander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); - -out = new Float32Array( M*N ); -svander.ndarray( -1, M, N, x, 1, 0, out, N, 1, 0 ); -console.log( out ); ``` @@ -186,12 +225,12 @@ The function accepts the following arguments: - **order**: `[in] CBLAS_LAYOUT` storage layout. - **mode**: `[in] float` 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] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **Out**: `[out] float*` 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_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ); @@ -217,7 +256,7 @@ stdlib_strided_svander_ndarray( -1.0f, 3, 3, x, 1, 0, Out, 3, 1, 0 ); The function accepts the following arguments: - **mode**: `[in] float` 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] float*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js index f3998f5f2d29..60081e021b73 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js @@ -25,7 +25,6 @@ var uniform = require( '@stdlib/random/array/uniform' ); var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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 svander = require( './../lib/svander.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, 'float32' ); +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 = svander( 'row-major', -1, N, N, x, 1, out, N ); - if ( isnanf( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = svander( 'row-major', 1, len, len, x, 1, out, len ); + if ( isnanf( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( z[ i%z.length ] ) ) { + if ( isnanf( 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/svander/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js index cdbfd72288bd..65118b890f6f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js @@ -26,7 +26,6 @@ var uniform = require( '@stdlib/random/array/uniform' ); var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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; @@ -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, 'float32' ); +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 = svander( 'row-major', -1, N, N, x, 1, out, N ); - if ( isnanf( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = svander( 'row-major', 1, len, len, x, 1, out, len ); + if ( isnanf( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( z[ i%z.length ] ) ) { + if ( isnanf( 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/svander/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js index ab91d986ff42..f69484a08a7a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js @@ -25,7 +25,6 @@ var uniform = require( '@stdlib/random/array/uniform' ); var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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 svander = 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, 'float32' ); +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 = svander( -1, N, N, x, 1, 0, out, N, 1, 0 ); - if ( isnanf( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = svander( 1, len, len, x, 1, 0, out, len, 1, 0 ); + if ( isnanf( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( z[ i%z.length ] ) ) { + if ( isnanf( 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/svander/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js index 891bd0f1e2ef..e8f4a56418f7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.native.js @@ -26,7 +26,6 @@ var uniform = require( '@stdlib/random/array/uniform' ); var zeros = require( '@stdlib/array/zeros' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); 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; @@ -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, 'float32' ); +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 = svander( -1, N, N, x, 1, 0, out, N, 1, 0 ); - if ( isnanf( z[ i%z.length ] ) ) { + x[ 0 ] += 0.1; + v = svander( 1, len, len, x, 1, 0, out, len, 1, 0 ); + if ( isnanf( v[ i%v.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( z[ i%z.length ] ) ) { + if ( isnanf( 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/svander/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c index 3d3573a18d5e..535ef0186675 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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. @@ -110,7 +110,7 @@ static double benchmark1( int iterations, int len ) { t = tic(); for ( i = 0; i < iterations; i++ ) { // cppcheck-suppress uninitvar - stdlib_strided_svander( CblasRowMajor, -1.0f, len, len, x, 1, out, len ); + stdlib_strided_svander( CblasRowMajor, 1.0f, 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_svander_ndarray( -1.0f, len, len, x, 1, 0, out, len, 1, 0 ); + stdlib_strided_svander_ndarray( 1.0f, len, len, x, 1, 0, out, len, 1, 0 ); if ( out[ 0 ] != out[ 0 ] ) { printf( "should not return NaN\n" ); break; @@ -179,22 +179,22 @@ int main( void ) { print_version(); count = 0; for ( i = MIN; i <= MAX; i++ ) { - len = (int)sqrt( pow( 10, i ) ); + 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 ); } } for ( i = MIN; i <= MAX; i++ ) { - len = (int)sqrt( pow( 10, i ) ); + len = (int)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 ); + 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 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt index bfb07b99c7fe..7834fd360637 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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,8 +15,8 @@ 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 ... ] @@ -34,7 +34,7 @@ `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`. @@ -49,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 ------- @@ -62,6 +62,12 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float32}}( 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/float32}}( [ 1.0, 2.0, 3.0 ] ); + > out = new {{alias:@stdlib/array/float32}}( 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 ] @@ -70,10 +76,6 @@ Generates a single-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: integer @@ -81,7 +83,7 @@ `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`. @@ -117,8 +119,15 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); > var out = new {{alias:@stdlib/array/float32}}( 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/float32}}( [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ] ); + > out = new {{alias:@stdlib/array/float32}}( 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/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts index d00b2b3b7915..2dd3ebae121a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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 single-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/svander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts index ca5a2514560d..7bc5e6d21acf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/docs/types/test.ts @@ -29,11 +29,12 @@ import svander = require( './index' ); svander( 'row-major', -1, 10, 10, x, 1, out, 10 ); // $ExpectType Float32Array } -// 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 Float32Array( 10 ); const out = new Float32Array( 100 ); + svander( '10', -1, 10, 10, x, 1, out, 10 ); // $ExpectError svander( 10, -1, 10, 10, x, 1, out, 10 ); // $ExpectError svander( true, -1, 10, 10, x, 1, out, 10 ); // $ExpectError svander( false, -1, 10, 10, x, 1, out, 10 ); // $ExpectError diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js index cf57107b1f5c..ff68ec9e8b3c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/examples/index.js @@ -32,7 +32,3 @@ var out = new Float32Array( M*N ); svander( 'row-major', -1, M, N, x, 1, out, N ); console.log( out ); - -out = new Float32Array( M*N ); -svander.ndarray( -1, M, N, x, 1, 0, out, N, 1, 0 ); -console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js index cdb1a09fae92..b1f8e17b26d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/base.js @@ -31,9 +31,13 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; /** * Generates a single-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 {Float32Array} x - input array * @param {integer} strideX - stride length for `x` @@ -54,89 +58,85 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * // out => [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] */ function svander( 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; - sfill( 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 ) { + sfill( 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; - sfill( 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 + sfill( 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/svander/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js index 1926291a393d..c61fff817c2d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.js @@ -32,7 +32,7 @@ var base = require( './base.js' ); * Generates a single-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 {Float32Array} 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 {Float32Array} output matrix * * @example @@ -62,9 +61,6 @@ function svander( 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; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js index 7ee8b5cbb52c..7294b4ede577 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/ndarray.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); * Generates a single-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 {Float32Array} 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 {Float32Array} output matrix * * @example @@ -62,9 +61,6 @@ function svander( 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; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js index 70f8761a6698..8467b825456e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float32Array} 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 {Float32Array} output matrix * @@ -73,9 +72,6 @@ function svander( 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; diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js index ed6979cc2b43..d61293abe431 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/lib/svander.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 {Float32Array} x - input array * @param {integer} strideX - stride length for `x` * @param {Float32Array} 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 {Float32Array} output matrix * @@ -69,9 +68,6 @@ function svander( 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 { diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json index 61a25f920cd8..3eb0f1e1a1cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/manifest.json @@ -45,7 +45,8 @@ "@stdlib/napi/argv", "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float32array" + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/argv-strided-float32array2d" ] }, { diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/package.json b/lib/node_modules/@stdlib/blas/ext/base/svander/package.json index 9528f6673be1..c70109c63f20 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/package.json @@ -70,5 +70,6 @@ "float", "single", "float32array" - ] + ], + "__stdlib__": {} } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c index cc6092089bb0..c28efa9ced43 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c @@ -23,6 +23,7 @@ #include "stdlib/napi/argv_float.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/argv_strided_float32array2d.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_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, Out, M, N, LDO, 1, argv, 6 ); API_SUFFIX(stdlib_strided_svander)( 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_FLOAT32ARRAY( env, Out, M*N, 1, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, Out, M, N, strideOut1, strideOut2, argv, 6 ); API_SUFFIX(stdlib_strided_svander_ndarray)( mode, M, N, X, strideX, offsetX, Out, strideOut1, strideOut2, offsetOut ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c index 8d93487a9423..37122b633276 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/src/main.c @@ -28,13 +28,13 @@ * Generates a single-precision floating-point Vandermonde matrix. * * @param order storage layout -* @param mode specifies whether powers are increasing or decreasing -* @param M number of rows in `Out` and number of indexed elements in `X` +* @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 X input array * @param strideX stride length for `X` * @param Out output matrix -* @param LDO stride length for the leading dimension of `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_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO ) { CBLAS_INT sa1; @@ -55,10 +55,6 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float m c_xerbla( 4, "stdlib_strided_svander", "Error: invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( strideX == 0 ) { - c_xerbla( 6, "stdlib_strided_svander", "Error: invalid argument. Sixth argument must be nonzero. Value: `%d`.", strideX ); - return; - } if ( order == CblasColMajor ) { v = M; } else { @@ -90,8 +86,8 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float m /** * Generates a single-precision floating-point Vandermonde matrix using alternative indexing semantics. * -* @param mode specifies whether powers are increasing or decreasing -* @param M number of rows in `Out` and number of indexed elements in `X` +* @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 X input array * @param strideX stride length for `X` @@ -103,12 +99,10 @@ void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float m */ void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *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; @@ -122,89 +116,81 @@ void API_SUFFIX(stdlib_strided_svander_ndarray)( const float mode, const CBLAS_I c_xerbla( 3, "stdlib_strided_svander_ndarray", "Error: invalid argument. Third argument must be a nonnegative integer. Value: `%d`.", N ); return; } - if ( strideX == 0 ) { - c_xerbla( 5, "stdlib_strided_svander_ndarray", "Error: invalid argument. Fifth argument must be nonzero. Value: `%d`.", strideX ); - return; - } 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 ) ) { - 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.0f; - 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.0f; 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.0f; 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_sfill_ndarray)( S0, 1.0f, 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_sfill_ndarray)( S0, 1.0f, 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_sfill_ndarray)( S0, 1.0f, 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_sfill_ndarray)( S0, 1.0f, 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; } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js index f935df938e98..f0391bf0b435 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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() { - svander( -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float32Array( 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 Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float32Array( 6 ); + + svander( -1, 2, 3, x, 2, 0, out, 1, 2, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( -1, 2, 3, x, -2, 2, out, 1, 2, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float32Array( [ 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 Float32Array([ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]); + out = new Float32Array( 6 ); + + svander( 1, 2, 3, x, 2, 1, out, 3, -1, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 0.0, 2.0 ] ); + out = new Float32Array( 6 ); + + svander( 1, 2, 3, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float32Array( 3 ); + + svander( 1, 3, 1, x, 1, 0, out, 1, 1, 0 ); + + // Single column: all x^0 = 1 + expected = new Float32Array( [ 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 Float32Array( [ 3.0 ] ); + out = new Float32Array( 4 ); + + svander( 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 Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 8 ); + + // Column-major 2x2 starting at offset 2, with strideOut2=3 (padding of 1) + svander( 1, 2, 2, x, 1, 0, out, 1, 3, 2 ); + + expected = new Float32Array( [ 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/svander/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js index befbe9ceb5e3..3a3c50edf8ff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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() { - svander( -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, 0, new Float32Array( 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,11 +235,12 @@ 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; + // Pick every other element: x[0]=1.0, x[2]=3.0 x = new Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); out = new Float32Array( 6 ); @@ -271,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; @@ -281,12 +262,47 @@ tape( 'the function supports a negative `x` stride', opts, function test( t ) { svander( -1, 2, 3, x, -2, 2, out, 3, 1, 0 ); + // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 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 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 Float32Array( [ 1.0, 999.0, 3.0, 999.0 ] ); + out = new Float32Array( 6 ); + + svander( -1, 2, 3, x, 2, 0, out, 1, 2, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 3.0, 999.0, 1.0 ] ); + out = new Float32Array( 6 ); + + svander( -1, 2, 3, x, -2, 2, out, 1, 2, 0 ); + + // x[2]=1.0 (first), x[0]=3.0 (second) + expected = new Float32Array( [ 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; @@ -313,13 +329,14 @@ tape( 'the function supports an output offset', opts, function test( t ) { svander( -1, 2, 3, x, 1, 0, out, 3, 1, 2 ); + // Starting at offset 2: expected = new Float32Array( [ 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 ) { +tape( 'the function supports output stride with padding (row-major)', opts, function test( t ) { var expected; var out; var x; @@ -327,6 +344,7 @@ tape( 'the function supports output strides with padding (row-major)', opts, fun x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 10 ); + // 2x3 row-major with strideOut1=5 (padding of 2 per row) svander( -1, 2, 3, x, 1, 0, out, 5, 1, 0 ); expected = new Float32Array([ @@ -346,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; @@ -354,6 +372,7 @@ tape( 'the function supports output strides with padding (column-major)', opts, x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 12 ); + // 2x3 column-major with strideOut2=4 (padding of 2 per column) svander( -1, 2, 3, x, 1, 0, out, 1, 4, 0 ); expected = new Float32Array([ @@ -385,6 +404,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' svander( -1, 3, 2, x, 1, 0, out, 2, 1, 0 ); + // 3x2 matrix, decreasing: expected = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); t.deepEqual( out, expected, 'returns expected value' ); @@ -401,6 +421,7 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' svander( 1, 2, 4, x, 1, 0, out, 4, 1, 0 ); + // 2x4 matrix, increasing: expected = new Float32Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); t.deepEqual( out, expected, 'returns expected value' ); @@ -415,6 +436,7 @@ tape( 'the function supports non-square matrices (M > N, column-major, decreasin x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); out = new Float32Array( 6 ); + // 3x2 column-major: strideOut1=1, strideOut2=3 svander( -1, 3, 2, x, 1, 0, out, 1, 3, 0 ); expected = new Float32Array( [ 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); @@ -431,6 +453,7 @@ tape( 'the function supports non-square matrices (M < N, column-major, increasin x = new Float32Array( [ 2.0, 3.0 ] ); out = new Float32Array( 8 ); + // 2x4 column-major: strideOut1=1, strideOut2=2 svander( 1, 2, 4, x, 1, 0, out, 1, 2, 0 ); expected = new Float32Array( [ 1.0, 1.0, 2.0, 3.0, 4.0, 9.0, 8.0, 27.0 ] ); @@ -438,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 Float32Array([ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]); + out = new Float32Array( 6 ); + + svander( 1, 2, 3, x, 2, 1, out, 3, -1, 2 ); + + expected = new Float32Array( [ 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 Float32Array( [ 0.0, 2.0 ] ); + out = new Float32Array( 6 ); + + svander( 1, 2, 3, x, 1, 0, out, 3, 1, 0 ); + + expected = new Float32Array( [ 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 Float32Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float32Array( 3 ); + + svander( 1, 3, 1, x, 1, 0, out, 1, 1, 0 ); + + // Single column: all x^0 = 1 + expected = new Float32Array( [ 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 Float32Array( [ 3.0 ] ); + out = new Float32Array( 4 ); + + svander( 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 Float32Array( [ 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 Float32Array( [ 1.0, 2.0 ] ); + out = new Float32Array( 8 ); + + // Column-major 2x2 starting at offset 2, with strideOut2=3 (padding of 1) + svander( 1, 2, 2, x, 1, 0, out, 1, 3, 2 ); + + expected = new Float32Array( [ 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/svander/test/test.svander.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js index 32cc80a43d3a..08c11f221480 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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() { - svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, new Float32Array( 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 Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + + // Create an offset view: + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + out = new Float32Array( 9 ); + + svander( 'row-major', 1, 3, 3, x1, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 0.0, 2.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 1, 2, 3, x, 1, out, 3 ); + + expected = new Float32Array( [ 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 Float32Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float32Array( 3 ); + + svander( 'row-major', 1, 3, 1, x, 1, out, 1 ); + + // Single column: all x^0 = 1 + expected = new Float32Array( [ 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 Float32Array( [ 3.0 ] ); + out = new Float32Array( 4 ); + + svander( '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 Float32Array( [ 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/svander/test/test.svander.native.js b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js index 1f945b0b73de..546e14b3f943 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/test/test.svander.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() { - svander( 'row-major', -1, 3, 3, new Float32Array( [ 1.0, 2.0, 3.0 ] ), value, new Float32Array( 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,11 +282,12 @@ 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; + // Pick every other element: x[0]=1.0, x[2]=3.0 x = new Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); @@ -318,27 +299,30 @@ 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; + // Negative stride: starts from last and goes backward x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); svander( 'row-major', -1, 2, 3, x, -2, out, 3 ); + // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 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 ) { +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 Float32Array( [ 1.0, 0.0, 3.0, 0.0 ] ); out = new Float32Array( 6 ); @@ -350,16 +334,18 @@ 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; + // Negative stride: starts from last and goes backward x = new Float32Array( [ 3.0, 0.0, 1.0 ] ); out = new Float32Array( 6 ); svander( 'column-major', -1, 2, 3, x, -2, out, 2 ); + // x[2]=1.0 (first), x[0]=3.0 (second) expected = new Float32Array( [ 1.0, 9.0, 1.0, 3.0, 1.0, 1.0 ] ); t.deepEqual( out, expected, 'returns expected value' ); @@ -374,6 +360,7 @@ tape( 'the function supports an `ldo` larger than the matrix dimension (row-majo x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 10 ); + // 2x3 row-major with ldo=5 (padding of 2 per row) svander( 'row-major', -1, 2, 3, x, 1, out, 5 ); expected = new Float32Array([ @@ -401,6 +388,7 @@ tape( 'the function supports an `ldo` larger than the matrix dimension (column-m x = new Float32Array( [ 1.0, 2.0 ] ); out = new Float32Array( 12 ); + // 2x3 column-major with ldo=4 (padding of 2 per column) svander( 'column-major', -1, 2, 3, x, 1, out, 4 ); expected = new Float32Array([ @@ -432,6 +420,7 @@ tape( 'the function supports non-square matrices (M > N, row-major, decreasing)' svander( 'row-major', -1, 3, 2, x, 1, out, 2 ); + // 3x2 matrix, decreasing: expected = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); t.deepEqual( out, expected, 'returns expected value' ); @@ -448,8 +437,91 @@ tape( 'the function supports non-square matrices (M < N, row-major, increasing)' svander( 'row-major', 1, 2, 4, x, 1, out, 4 ); + // 2x4 matrix, increasing: expected = new Float32Array( [ 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 view offsets', opts, function test( t ) { + var expected; + var out; + var x0; + var x1; + + // Initial array: + x0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + + // Create an offset view: + x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + + out = new Float32Array( 9 ); + + svander( 'row-major', 1, 3, 3, x1, 1, out, 3 ); + + expected = new Float32Array([ + 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 Float32Array( [ 0.0, 2.0 ] ); + out = new Float32Array( 6 ); + + svander( 'row-major', 1, 2, 3, x, 1, out, 3 ); + + expected = new Float32Array( [ 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 Float32Array( [ 5.0, 10.0, 15.0 ] ); + out = new Float32Array( 3 ); + + svander( 'row-major', 1, 3, 1, x, 1, out, 1 ); + + // Single column: all x^0 = 1 + expected = new Float32Array( [ 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 Float32Array( [ 3.0 ] ); + out = new Float32Array( 4 ); + + svander( '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 Float32Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 6599710222dcacfccb4821544cc082bbb5c74f2e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 17 Apr 2026 17:28:34 +0500 Subject: [PATCH 13/13] fix: apply suggestion 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/svander/src/addon.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c index c28efa9ced43..d0192619432c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/svander/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/svander/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_FLOAT( 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_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 7 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( 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_FLOAT32ARRAY( env, X, M, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY2D( env, Out, M, N, sa1, sa2, argv, 6 ); + API_SUFFIX(stdlib_strided_svander)( order, mode, M, N, X, strideX, Out, LDO ); + return NULL; }