diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/README.md b/lib/node_modules/@stdlib/lapack/base/dpoequ/README.md new file mode 100644 index 000000000000..e5a016703210 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/README.md @@ -0,0 +1,265 @@ + + +# dpoequ + +> Compute row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. + +
+ +## Usage + +```javascript +var dpoequ = require( '@stdlib/lapack/base/dpoequ' ); +``` + +#### dpoequ( order, N, A, LDA, S, scond, amax ) + +Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +var S = new Float64Array( 2 ); +var scond = new Float64Array( 1 ); +var amax = new Float64Array( 1 ); + +var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +// returns 0 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: order of matrix. +- **A**: input symmetric positive definite [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **S**: [`Float64Array`][mdn-float64array] containing scale factors. +- **scond**: [`Float64Array`][mdn-float64array] containing the ratio of the smallest to the largest scale factors. +- **amax**: [`Float64Array`][mdn-float64array] containing the absolute value of the largest matrix element. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 2.0, 4.0 ] ); +var S0 = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +var scond0 = new Float64Array( [ 0.0, 0.0 ] ); +var amax0 = new Float64Array( [ 0.0, 0.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var S1 = new Float64Array( S0.buffer, S0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var scond1 = new Float64Array( scond0.buffer, scond0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var amax1 = new Float64Array( amax0.buffer, amax0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = dpoequ( 'row-major', 2, A1, 2, S1, scond1, amax1 ); +// returns 0 +``` + +#### dpoequ.ndarray( N, A, sa1, sa2, oa, S, ss, os, sc, osc, am, oam ) + +Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A` using alternative semantic indexing. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +var S = new Float64Array( 2 ); +var scond = new Float64Array( 1 ); +var amax = new Float64Array( 1 ); + +var out = dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); +// returns 0 +``` + +The function has the following parameters: + +- **N**: order of matrix. +- **A**: input symmetric positive definite [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **S**: [`Float64Array`][mdn-float64array] containing scale factors. +- **ss**: stride length of `S`. +- **os**: starting index for `S`. +- **sc**: [`Float64Array`][mdn-float64array] containing the ratio of the smallest to the largest scale factors. +- **osc**: starting index for `sc`. +- **am**: [`Float64Array`][mdn-float64array] containing the absolute value of the largest matrix element. +- **oam**: starting index for `am`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 1.0, 2.0, 2.0, 4.0 ] ); +var S = new Float64Array( 2 ); +var scond = new Float64Array( 1 ); +var amax = new Float64Array( 1 ); + +var out = dpoequ.ndarray( 2, A, 2, 1, 1, S, 1, 0, scond, 0, amax, 0 ); +// returns 0 +``` + +
+ + + +
+ +## Notes + +- Both functions return a status code indicating success or failure. A status code indicates the following conditions: + + - `0`: factorization was successful. + - `<0`: the k-th argument had an illegal value, where `-k` equals the status code value. + - `0 < k < N`: the k-th argument had a non-positive value. + +- `dpoequ()` corresponds to the [LAPACK][lapack] routine [`dpoequ`][lapack-dpoequ]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dpoequ = require( '@stdlib/lapack/base/dpoequ' ); + +var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +var S = new Float64Array( 2 ); +var scond = new Float64Array( 1 ); +var amax = new Float64Array( 1 ); + +var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +console.log( out ); +console.log( scond ); +console.log( amax ); +console.log( S ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.js new file mode 100644 index 000000000000..e4200b4eaa4f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dpoequ = require( './../lib/dpoequ.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var scond = uniform( 1, 1.0, 100.0, options ); + var amax = uniform( 1, 1.0, 100.0, options ); + var A = uniform( len, 1.0, 100.0, options ); + var S = uniform( 2, 1.0, 100.0, options ); + + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dpoequ( 'row-major', len, A, len, S, scond, amax); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..6ede8bcd8529 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/benchmark/benchmark.ndarray.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dpoequ = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var scond = uniform( 1, 1.0, 100.0, options ); + var amax = uniform( 1, 1.0, 100.0, options ); + var A = uniform( len, 1.0, 100.0, options ); + var S = uniform( 2, 1.0, 100.0, options ); + + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dpoequ( len, A, len, 1, 0, S, 1, 0, scond, 0, amax, 0 ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/repl.txt new file mode 100644 index 000000000000..bd5765fb3d80 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/repl.txt @@ -0,0 +1,139 @@ + +{{alias}}( order, N, A, LDA, S, scond, amax ) + Computes row and column scalings intended to equilibrate a symmetric + positive definite matrix `A`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Order of matrix. + + A: Float64Array + Input symmetric positive definite matrix. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + S: Float64Array + Array containing scale factors. + + scond: Float64Array + Array containing the ratio of the smallest to the largest scale + factors. + + amax: Float64Array + Array contacontaining the absolute value of the largest matrix element. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then the leading principal minor of order `k` is + not positive, where `k = info`. If `k < N`, then the factorization + could not be completed. If `k = N`, then the factorization was + completed, but `D(N) <= 0`, meaning that the matrix `A` is not + positive definite. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 2.0, 4.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > var scond = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > var amax = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > {{alias}}( 'row-major', 2, A, 2, S, scond, amax ) + 0 + > S + [ 1.0, 0.5 ] + > scond + [ 0.5 ] + > amax + [ 4.0 ] + + +{{alias}}.ndarray( N, A, sa1, sa2, oa, S, ss, os, sc, osc, am, oam ) + Computes row and column scalings intended to equilibrate a symmetric + positive definite matrix `A` using alternative semantic indexing. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Order of matrix. + + A: Float64Array + Input symmetric positive definite matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + S: Float64Array + Array containing scale factors. + + ss: integer + Stride length of `S`. + + os: integer + Starting index for `S`. + + sc: Float64Array + Array containing the ratio of the smallest to the largest scale + factors. + + osc: integer + Starting index for `sc`. + + am: Float64Array + Array contacontaining the absolute value of the largest matrix element. + + oam: integer + Starting index for `am`. + + Returns + ------- + info: integer + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then the k-th argument had a non-positive + value, where `k = info`. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 2.0, 4.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > var scond = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > var amax = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > {{alias}}.ndarray( 2, A, 2, 1, 1, S, 1, 1, scond, 1, amax, 1 ) + 0 + > S + [ 0.0, 1.0, 0.5 ] + > scond + [ 0.0, 0.5 ] + > amax + [ 0.0, 4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/index.d.ts new file mode 100644 index 000000000000..2e2d9042f019 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/index.d.ts @@ -0,0 +1,137 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* Status code. +* +* ## Notes +* +* The status code indicates the following conditions: +* +* - if equal to zero, then the factorization was successful. +* - if less than zero, then the k-th argument had an illegal value, where `k = -StatusCode`. +* - if greater than zero, then the leading principal minor of order `k` is not positive, where `k = StatusCode`. If `k < N`, then the factorization could not be completed. If `k = N`, then the factorization was completed, but `D(N) <= 0`, meaning that the matrix `A` is not positive definite. +*/ +type StatusCode = number; + +/** +* Interface describing `dpoequ`. +*/ +interface Routine { + /** + * Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. + * + * @param order - storage layout + * @param N - order of matrix + * @param A - symmetric positive definite matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param S - array containing scale factors + * @param scond - array containing the ratio of smallest to largest scale factors + * @param amax - array containing absolute value of largest matrix element + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + * var S = new Float64Array( 2 ); + * var scond = new Float64Array( 1 ); + * var amax = new Float64Array( 1 ); + * + * var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); + * // returns 0 + */ + ( order: Layout, N: number, A: Float64Array, LDA: number, S: Float64Array, scond: Float64Array, amax: Float64Array ): number; + + /** + * Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A` using alternative semantic indexing. + * + * @param N - order of matrix + * @param A - symmetric positive definite matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param S - array containing scale factors + * @param strideS - stride length of `S` + * @param offsetS - starting index for `S` + * @param scond - array containing the ratio of smallest to largest scale factors + * @param offsetSC - starting index for `scond` + * @param amax - array containing absolute value of largest matrix element + * @param offsetAM - starting index for `amax` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + * var S = new Float64Array( 2 ); + * var scond = new Float64Array( 1 ); + * var amax = new Float64Array( 1 ); + * + * var out = dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); + * // returns 0 + */ + ndarray( N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, S: Float64Array, strideS: number, offsetS: number, scond: Float64Array, offsetSC: number, amax: Float64Array, offsetAM: number ): number; +} + +/** +* Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. +* +* @param order - storage layout +* @param N - order of matrix +* @param A - symmetric positive definite matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param S - array containing scale factors +* @param scond - array containing the ratio of smallest to largest scale factors +* @param amax - array containing absolute value of largest matrix element +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); +* // returns 0 +*/ +declare var dpoequ: Routine; + + +// EXPORTS // + +export = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/test.ts new file mode 100644 index 000000000000..525f97f29df1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/docs/types/test.ts @@ -0,0 +1,404 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dpoequ = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, A, 2, S, SCOND, AMAX ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 5, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( true, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( false, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( null, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( void 0, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( [], 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( {}, 2, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( ( x: number ): number => x, 2, A, 2, S, SCOND, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', '5', A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', true, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', false, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', null, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', void 0, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', [], A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', {}, A, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', ( x: number ): number => x, A, 2, S, SCOND, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, '5', 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, 5, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, true, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, false, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, null, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, void 0, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, [], 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, {}, 2, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, ( x: number ): number => x, 2, S, SCOND, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, A, '5', S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, true, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, false, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, null, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, void 0, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, [], S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, {}, S, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, ( x: number ): number => x, S, SCOND, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, A, 2, '5', SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, 5, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, true, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, false, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, null, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, void 0, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, [], SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, {}, SCOND, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, ( x: number ): number => x, SCOND, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, A, 2, S, '5', AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, 5, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, true, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, false, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, null, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, void 0, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, [], AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, {}, AMAX ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, ( x: number ): number => x, AMAX ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + + dpoequ( 'row-major', 2, A, 2, S, SCOND, '5' ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, 5 ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, true ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, false ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, null ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, void 0 ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, [] ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, {} ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ(); // $ExpectError + dpoequ( 'row-major' ); // $ExpectError + dpoequ( 'row-major', 2 ); // $ExpectError + dpoequ( 'row-major', 2, A ); // $ExpectError + dpoequ( 'row-major', 2, A, 2 ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND ); // $ExpectError + dpoequ( 'row-major', 2, A, 2, S, SCOND, AMAX, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( '5', A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( true, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( false, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( null, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( void 0, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( [], A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( {}, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( ( x: number ): number => x, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, '5', 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, 5, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, true, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, false, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, null, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, void 0, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, [], 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, {}, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, ( x: number ): number => x, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, '5', 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, true, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, false, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, null, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, void 0, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, [], 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, {}, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, ( x: number ): number => x, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, '5', 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, true, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, false, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, null, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, void 0, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, [], 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, {}, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, ( x: number ): number => x, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, '5', S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, true, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, false, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, null, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, void 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, [], S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, {}, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, ( x: number ): number => x, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, '5', 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, 5, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, true, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, false, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, null, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, void 0, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, [], 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, {}, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, '5', 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, true, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, false, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, null, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, void 0, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, [], 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, {}, 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, ( x: number ): number => x, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, '5', SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, true, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, false, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, null, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, void 0, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, [], SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, {}, SCOND, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, ( x: number ): number => x, SCOND, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, '5', 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, 5, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, true, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, false, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, null, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, void 0, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, [], 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, {}, 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, ( x: number ): number => x, 0, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, '5', AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, true, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, false, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, null, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, void 0, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, [], AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, {}, AMAX, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, ( x: number ): number => x, AMAX, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, '5', 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, 5, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, true, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, false, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, null, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, void 0, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, [], 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, {}, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, '5' ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, true ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, false ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, null ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, void 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, [] ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, {} ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + const S = new Float64Array( [ 0.0 ] ); + const SCOND = new Float64Array( [ 0.0 ] ); + const AMAX = new Float64Array( [ 0.0 ] ); + + dpoequ.ndarray(); // $ExpectError + dpoequ.ndarray( 2 ); // $ExpectError + dpoequ.ndarray( 2, A ); // $ExpectError + dpoequ.ndarray( 2, A, 2 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0 ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX ); // $ExpectError + dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/examples/index.js new file mode 100644 index 000000000000..8b70385b70b2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/examples/index.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var dpoequ = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +var S = new Float64Array( 2 ); +var scond = new Float64Array( 1 ); +var amax = new Float64Array( 1 ); + +var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +console.log( out ); +console.log( scond ); +console.log( amax ); +console.log( S ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/base.js new file mode 100644 index 000000000000..8cb7c09bd873 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/base.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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, max-params */ + +'use strict'; + +// MODULES // + +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); + + +// MAIN // + +/** +* Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. +* +* @private +* @param {NonNegativeInteger} N - order of matrix +* @param {Float64Array} A - symmetric positive definite matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} S - array containing scale factors +* @param {NonNegativeInteger} strideS - stride length of `S` +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} scond - array containing the ratio of smallest to largest scale factors +* @param {NonNegativeInteger} offsetSC - starting index for `scond` +* @param {Float64Array} amax - array containing absolute value of largest matrix element +* @param {NonNegativeInteger} offsetAM - starting index for `amax` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); +* // returns 0 +*/ +function dpoequ( N, A, strideA1, strideA2, offsetA, S, strideS, offsetS, scond, offsetSC, amax, offsetAM ) { + var smin; + var i; + + if ( N === 0 ) { + scond[ offsetSC ] = 1.0; + amax[ offsetAM ] = 0.0; + return 0; + } + + // Find the minimum and maximum diagonal elements. + S[ offsetS ] = A[ offsetA ]; + smin = S[ offsetS ]; + amax[ offsetAM ] = S[ offsetS ]; + for ( i = 1; i < N; i++ ) { + S[ offsetS + ( i * strideS ) ] = A[ offsetA + ( i * strideA1 ) + ( i * strideA2 ) ]; + smin = min( smin, S[ offsetS + ( i * strideS ) ] ); + amax[ offsetAM ] = max( amax[ offsetAM ], S[ offsetS + ( i * strideS ) ] ); + } + if ( smin <= 0.0 ) { + // Find the first non-positive diagonal element and return. + for ( i = 0; i < N; i++ ) { + if ( S[ offsetS + ( i * strideS ) ] <= 0.0 ) { + return i; + } + } + } + // Set the scale factors to the reciprocal of the square root of the diagonal elements. + for ( i = 0; i < N; i++ ) { + S[ offsetS + ( i * strideS ) ] = 1.0 / sqrt( S[ offsetS + ( i * strideS ) ] ); + } + // Compute scond = min(S) / max(S). + scond[ offsetSC ] = sqrt( smin ) / sqrt( amax[ offsetAM ] ); + return 0; +} + + +// EXPORTS // + +module.exports = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/dpoequ.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/dpoequ.js new file mode 100644 index 000000000000..1f7c64724232 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/dpoequ.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} N - order of matrix +* @param {Float64Array} A - symmetric positive definite matrix +* @param {NonNegativeInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} S - array containing scale factors +* @param {Float64Array} scond - array containing the ratio of smallest to largest scale factors +* @param {Float64Array} amax - array containing absolute value of largest matrix element +* @throws {TypeError} first argument must be a valid order +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +* // returns 0 +*/ +function dpoequ( order, N, A, LDA, S, scond, amax ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( N, A, sa1, sa2, 0, S, 1, 0, scond, 0, amax, 0 ); +} + + +// EXPORTS // + +module.exports = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/index.js new file mode 100644 index 000000000000..a04617b020b6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* LAPACK routine to compute row and column scalings intended to equilibrate a symmetric positive definite matrix `A`. +* +* @module @stdlib/lapack/base/dpoequ +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dpoequ = require( '@stdlib/lapack/base/dpoequ' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dpoequ = require( '@stdlib/lapack/base/dpoequ' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ.ndarray( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); +* // returns 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 dpoequ; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dpoequ = main; +} else { + dpoequ = tmp; +} + + +// EXPORTS // + +module.exports = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/main.js new file mode 100644 index 000000000000..1f8c6b2ddb52 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dpoequ = require( './dpoequ.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dpoequ, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/ndarray.js new file mode 100644 index 000000000000..75c99621de6f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/lib/ndarray.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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, max-params */ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes row and column scalings intended to equilibrate a symmetric positive definite matrix `A` using alternative semantic indexing. +* +* @param {NonNegativeInteger} N - order of matrix +* @param {Float64Array} A - symmetric positive definite matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} S - array containing scale factors +* @param {NonNegativeInteger} strideS - stride length of `S` +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} scond - array containing the ratio of smallest to largest scale factors +* @param {NonNegativeInteger} offsetSC - starting index for `scond` +* @param {Float64Array} amax - array containing absolute value of largest matrix element +* @param {NonNegativeInteger} offsetAM - starting index for `amax` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); +* var S = new Float64Array( 2 ); +* var scond = new Float64Array( 1 ); +* var amax = new Float64Array( 1 ); +* +* var out = dpoequ( 2, A, 2, 1, 0, S, 1, 0, scond, 0, amax, 0 ); +* // returns 0 +*/ +function dpoequ( N, A, strideA1, strideA2, offsetA, S, strideS, offsetS, scond, offsetSC, amax, offsetAM ) { + return base( N, A, strideA1, strideA2, offsetA, S, strideS, offsetS, scond, offsetSC, amax, offsetAM ); +} + + +// EXPORTS // + +module.exports = dpoequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/package.json b/lib/node_modules/@stdlib/lapack/base/dpoequ/package.json new file mode 100644 index 000000000000..e40f1de7bd3c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/lapack/base/dpoequ", + "version": "0.0.0", + "description": "Computes row and column scalings intended to equilibrate a symmetric positive definite 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", + "lapack", + "dpoequ", + "scaling", + "equilibrate", + "cholesky", + "triangular", + "symmetric", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.dpoequ.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.dpoequ.js new file mode 100644 index 000000000000..daaa983c13a8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.dpoequ.js @@ -0,0 +1,164 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dpoequ = require( './../lib/dpoequ.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dpoequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dpoequ.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 0.0, 4.0 ] ); + + 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() { + dpoequ( value, 2, A, 2, A, A, A ); + }; + } +}); + +tape( 'the function correctly computes row and column scalings intended to equilibrate a symmetric positive definite matrix', function test( t ) { + var scond; + var amax; + var out; + var A; + var S; + + A = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + S = new Float64Array( 2 ); + scond = new Float64Array( 1 ); + amax = new Float64Array( 1 ); + + out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, S, new Float64Array( [ 1.0, 0.5 ] ), 1.0 ); + isApprox( t, scond, new Float64Array( [ 0.5 ] ), 1.0 ); + isApprox( t, amax, new Float64Array( [ 4 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function returns the index of first non-positive diagonal element', function test( t ) { + var scond; + var amax; + var out; + var A; + var S; + + A = new Float64Array( [ 1.0, 2.0, 2.0, 0.0 ] ); + S = new Float64Array( [ 0.0, 0.0 ] ); + scond = new Float64Array( [ 0.0 ] ); + amax = new Float64Array( [ 0.0 ] ); + + out = dpoequ( 'row-major', 2, A, 2, S, scond, amax ); + t.strictEqual( out, 1, 'returns expected value' ); + isApprox( t, S, new Float64Array( [ 1.0, 0.0 ] ), 1.0 ); + isApprox( t, scond, new Float64Array( [ 0.0 ] ), 1.0 ); + isApprox( t, amax, new Float64Array( [ 1.0 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function sets scond to 1.0 and amax to 0.0 if the order of the matrix is 0', function test( t ) { + var scond; + var amax; + var out; + var A; + var S; + + A = new Float64Array( 0 ); + S = new Float64Array( 0 ); + scond = new Float64Array( 1 ); + amax = new Float64Array( 1 ); + + out = dpoequ( 'row-major', 0, A, 0, S, scond, amax ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, scond, new Float64Array( [ 1.0 ] ), 1.0 ); + isApprox( t, amax, new Float64Array( [ 0.0 ] ), 1.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.js new file mode 100644 index 000000000000..7800eeda8360 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dpoequ = 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 dpoequ, '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 dpoequ.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 dpoequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dpoequ, mock, 'returns expected value' ); + 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 dpoequ; + var main; + + main = require( './../lib/dpoequ.js' ); + + dpoequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dpoequ, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.ndarray.js new file mode 100644 index 000000000000..e380b07a6025 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpoequ/test/test.ndarray.js @@ -0,0 +1,102 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dpoequ = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dpoequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dpoequ.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports accessing elements from non-contiguous arrangement of rows and columns and in different order', function test( t ) { + var scond; + var amax; + var out; + var A; + var S; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 0, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 2, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 3, + 999, 999, 999, 999, 999, 999 + ]); + + S = new Float64Array( [ 999, 999, 0.0, 999, 0.0 ] ); + + scond = new Float64Array( [ 999, 999, 0.0, 999 ] ); + amax = new Float64Array( [ 999, 0.0, 999 ] ); + + out = dpoequ( 3, A, -12, -2, 35, S, 1, 2, scond, 2, amax, 1 ); + t.strictEqual( out, 0, 'returns expected value' ); + isApprox( t, S, new Float64Array( [ 999, 999, 0.5773502691896258, 0.7071067811865475, 1 ] ), 1.0 ); + isApprox( t, scond, new Float64Array( [ 999, 999, 0.5773502691896258, 999 ] ), 1.0 ); + isApprox( t, amax, new Float64Array( [ 999, 3.0, 999 ] ), 1.0 ); + t.end(); +});