diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/README.md new file mode 100644 index 000000000000..16d34b0da99e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/README.md @@ -0,0 +1,171 @@ + + +# svander + +> Generate a single-precision floating-point Vandermonde matrix. + +
+ +
+ + + +
+ +## Usage + +```javascript +var svander = require( '@stdlib/blas/ext/base/ndarray/svander' ); +``` + +#### svander( arrays ) + +Generates a single-precision floating-point Vandermonde matrix. + +```javascript +var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +var out = zeros( [ 3, 3 ], { + 'dtype': 'float32' +}); + +var mode = scalar2ndarray( 1, { + 'dtype': 'float32' +}); + +var v = svander( [ x, out, mode ] ); +// returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 2.0, 4.0 ], [ 1.0, 3.0, 9.0 ] ] + +var bool = ( v === out ); +// returns true +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a two-dimensional output ndarray. + - a zero-dimensional ndarray specifying the mode. + +Let the output ndarray have shape `[M, N]`. When the mode is positive, the matrix is generated such that + +```text +[ + 1 x_0^1 x_0^2 ... x_0^(N-1) + 1 x_1^1 x_1^2 ... x_1^(N-1) + ... +] +``` + +with increasing powers along the rows. + +When the mode is negative, the matrix is generated such that + +```text +[ + x_0^(N-1) ... x_0^2 x_0^1 1 + x_1^(N-1) ... x_1^2 x_1^1 1 + ... +] +``` + +with decreasing powers along the rows. + +
+ + + +
+ +## Notes + +- Let the output ndarray have shape `[M, N]`. If `M <= 0` or `N <= 0`, the function returns the output ndarray unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var svander = require( '@stdlib/blas/ext/base/ndarray/svander' ); + +var M = 3; +var N = 4; + +var opts = { + 'dtype': 'float32' +}; + +var x = discreteUniform( [ M ], 0, 10, opts ); +console.log( ndarray2array( x ) ); + +var out = zeros( [ M, N ], opts ); + +var mode = scalar2ndarray( -1, { + 'dtype': 'float32' +}); + +var v = svander( [ x, out, mode ] ); +console.log( ndarray2array( v ) ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/benchmark/benchmark.js new file mode 100644 index 000000000000..f7752b420659 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/benchmark/benchmark.js @@ -0,0 +1,115 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pkg = require( './../package.json' ).name; +var svander = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var mode; + var out; + var x; + + x = uniform( [ len ], -10.0, 10.0, options ); + out = zeros( [ len, len ], options ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = svander( [ x, out, mode ] ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnanf( v.get( i%len, i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/repl.txt new file mode 100644 index 000000000000..de9e1820a83d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/repl.txt @@ -0,0 +1,54 @@ + +{{alias}}( arrays ) + Generates a single-precision floating-point Vandermonde matrix. + + Let the output ndarray have shape `[M, N]`. When the mode is + positive, the matrix is generated such that + + [ + 1 x_0^1 x_0^2 ... x_0^(N-1) + 1 x_1^1 x_1^2 ... x_1^(N-1) + ... + ] + + with increasing powers along the rows. + + When the mode is negative, the matrix is generated such that + + [ + x_0^(N-1) ... x_0^2 x_0^1 1 + x_1^(N-1) ... x_1^2 x_1^1 1 + ... + ] + + with decreasing powers along the rows. + + If `M <= 0` or `N <= 0`, the function returns the output ndarray + unchanged. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a two-dimensional output ndarray. + - a zero-dimensional ndarray specifying the mode. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var x = new {{alias:@stdlib/ndarray/vector/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var out = {{alias:@stdlib/ndarray/zeros}}( [ 3, 3 ], { 'dtype': 'float32' } ); + > var mode = {{alias:@stdlib/ndarray/from-scalar}}( 1, { 'dtype': 'float32' } ); + > {{alias}}( [ x, out, mode ] ); + > out + [ [ 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/ndarray/svander/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/types/index.d.ts new file mode 100644 index 000000000000..76afd55b9e29 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/types/index.d.ts @@ -0,0 +1,64 @@ +/* +* @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 { float32ndarray, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Generates a single-precision floating-point Vandermonde matrix. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a two-dimensional output ndarray. +* - a zero-dimensional ndarray specifying the mode. +* +* @param arrays - array-like object containing ndarrays +* @returns output ndarray +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var out = zeros( [ 3, 3 ], { +* 'dtype': 'float32' +* }); +* +* var mode = scalar2ndarray( 1, { +* 'dtype': 'float32' +* }); +* +* var v = svander( [ x, out, mode ] ); +* // returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 2.0, 4.0 ], [ 1.0, 3.0, 9.0 ] ] +* +* var bool = ( v === out ); +* // returns true +*/ +declare function svander( arrays: [ float32ndarray, float32ndarray, typedndarray ] ): float32ndarray; + + +// EXPORTS // + +export = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/types/test.ts new file mode 100644 index 000000000000..bfdba0bf7b16 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/docs/types/test.ts @@ -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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import svander = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const out = zeros( [ 3, 3 ], { + 'dtype': 'float32' + }); + const mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + + svander( [ x, out, mode ] ); // $ExpectType float32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + svander( '10' ); // $ExpectError + svander( 10 ); // $ExpectError + svander( true ); // $ExpectError + svander( false ); // $ExpectError + svander( null ); // $ExpectError + svander( undefined ); // $ExpectError + svander( [] ); // $ExpectError + svander( {} ); // $ExpectError + svander( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 3 ], { + 'dtype': 'float32' + }); + const out = zeros( [ 3, 3 ], { + 'dtype': 'float32' + }); + const mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + + svander(); // $ExpectError + svander( [ x, out, mode ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/examples/index.js new file mode 100644 index 000000000000..032f5802161d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/examples/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var svander = require( './../lib' ); + +var M = 3; +var N = 4; + +var opts = { + 'dtype': 'float32' +}; + +var x = discreteUniform( [ M ], 0, 10, opts ); +console.log( ndarray2array( x ) ); + +var out = zeros( [ M, N ], opts ); + +var mode = scalar2ndarray( -1, { + 'dtype': 'float32' +}); + +var v = svander( [ x, out, mode ] ); +console.log( ndarray2array( v ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/index.js new file mode 100644 index 000000000000..7e20a0ab8238 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/index.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Generate a single-precision floating-point Vandermonde matrix. +* +* @module @stdlib/blas/ext/base/ndarray/svander +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var svander = require( '@stdlib/blas/ext/base/ndarray/svander' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var out = zeros( [ 3, 3 ], { +* 'dtype': 'float32' +* }); +* +* var mode = scalar2ndarray( 1, { +* 'dtype': 'float32' +* }); +* +* var v = svander( [ x, out, mode ] ); +* // returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 2.0, 4.0 ], [ 1.0, 3.0, 9.0 ] ] +* +* var bool = ( v === out ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/main.js new file mode 100644 index 000000000000..35862f860f97 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/lib/main.js @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var getShape = require( '@stdlib/ndarray/base/shape' ); +var getStrides = require( '@stdlib/ndarray/base/strides' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/blas/ext/base/svander' ).ndarray; + + +// MAIN // + +/** +* Generates a single-precision floating-point Vandermonde matrix. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a two-dimensional output ndarray. +* - a zero-dimensional ndarray specifying the mode. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {Object} output ndarray +* +* @example +* var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); +* var zeros = require( '@stdlib/ndarray/zeros' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = new Float32Vector( [ 1.0, 2.0, 3.0 ] ); +* var out = zeros( [ 3, 3 ], { +* 'dtype': 'float32' +* }); +* +* var mode = scalar2ndarray( 1, { +* 'dtype': 'float32' +* }); +* +* var v = svander( [ x, out, mode ] ); +* // returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 2.0, 4.0 ], [ 1.0, 3.0, 9.0 ] ] +* +* var bool = ( v === out ); +* // returns true +*/ +function svander( arrays ) { + var mode; + var out; + var sh; + var so; + var x; + + x = arrays[ 0 ]; + out = arrays[ 1 ]; + mode = ndarraylike2scalar( arrays[ 2 ] ); + + sh = getShape( out, false ); + so = getStrides( out, false ); + + strided( mode, sh[ 0 ], sh[ 1 ], getData( x ), getStride( x, 0 ), getOffset( x ), getData( out ), so[ 0 ], so[ 1 ], getOffset( out ) ); // eslint-disable-line max-len + return out; +} + + +// EXPORTS // + +module.exports = svander; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/package.json new file mode 100644 index 000000000000..fbca463127f5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/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", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "svander", + "vandermonde", + "matrix", + "generate", + "ndarray", + "array", + "typed", + "strided", + "float32", + "float", + "single", + "float32array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/test/test.js new file mode 100644 index 000000000000..01bdb7e13abc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/svander/test/test.js @@ -0,0 +1,476 @@ +/** +* @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 scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var svander = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} N - number of elements +* @param {integer} stride - stride +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, N, stride, offset ) { + return new ndarray( 'float32', new Float32Array( buffer ), [ N ], [ stride ], offset, 'row-major' ); +} + +/** +* Returns a two-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} M - number of rows +* @param {NonNegativeInteger} N - number of columns +* @param {integer} stride0 - stride of the first dimension +* @param {integer} stride1 - stride of the second dimension +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} two-dimensional ndarray +*/ +function matrix( buffer, M, N, stride0, stride1, offset ) { + return new ndarray( 'float32', new Float32Array( buffer ), [ M, N ], [ stride0, stride1 ], offset, 'row-major' ); +} + + +// 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 1', function test( t ) { + t.strictEqual( svander.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, increasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, 3, 1, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (row-major, decreasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, 3, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, increasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, 1, 3, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 4.0, 9.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Vandermonde matrix (column-major, decreasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, 1, 3, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 4.0, 9.0, 1.0, 2.0, 3.0, 1.0, 1.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the output ndarray', function test( t ) { + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0 ], 2, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0 ], 2, 2, 2, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an empty input ndarray, the function returns the output ndarray unchanged', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + out = matrix( [ 3.0, 4.0, 5.0, 6.0 ], 0, 3, 3, 1, 0 ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 6.0 ] ); + + x = vector( [], 0, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if not provided an output ndarray with at least one column, the function returns the output ndarray unchanged', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + out = matrix( [ 3.0, 4.0, 5.0, 6.0 ], 2, 0, 0, 1, 0 ); + expected = new Float32Array( [ 3.0, 4.0, 5.0, 6.0 ] ); + + x = vector( [ 1.0, 2.0 ], 2, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports input ndarrays with strides', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 0.0, 3.0, 0.0 ], 2, 2, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 3, 3, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports input ndarrays with negative strides', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 3.0, 0.0, 1.0 ], 2, -2, 2 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 3, 3, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 9.0, 3.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports ndarrays having non-zero offsets', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 0.0, 1.0, 2.0, 3.0 ], 3, 1, 1 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, 3, 1, 2 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output ndarrays with negative strides', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 3, -3, 1, 6 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 3.0, 9.0, 1.0, 2.0, 4.0, 1.0, 1.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output ndarrays with non-unit strides (row-major)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0 ], 2, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 3, 5, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array([ + 1.0, + 1.0, + 1.0, + 0.0, + 0.0, + 4.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports output ndarrays with non-unit strides (column-major)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0 ], 2, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 3, 1, 4, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + 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.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M > N, row-major, decreasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 1.0, 2.0, 3.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3, 2, 2, 1, 0 ); + + mode = scalar2ndarray( -1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 2.0, 1.0, 3.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (M < N, row-major, increasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 2.0, 3.0 ], 2, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 4, 4, 1, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 2.0, 4.0, 8.0, 1.0, 3.0, 9.0, 27.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles zero values in the input ndarray (row-major, increasing)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 0.0, 2.0 ], 2, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 2, 3, 3, 1, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 0.0, 0.0, 1.0, 2.0, 4.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single column (N=1)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 5.0, 10.0, 15.0 ], 3, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0 ], 3, 1, 1, 1, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a single row (M=1)', function test( t ) { + var expected; + var mode; + var out; + var x; + var v; + + x = vector( [ 3.0 ], 1, 1, 0 ); + out = matrix( [ 0.0, 0.0, 0.0, 0.0 ], 1, 4, 4, 1, 0 ); + + mode = scalar2ndarray( 1, { + 'dtype': 'float32' + }); + v = svander( [ x, out, mode ] ); + + expected = new Float32Array( [ 1.0, 3.0, 9.0, 27.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( getData( v ), expected, 'returns expected value' ); + t.end(); +});