diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/NOTICE b/lib/node_modules/@stdlib/lapack/base/dpbequ/NOTICE new file mode 100644 index 000000000000..3a19a9b0205e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/NOTICE @@ -0,0 +1,54 @@ +DPBEQU derives from unchanged Reference-LAPACK SRC/dpbequ.f at commit +2e5d9c1273435fbd953adb294ed603e4789afaba. The translation adds +finite-selected-diagonal and conservative disjointness requirements, +and retains the first tied extremum (an explicit mixed-zero source +deviation). The full original BSD license follows. + +Copyright (c) 1992-2025 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. +Copyright (c) 2000-2025 The University of California Berkeley. All + rights reserved. +Copyright (c) 2006-2025 The University of Colorado Denver. All rights + reserved. + +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/README.md b/lib/node_modules/@stdlib/lapack/base/dpbequ/README.md new file mode 100644 index 000000000000..f45af3216f37 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/README.md @@ -0,0 +1,362 @@ + + +# dpbequ + +> Compute diagonal scaling factors for a symmetric band matrix. + +
+ +Computes `S[i]=1/sqrt(A[i,i])`, `SCOND=sqrt(min(A[i,i]))/sqrt(max(A[i,i]))` and `AMAX=max(A[i,i])` for positive selected diagonals. The input band matrix is unchanged. Scalar `INFO` reports the first nonpositive diagonal; positive diagonals alone do not establish positive definiteness or numerical stability. These interfaces and support restrictions remain proposed package adaptations. + +
+ + + +
+ +## Usage + +```javascript +var dpbequ = require( '@stdlib/lapack/base/dpbequ' ); +``` + +#### dpbequ( order, uplo, N, KD, AB, LDAB, S, SCOND, AMAX ) + +Writes scaling factors and two scalar outputs and returns numeric `INFO`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AB = new Float64Array( [ 4.0, 16.0, 64.0 ] ); +var S = new Float64Array( 3 ); +var SCOND = new Float64Array( 1 ); +var AMAX = new Float64Array( 1 ); +var info = dpbequ( 'column-major', 'lower', 3, 0, AB, 1, S, SCOND, AMAX ); +// returns 0 +// S => [ 0.5, 0.25, 0.125 ] +// SCOND => [ 0.25 ] +// AMAX => [ 64 ] +``` + +- **order**: `'row-major'` (`101`) or `'column-major'` (`102`). +- **uplo**: `'upper'` (`121`) or `'lower'` (`122`); character selectors `'U'` and `'L'` are rejected. +- **N**, **KD**: nonnegative primitive safe integers, at most `2147483646`. +- **AB**: read-only intrinsic `Float64Array` containing the full `H`-by-`N` compact band view, `H=KD+1`. +- **LDAB**: primitive safe integer leading dimension; column-major requires `LDAB>=H`, row-major `LDAB>=max(1,N)`. +- **S**: output-only intrinsic `Float64Array` with `N` active scaling cells. +- **SCOND**, **AMAX**: mutable intrinsic `Float64Array` scalar outputs at index zero. + +For zero-based `i,j`, upper storage places `A(i,j)` in band row `KD+i-j`, lower in row `i-j`. Band cell `b,j` is `AB[b*LDAB+j]` row-major or `AB[b+j*LDAB]` column-major. Upper diagonals are in row `KD`, lower in row zero. `KD>=N` is supported. Only selected diagonals are numerically read, but the entire conservative `H`-by-`N` view is validated, including unused cells and padding envelopes. + + + +#### dpbequ.ndarray( uplo, N, KD, AB, strideAB1, strideAB2, offsetAB, S, strideS, offsetS, SCOND, offsetSCOND, AMAX, offsetAMAX ) + +Uses independent signed element strides and offsets relative to the actual typed-array views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AB = new Float64Array( [ 4.0, -0.0, 16.0, 25.0 ] ); +var S = new Float64Array( 4 ); +var SCOND = new Float64Array( [ -7.0 ] ); +var AMAX = new Float64Array( [ -9.0 ] ); +var info = dpbequ.ndarray( 'lower', 4, 0, AB, 1, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); +// returns 2 +// S => [ 4, -0, 16, 25 ] +// SCOND => [ -7 ] +// AMAX => [ 25 ] +``` + +Band cell `b,j` is `AB[offsetAB+b*strideAB1+j*strideAB2]`; output cell `j` is `S[offsetS+j*strideS]`. Scalar cells are `SCOND[offsetSCOND]` and `AMAX[offsetAMAX]`. Metadata must be primitive safe integers; active offsets are nonnegative. Full views must fit, be injective and have exactly representable products, corners and indexed byte sums. Used zero strides are rejected. Valid unused singleton strides need not enter arithmetic. + +
+ + + +
+ +## Notes + +- All selected diagonals must be finite before any output write. Ignored band or padding entries may be nonfinite; no full-value scan is performed. This finite-diagonal restriction is a proposed deviation from Reference-LAPACK. +- `INFO=0` writes all scaling factors and both scalar results. For positive `INFO`, every original selected diagonal is copied into `S`, `AMAX` includes all columns, and `SCOND` retains the caller's exact sentinel. `INFO` is the first one-based nonpositive diagonal, including negative zero. Failure is not a partial early diagonal copy. +- Strict comparisons retain the first tied extremum. On mixed negative/positive zero failures, the first zero sign is retained in `AMAX`; sampled GNU reference builds instead retain the last zero sign. No universal signed-zero, nonfinite or untested-platform bitwise parity is claimed. +- All four active conservative indexed byte envelopes must be pairwise disjoint, even though only the input diagonal is read. Disjoint envelopes may share one ordinary backing buffer. Overlapping gaps or unused band cells are still rejected; inputs are not copied to evade aliases. +- Active views require intrinsic `Float64Array` over ordinary `ArrayBuffer`, including current in-bounds resizable extents. Shared backing, cloned shared storage, proxies, detached and current out-of-bounds views are rejected. Captured intrinsics ignore shadowed metadata and support genuine crossrealm views and subclasses. +- Backing must remain stable and exclusive until synchronous return: no resize, detach, transfer, reentry or concurrent foreign mutation. Pure JavaScript cannot detect physical overlap between externally fabricated ordinary buffers with different identities; callers must guarantee physical disjointness. Native/C independently reject physical indexed-envelope overlaps, and these errors propagate without fallback. +- For `N=0`, validate selectors, dimensions, main `LDAB`, and only active `SCOND`/`AMAX` storage, offsets and mutual disjointness. Write `SCOND=1` and positive-zero `AMAX` and return zero. `AB`, `S` and their unused ndarray metadata are not inspected. Main leading-dimension bounds still apply. +- Native eligibility uses conservative signed32 metadata, products and corners before dispatch. Otherwise valid wider metadata uses the JavaScript kernel before mutation. Backend errors never trigger a retry after mutation. There is no numerical BLAS dependency, integer output staging or heap workspace; internal Node-API allocation is not a transactional engine-wide allocation guarantee. +- Invalid selectors, array brands or backing throw `TypeError`; invalid integer metadata, geometry, aliases or selected nonfinite diagonals throw `RangeError` before routine-owned writes. Type annotations cannot encode these runtime preconditions. +- The proposed Node engine floor is a feature/support declaration. Actual package execution uses Node24/Linux and does not certify Node16, other engines, native platforms or arbitrary toolchains. + +
+ + + +
+ +## Examples + +```javascript +'use strict'; + +// MODULES // + +var assert = require( 'assert' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dpbequ = require( '@stdlib/lapack/base/dpbequ' ); + + +// MAIN // + +// Only selected diagonals are read; ignored band entries may be nonfinite: +var AB = new Float64Array( [ 4.0, 16.0, 64.0, NaN, Infinity, 999.0 ] ); +var S = new Float64Array( 3 ); +var SCOND = new Float64Array( [ -7.0 ] ); +var AMAX = new Float64Array( [ -9.0 ] ); +var info = dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); +assert.strictEqual( info, 0 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '0.5,0.25,0.125' ); +assert.strictEqual( SCOND[ 0 ], 0.25 ); +assert.strictEqual( AMAX[ 0 ], 64.0 ); +assert.strictEqual( S[ 0 ]*S[ 0 ]*AB[ 0 ], 1.0 ); +assert.strictEqual( S[ 1 ]*S[ 1 ]*AB[ 1 ], 1.0 ); +assert.strictEqual( S[ 2 ]*S[ 2 ]*AB[ 2 ], 1.0 ); +console.log( 'INFO: %d; S: %s; SCOND: %d; AMAX: %d', info, Array.prototype.join.call( S, ', ' ), SCOND[ 0 ], AMAX[ 0 ] ); + +// Signed band/output strides and scalar offsets retain all guards: +AB = new Float64Array( [ 8.0, 64.0, 999.0, 16.0, 999.0, 4.0, 999.0, 8.0 ] ); +S = new Float64Array( [ 7.0, 7.0, 7.0, 7.0, 7.0 ] ); +SCOND = new Float64Array( [ 7.0, -7.0, 7.0 ] ); +AMAX = new Float64Array( [ 7.0, -9.0, 7.0 ] ); +info = dpbequ.ndarray( 'upper', 3, 1, AB, 1, -2, 4, S, -1, 3, SCOND, 1, AMAX, 1 ); +assert.strictEqual( info, 0 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '7,0.125,0.25,0.5,7' ); +assert.strictEqual( Array.prototype.join.call( SCOND, ',' ), '7,0.25,7' ); +assert.strictEqual( Array.prototype.join.call( AMAX, ',' ), '7,64,7' ); +assert.strictEqual( Array.prototype.join.call( AB, ',' ), '8,64,999,16,999,4,999,8' ); +console.log( 'Strided INFO: %d; guarded S: %s', info, Array.prototype.join.call( S, ', ' ) ); + +// Failure copies every diagonal and finds AMAX even in later columns: +AB = new Float64Array( [ 4.0, -0.0, 16.0, 25.0 ] ); +S = new Float64Array( 4 ); +SCOND = new Float64Array( [ -0.0 ] ); +AMAX = new Float64Array( [ -9.0 ] ); +info = dpbequ( 'column-major', 'lower', 4, 0, AB, 1, S, SCOND, AMAX ); +assert.strictEqual( info, 2 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '4,0,16,25' ); +assert.strictEqual( 1/S[ 1 ], -Infinity ); +assert.strictEqual( 1/SCOND[ 0 ], -Infinity ); +assert.strictEqual( AMAX[ 0 ], 25.0 ); +console.log( 'Failure INFO: %d; copied S: %s; AMAX: %d', info, Array.prototype.join.call( S, ', ' ), AMAX[ 0 ] ); + +// Strict-first AMAX preserves the first tied zero sign on failure: +AB = new Float64Array( [ -0.0, 0.0 ] ); +S = new Float64Array( 2 ); +info = dpbequ( 'row-major', 'lower', 2, 0, AB, 2, S, SCOND, AMAX ); +assert.strictEqual( info, 1 ); +assert.strictEqual( 1/AMAX[ 0 ], -Infinity ); +assert.strictEqual( 1/SCOND[ 0 ], -Infinity ); +console.log( 'Mixed-zero INFO: %d; first AMAX sign: %d', info, 1/AMAX[ 0 ] ); + +// Empty input ignores AB/S but validates and writes both active scalars: +info = dpbequ( 'column-major', 'upper', 0, 2, null, 3, null, SCOND, AMAX ); +assert.strictEqual( info, 0 ); +assert.strictEqual( SCOND[ 0 ], 1.0 ); +assert.strictEqual( 1/AMAX[ 0 ], Infinity ); +console.log( 'Empty INFO: %d; SCOND: %d; AMAX: %d', info, SCOND[ 0 ], AMAX[ 0 ] ); +``` + +
+ + + +
+ +## C APIs + +```c +#include "stdlib/lapack/base/dpbequ.h" +``` + +#### c_dpbequ( order, uplo, N, KD, AB, LDAB, S, SCOND, AMAX ) + +```c +LAPACK_INT API_SUFFIX(c_dpbequ)( const LAPACK_LAYOUT order, const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT LDAB, double *S, double *SCOND, double *AMAX ); +``` + + + +#### c_dpbequ_ndarray( uplo, N, KD, AB, strideAB1, strideAB2, offsetAB, S, strideS, offsetS, SCOND, offsetSCOND, AMAX, offsetAMAX ) + +```c +LAPACK_INT API_SUFFIX(c_dpbequ_ndarray)( const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT strideAB1, const LAPACK_INT strideAB2, const LAPACK_INT offsetAB, double *S, const LAPACK_INT strideS, const LAPACK_INT offsetS, double *SCOND, const LAPACK_INT offsetSCOND, double *AMAX, const LAPACK_INT offsetAMAX ); +``` + +Both return configured `LAPACK_INT` `INFO`; negative values identify prewrite argument errors (`-1` through `-9` main, `-1` through `-14` ndarray). Exact maps and validation precedence are documented in the public header. `LAPACK_ILP64` selects metadata width; API suffix configuration is independent. Raw `N/KD` are at most configured `MAX-1`; products, sums, magnitudes and physical byte envelopes cannot wrap. Minimum configured integer strides are rejected before negation on active calls. Caller storage must have sufficient capacity, double alignment and stable exclusive lifetime. Empty calls ignore input/vector pointers and inactive metadata but require two valid disjoint scalar cells. No numerical BLAS linkage is required. + +
+ +### Examples + +```c +#include "stdlib/lapack/base/dpbequ.h" +#include "stdlib/lapack/base/shared.h" +#include +#include +#include +#include + +/** +* Main execution sequence. +*/ +int main( void ) { + const double AB[] = { 4.0, 16.0, 64.0, NAN, INFINITY, 999.0 }; + double before[ 6 ]; + const double B[] = { 8.0, 64.0, 999.0, 16.0, 999.0, 4.0, 999.0, 8.0 }; + double T[] = { 7.0, 7.0, 7.0, 7.0, 7.0 }; + double C[] = { 7.0, -7.0, 7.0 }; + double M[] = { 7.0, -9.0, 7.0 }; + const double F[] = { 4.0, -0.0, 16.0, 25.0 }; + const double Z[] = { -0.0, 0.0 }; + double S[ 4 ] = { 0.0, 0.0, 0.0, 0.0 }; + double sc = -0.0; + double am = -9.0; + LAPACK_INT info; + + memcpy( before, AB, sizeof AB ); + info = API_SUFFIX(c_dpbequ)( LAPACK_ROW_MAJOR, LAPACK_LOWER_TRIANGLE, 3, 1, AB, 3, S, &sc, &am ); + if ( info != 0 || S[ 0 ] != 0.5 || S[ 1 ] != 0.25 || S[ 2 ] != 0.125 || sc != 0.25 || am != 64.0 || memcmp( before, AB, sizeof AB ) != 0 ) { + return EXIT_FAILURE; + } + if ( S[ 0 ]*S[ 0 ]*AB[ 0 ] != 1.0 || S[ 1 ]*S[ 1 ]*AB[ 1 ] != 1.0 || S[ 2 ]*S[ 2 ]*AB[ 2 ] != 1.0 ) { + return EXIT_FAILURE; + } + printf( "INFO: %d; SCOND: %.2f; AMAX: %.1f\n", (int)info, sc, am ); + + info = API_SUFFIX(c_dpbequ_ndarray)( LAPACK_UPPER_TRIANGLE, 3, 1, B, 1, -2, 4, T, -1, 3, C, 1, M, 1 ); + if ( info != 0 || T[ 0 ] != 7.0 || T[ 1 ] != 0.125 || T[ 2 ] != 0.25 || T[ 3 ] != 0.5 || T[ 4 ] != 7.0 || C[ 0 ] != 7.0 || C[ 1 ] != 0.25 || C[ 2 ] != 7.0 || M[ 0 ] != 7.0 || M[ 1 ] != 64.0 || M[ 2 ] != 7.0 ) { + return EXIT_FAILURE; + } + printf( "Strided INFO: %d; guarded S: %.3f, %.2f, %.1f\n", (int)info, T[ 1 ], T[ 2 ], T[ 3 ] ); + + sc = -0.0; + info = API_SUFFIX(c_dpbequ)( LAPACK_COL_MAJOR, LAPACK_LOWER_TRIANGLE, 4, 0, F, 1, S, &sc, &am ); + if ( info != 2 || S[ 0 ] != 4.0 || S[ 1 ] != 0.0 || !signbit(S[ 1 ]) || S[ 2 ] != 16.0 || S[ 3 ] != 25.0 || sc != 0.0 || !signbit(sc) || am != 25.0 ) { + return EXIT_FAILURE; + } + printf( "Failure INFO: %d; later-column AMAX: %.1f\n", (int)info, am ); + + info = API_SUFFIX(c_dpbequ)( LAPACK_ROW_MAJOR, LAPACK_LOWER_TRIANGLE, 2, 0, Z, 2, S, &sc, &am ); + if ( info != 1 || am != 0.0 || !signbit(am) || sc != 0.0 || !signbit(sc) ) { + return EXIT_FAILURE; + } + printf( "Mixed-zero INFO: %d; first AMAX sign retained\n", (int)info ); + + info = API_SUFFIX(c_dpbequ)( LAPACK_COL_MAJOR, LAPACK_UPPER_TRIANGLE, 0, 2, NULL, 3, NULL, &sc, &am ); + if ( info != 0 || sc != 1.0 || am != 0.0 || signbit(am) ) { + return EXIT_FAILURE; + } + printf( "Empty INFO: %d; SCOND: %.1f; AMAX: %.1f\n", (int)info, sc, am ); + return EXIT_SUCCESS; +} +``` + +
+ + + +
+ + + +
+ +## References + +The arithmetic follows [Reference-LAPACK DPBEQU][lapack-source] at commit `2e5d9c1273435fbd953adb294ed603e4789afaba`, with attribution to the University of Tennessee, University of California Berkeley, University of Colorado Denver and NAG Ltd. Public output/geometry/backing validation, the finite-diagonal domain and strict-first failure reduction are proposed adaptations. The original BSD conditions and disclaimer are retained in [NOTICE][lapack-notice] and reproduced below for distributions. + +```text +Copyright (c) 1992-2025 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. +Copyright (c) 2000-2025 The University of California Berkeley. All + rights reserved. +Copyright (c) 2006-2025 The University of Colorado Denver. All rights + reserved. + +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` + +
+ + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.js new file mode 100644 index 000000000000..5787816a22bd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.js @@ -0,0 +1,179 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dpbequ = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates bounded scaling benchmarks with complete output/input checks. +* +* @private +* @param {PositiveInteger} N - matrix order +* @param {boolean} upper - whether to use upper storage +* @param {boolean} failed - whether the second diagonal is negative zero +* @returns {Function} benchmark function +*/ +function createBenchmark( N, upper, failed ) { + var before; + var bytes; + var SCOND; + var AMAX; + var AB; + var ss; + var os; + var S; + var r; + var c; + var o; + var j; + + AB = new Float64Array( 2*N ); + S = new Float64Array( N+2 ); + SCOND = new Float64Array( 1 ); + AMAX = new Float64Array( 1 ); + r = N; + c = 1; + o = 0; + ss = 1; + os = 0; + for ( j = 0; j < AB.length; j++ ) { + AB[ j ] = NaN; + } + for ( j = 0; j < N; j++ ) { + AB[ o+(( ( upper ) ? 1 : 0 )*r)+(j*c) ] = ( failed && j === 1 ) ? -0.0 : (j+2)*(j+2); + } + bytes = new Uint8Array( AB.buffer ); + before = new Uint8Array( bytes ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var diagonal; + var index; + var info; + var i; + var j; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Output reset is included in the measured workload: + for ( j = 0; j < S.length; j++ ) { + S[ j ] = 7.0; + } + SCOND[ 0 ] = -0.0; + AMAX[ 0 ] = -9.0; + info = dpbequ( 'row-major', ( upper ) ? 'upper' : 'lower', N, 1, AB, N, S, SCOND, AMAX ); + if ( info !== (( failed ) ? 2 : 0) ) { + b.fail( 'should return the expected scaling status' ); + b.end(); + return; + } + } + b.toc(); + for ( j = 0; j < N; j++ ) { + index = os+(j*ss); + diagonal = AB[ o+(( ( upper ) ? 1 : 0 )*r)+(j*c) ]; + if ( failed ) { + if ( S[ index ] !== diagonal || (j === 1 && 1/S[ index ] !== -Infinity) ) { + b.fail( 'should copy every failure diagonal and preserve zero sign' ); + b.end(); + return; + } + } else if ( !( abs( (S[ index ]*S[ index ]*diagonal)-1.0 ) <= 1.0e-14 ) ) { + b.fail( 'should scale each positive diagonal to one' ); + b.end(); + return; + } + } + if ( AMAX[ 0 ] !== (N+1)*(N+1) || (( failed ) ? 1/SCOND[ 0 ] !== -Infinity : SCOND[ 0 ] !== 2/(N+1)) ) { + b.fail( 'should check full AMAX and SCOND output/sentinel' ); + b.end(); + return; + } + for ( j = 0; j < bytes.length; j++ ) { + if ( bytes[ j ] !== before[ j ] ) { + b.fail( 'should preserve every input byte' ); + b.end(); + return; + } + } + for ( j = 0; j < S.length; j++ ) { + if ( ((j < os+((N-1)*ss) || j > os) && ss < 0) || ((j < os || j > os+((N-1)*ss)) && ss > 0) ) { + if ( S[ j ] !== 7.0 ) { + b.fail( 'should retain unused output guards' ); + b.end(); + return; + } + } + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var options; + var sizes; + var name; + var fcn; + var i; + var j; + var k; + + options = { + 'iterations': 200, + 'repeats': 2 + }; + sizes = [ 8, 16 ]; + for ( i = 0; i < sizes.length; i++ ) { + for ( j = 0; j < 2; j++ ) { + for ( k = 0; k < 2; k++ ) { + name = format( '%s:N=%d:upper=%d:failed=%d', pkg, sizes[ i ], j, k ); + fcn = createBenchmark( sizes[ i ], j === 1, k === 1 ); + bench( name, options, fcn ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..f13857386339 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/benchmark.ndarray.js @@ -0,0 +1,179 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dpbequ = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates bounded scaling benchmarks with complete output/input checks. +* +* @private +* @param {PositiveInteger} N - matrix order +* @param {boolean} upper - whether to use upper storage +* @param {boolean} failed - whether the second diagonal is negative zero +* @returns {Function} benchmark function +*/ +function createBenchmark( N, upper, failed ) { + var before; + var bytes; + var SCOND; + var AMAX; + var AB; + var ss; + var os; + var S; + var r; + var c; + var o; + var j; + + AB = new Float64Array( 2*N ); + S = new Float64Array( N+2 ); + SCOND = new Float64Array( 1 ); + AMAX = new Float64Array( 1 ); + r = 1; + c = -2; + o = 2*(N-1); + ss = -1; + os = N; + for ( j = 0; j < AB.length; j++ ) { + AB[ j ] = NaN; + } + for ( j = 0; j < N; j++ ) { + AB[ o+(( ( upper ) ? 1 : 0 )*r)+(j*c) ] = ( failed && j === 1 ) ? -0.0 : (j+2)*(j+2); + } + bytes = new Uint8Array( AB.buffer ); + before = new Uint8Array( bytes ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var diagonal; + var index; + var info; + var i; + var j; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Output reset is included in the measured workload: + for ( j = 0; j < S.length; j++ ) { + S[ j ] = 7.0; + } + SCOND[ 0 ] = -0.0; + AMAX[ 0 ] = -9.0; + info = dpbequ.ndarray( ( upper ) ? 'upper' : 'lower', N, 1, AB, r, c, o, S, ss, os, SCOND, 0, AMAX, 0 ); + if ( info !== (( failed ) ? 2 : 0) ) { + b.fail( 'should return the expected scaling status' ); + b.end(); + return; + } + } + b.toc(); + for ( j = 0; j < N; j++ ) { + index = os+(j*ss); + diagonal = AB[ o+(( ( upper ) ? 1 : 0 )*r)+(j*c) ]; + if ( failed ) { + if ( S[ index ] !== diagonal || (j === 1 && 1/S[ index ] !== -Infinity) ) { + b.fail( 'should copy every failure diagonal and preserve zero sign' ); + b.end(); + return; + } + } else if ( !( abs( (S[ index ]*S[ index ]*diagonal)-1.0 ) <= 1.0e-14 ) ) { + b.fail( 'should scale each positive diagonal to one' ); + b.end(); + return; + } + } + if ( AMAX[ 0 ] !== (N+1)*(N+1) || (( failed ) ? 1/SCOND[ 0 ] !== -Infinity : SCOND[ 0 ] !== 2/(N+1)) ) { + b.fail( 'should check full AMAX and SCOND output/sentinel' ); + b.end(); + return; + } + for ( j = 0; j < bytes.length; j++ ) { + if ( bytes[ j ] !== before[ j ] ) { + b.fail( 'should preserve every input byte' ); + b.end(); + return; + } + } + for ( j = 0; j < S.length; j++ ) { + if ( ((j < os+((N-1)*ss) || j > os) && ss < 0) || ((j < os || j > os+((N-1)*ss)) && ss > 0) ) { + if ( S[ j ] !== 7.0 ) { + b.fail( 'should retain unused output guards' ); + b.end(); + return; + } + } + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var options; + var sizes; + var name; + var fcn; + var i; + var j; + var k; + + options = { + 'iterations': 200, + 'repeats': 2 + }; + sizes = [ 8, 16 ]; + for ( i = 0; i < sizes.length; i++ ) { + for ( j = 0; j < 2; j++ ) { + for ( k = 0; k < 2; k++ ) { + name = format( '%s:N=%d:upper=%d:failed=%d', pkg, sizes[ i ], j, k ); + fcn = createBenchmark( sizes[ i ], j === 1, k === 1 ); + bench( name, options, fcn ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/benchmark.c new file mode 100644 index 000000000000..3530d0fcaefd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/benchmark/c/benchmark.c @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include "stdlib/lapack/base/dpbequ.h" +#include "stdlib/lapack/base/shared.h" +#include +#include +#include +#include +#include +#include + +/** +* Main execution sequence. +*/ +int main( void ) { + double AB[ 32 ] = { 0.0 }; + double before[ 32 ]; + double S[ 18 ]; + double sc; + double am; + double diagonal; + LAPACK_INT r; + LAPACK_INT c; + LAPACK_INT o; + LAPACK_INT ss; + LAPACK_INT os; + LAPACK_INT info; + LAPACK_INT N; + const int32_t sizes[] = { 8, 16 }; + int32_t i; + int32_t j; + int32_t upper; + int32_t failed; + int32_t nd; + int32_t repeat; + int32_t iteration; + int32_t count = 0; + double elapsed; + clock_t t; + + for ( i = 0; i < 2; i++ ) { + N = sizes[ i ]; + for ( upper = 0; upper < 2; upper++ ) { + for ( nd = 0; nd < 2; nd++ ) { + r = nd ? 1 : N; + c = nd ? -2 : 1; + o = nd ? 2*(N-1) : 0; + ss = nd ? -1 : 1; + os = nd ? N : 0; + for ( failed = 0; failed < 2; failed++ ) { + for ( j = 0; j < 2*N; j++ ) { + AB[ j ] = NAN; + } + for ( j = 0; j < N; j++ ) { + AB[ o+(upper*r)+(j*c) ] = (failed && j == 1) ? -0.0 : (double)((j+2)*(j+2)); + } + memcpy( before, AB, (size_t)(2*N)*sizeof(double) ); + for ( repeat = 0; repeat < 2; repeat++ ) { + t = clock(); + for ( iteration = 0; iteration < 200; iteration++ ) { + for ( j = 0; j < N+2; j++ ) { + S[ j ] = 7.0; + } + sc = -0.0; + am = -9.0; + if ( nd ) { + info = API_SUFFIX(c_dpbequ_ndarray)( upper ? LAPACK_UPPER_TRIANGLE : LAPACK_LOWER_TRIANGLE, N, 1, AB, r, c, o, S, ss, os, &sc, 0, &am, 0 ); + } else { + info = API_SUFFIX(c_dpbequ)( LAPACK_ROW_MAJOR, upper ? LAPACK_UPPER_TRIANGLE : LAPACK_LOWER_TRIANGLE, N, 1, AB, N, S, &sc, &am ); + } + if ( info != (failed ? 2 : 0) ) { + return EXIT_FAILURE; + } + } + + elapsed = (double)(clock()-t)/(double)CLOCKS_PER_SEC; + for ( j = 0; j < N; j++ ) { + diagonal = AB[ o+(upper*r)+(j*c) ]; + if ( failed ) { + if ( S[ os+(j*ss) ] != diagonal || (j == 1 && !signbit(S[ os+(j*ss) ])) ) { + return EXIT_FAILURE; + } + } else if ( !(fabs(S[ os+(j*ss) ]*S[ os+(j*ss) ]*diagonal-1.0) <= 1.0e-14) ) { + return EXIT_FAILURE; + } + } + if ( am != (double)((N+1)*(N+1)) || (failed ? sc != 0.0 || !signbit(sc) : sc != 2.0/(double)(N+1)) || memcmp( before, AB, (size_t)(2*N)*sizeof(double) ) != 0 ) { + return EXIT_FAILURE; + } + for ( j = 0; j < N+2; j++ ) { + if ( ((ss < 0 && (j < os+(N-1)*ss || j > os)) || (ss > 0 && (j < os || j > os+(N-1)*ss))) && S[ j ] != 7.0 ) { + return EXIT_FAILURE; + } + } + count++; + printf( "# c::dpbequ:N=%d:upper=%d:ndarray=%d:failed=%d\n", (int)N, upper, nd, failed ); + printf( "ok %d benchmark finished; 200 iterations; %.9f seconds\n", count, elapsed ); + } + } + } + } + } + printf( "1..%d\n# total %d\n# pass %d\n", count, count, count ); + return EXIT_SUCCESS; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/binding.gyp b/lib/node_modules/@stdlib/lapack/base/dpbequ/binding.gyp new file mode 100644 index 000000000000..89dba19a0e05 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/binding.gyp @@ -0,0 +1,268 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + '-DNAPI_VERSION=8', + '-fno-fast-math', + '-ffp-contract=off', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/repl.txt new file mode 100644 index 000000000000..916de97335ce --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/repl.txt @@ -0,0 +1,129 @@ +{{alias}}( order, uplo, N, KD, AB, LDAB, S, SCOND, AMAX ) + Computes diagonal scaling for a symmetric compact band matrix. + S[i]=1/sqrt(diagonal[i]), SCOND=sqrt(min)/sqrt(max), AMAX=max. + Input AB is unchanged. INFO is zero or the first one-based + nonpositive diagonal. On failure all original diagonals are copied + to S, AMAX includes later columns and SCOND retains its sentinel. + Strict-first zero ties differ from sampled reference AMAX failures. + + H=KD+1; full AB is H-by-N. Upper diagonal row KD, lower row zero. + KD>=N is supported. Selected diagonals must be finite before any + output write; ignored entries may be nonfinite. Positive diagonal + scaling does not certify positive definiteness or stability. + + Active intrinsic Float64Array views need current ordinary backing, + pairwise disjoint conservative envelopes and stable exclusive + synchronous lifetime. RAB current valid extents are supported; + SAB, proxies, detached and OOB views are rejected. Pure JS callers + guarantee hidden foreign physical nonaliasing. Native physical + alias errors propagate and never trigger postmutation fallback. + + N=0 validates only active SCOND/AMAX and required scalar/main LDAB + metadata, then writes SCOND=1, AMAX=+0. AB/S and inactive ndarray + metadata are ignored. Only predispatch valid wider metadata uses + JS fallback. Proposed Node>=16 is not compatibility proof; actual + execution uses Node24/Linux. + + Parameters + ---------- + order: string|number + Row-major (101) or column-major (102). + uplo: string|number + Upper (121) or lower (122). + N: integer + Matrix order in [0,2147483646]. + KD: integer + Bandwidth in [0,2147483646]. + AB: Float64Array + Read-only full (KD+1)-by-N compact band view. + LDAB: integer + >=KD+1 column-major or >=max(1,N) row-major. + S: Float64Array + Output-only N-vector. + SCOND: Float64Array + Mutable scalar at index zero; retained on failure. + AMAX: Float64Array + Mutable maximum scalar at index zero. + + Returns + ------- + info: number + Zero or the first one-based nonpositive diagonal. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 4, 16, 64 ] ); + > var S = new {{alias:@stdlib/array/float64}}( 3 ); + > var C = new {{alias:@stdlib/array/float64}}( 1 ); + > var M = new {{alias:@stdlib/array/float64}}( 1 ); + > {{alias}}( 'column-major', 'lower', 3, 0, A, 1, S, C, M ) + 0 + > S + [ 0.5, 0.25, 0.125 ] + > C + [ 0.25 ] + > M + [ 64 ] + + +{{alias}}.ndarray( uplo, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ) + Uses signed element indexing AB[o+b*r+j*c], S[os+j*ss], + SCOND[oc], AMAX[om] relative to the intrinsic typed-array views. + Active offsets are nonnegative safe integers; full views fit and + are injective with exact products/corners/byte sums. Used zero + strides and overlapping conservative envelopes are rejected. + On N=0 only active scalars and their offsets are inspected. + + Parameters + ---------- + uplo: string|number + Upper (121) or lower (122). + N: integer + Matrix order in [0,2147483646]. + KD: integer + Bandwidth in [0,2147483646]. + AB: Float64Array + Read-only full compact band view. + r: integer + Band-row element stride. + c: integer + Matrix-column element stride. + o: integer + Band starting offset. + S: Float64Array + Output-only N-vector. + ss: integer + Scaling element stride. + os: integer + Scaling starting offset. + SCOND: Float64Array + Mutable scalar; retained on failure. + oc: integer + Active SCOND offset. + AMAX: Float64Array + Mutable maximum scalar. + om: integer + Active AMAX offset. + + Returns + ------- + info: number + Zero or first one-based nonpositive diagonal. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 4, -0, 16, 25 ] ); + > var S = new {{alias:@stdlib/array/float64}}( 4 ); + > var C = new {{alias:@stdlib/array/float64}}( [ -7 ] ); + > var M = new {{alias:@stdlib/array/float64}}( 1 ); + > {{alias}}.ndarray( 'lower', 4, 0, A, 1, 1, 0, S, 1, 0, C, 0, M, 0 ) + 2 + > S + [ 4, -0, 16, 25 ] + > C + [ -7 ] + > M + [ 25 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/index.d.ts new file mode 100644 index 000000000000..8daa5f3c8e44 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/index.d.ts @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `dpbequ`. +*/ +interface Routine { + /** + * Computes diagonal scaling for a symmetric band matrix. + * + * ## Notes + * + * - Full compact AB is (KD+1)-by-N; upper diagonal row KD, lower row zero. KD>=N is supported. + * - Selected diagonals must be finite before writes; ignored entries may be nonfinite. + * - INFO=0 writes scaling S, SCOND and AMAX. Positive INFO copies every original diagonal into S and writes full AMAX, retaining SCOND's exact sentinel. + * - The first nonpositive diagonal gives one-based INFO; strict comparisons preserve the first tied zero sign, differing from sampled reference AMAX failures. + * - Active intrinsic Float64Array views require current ordinary backing, stable exclusive lifetime and pairwise disjoint conservative indexed byte envelopes. + * - RAB current valid extents are supported; shared/proxy/detached/OOB views are rejected. Hidden foreign physical aliases remain a caller precondition in pure JS. + * - Empty calls validate only active disjoint scalar cells after required selectors/dimensions/main LDAB, then write SCOND=1 and AMAX=+0; inactive AB/S metadata is ignored. + * - Types cannot express finite values, geometry, lifetime, alias, exact arithmetic or configured native-domain constraints. + * + * @param order - row-major (101) or column-major (102) layout + * @param uplo - upper (121) or lower (122) triangle + * @param N - matrix order, integer in [0,2147483646] + * @param KD - bandwidth, integer in [0,2147483646] + * @param AB - read-only full compact band view + * @param LDAB - leading dimension, >=KD+1 column-major or >=max(1,N) row-major + * @param S - output-only N-vector + * @param SCOND - mutable scalar output at index zero, retained on failure + * @param AMAX - mutable maximum output at index zero + * @throws invalid selectors, storage or runtime domain + * @returns numeric INFO, zero or the first one-based nonpositive diagonal + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AB = new Float64Array( [ 4.0, 16.0, 64.0 ] ); + * var S = new Float64Array( 3 ); + * var SCOND = new Float64Array( 1 ); + * var AMAX = new Float64Array( 1 ); + * var info = dpbequ( 'column-major', 'lower', 3, 0, AB, 1, S, SCOND, AMAX ); + * // returns 0 + * // S => [ 0.5, 0.25, 0.125 ] + * // SCOND => [ 0.25 ] + * // AMAX => [ 64 ] + */ + ( order: Layout | 101 | 102, uplo: MatrixTriangle | 121 | 122, N: number, KD: number, AB: Float64Array, LDAB: number, S: Float64Array, SCOND: Float64Array, AMAX: Float64Array ): number; + + /** + * Computes diagonal scaling for a symmetric band matrix with alternative indexing. + * + * ## Notes + * + * - Full compact AB is (KD+1)-by-N; upper diagonal row KD, lower row zero. KD>=N is supported. + * - Selected diagonals must be finite before writes; ignored entries may be nonfinite. + * - INFO=0 writes scaling S, SCOND and AMAX. Positive INFO copies every original diagonal into S and writes full AMAX, retaining SCOND's exact sentinel. + * - The first nonpositive diagonal gives one-based INFO; strict comparisons preserve the first tied zero sign, differing from sampled reference AMAX failures. + * - Active intrinsic Float64Array views require current ordinary backing, stable exclusive lifetime and pairwise disjoint conservative indexed byte envelopes. + * - RAB current valid extents are supported; shared/proxy/detached/OOB views are rejected. Hidden foreign physical aliases remain a caller precondition in pure JS. + * - Empty calls validate only active disjoint scalar cells after required selectors/dimensions/main LDAB, then write SCOND=1 and AMAX=+0; inactive AB/S metadata is ignored. + * - Types cannot express finite values, geometry, lifetime, alias, exact arithmetic or configured native-domain constraints. + * + * @param uplo - upper (121) or lower (122) triangle + * @param N - matrix order, integer in [0,2147483646] + * @param KD - bandwidth, integer in [0,2147483646] + * @param AB - read-only full compact band view + * @param strideAB1 - band-row element stride + * @param strideAB2 - matrix-column element stride + * @param offsetAB - band starting element offset + * @param S - output-only N-vector + * @param strideS - output-vector element stride + * @param offsetS - output-vector starting offset + * @param SCOND - mutable scalar output, retained on failure + * @param offsetSCOND - active SCOND scalar offset + * @param AMAX - mutable maximum output + * @param offsetAMAX - active AMAX scalar offset + * @throws invalid selectors, storage or runtime domain + * @returns numeric INFO, zero or the first one-based nonpositive diagonal + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AB = new Float64Array( [ 4.0, -0.0, 16.0, 25.0 ] ); + * var S = new Float64Array( 4 ); + * var SCOND = new Float64Array( [ -7.0 ] ); + * var AMAX = new Float64Array( 1 ); + * var info = dpbequ.ndarray( 'lower', 4, 0, AB, 1, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); + * // returns 2 + * // S => [ 4, -0, 16, 25 ] + * // SCOND => [ -7 ] + * // AMAX => [ 25 ] + */ + ndarray( uplo: MatrixTriangle | 121 | 122, N: number, KD: number, AB: Float64Array, strideAB1: number, strideAB2: number, offsetAB: number, S: Float64Array, strideS: number, offsetS: number, SCOND: Float64Array, offsetSCOND: number, AMAX: Float64Array, offsetAMAX: number ): number; +} + +/** +* Computes diagonal scaling factors for a symmetric band matrix. +*/ +declare var dpbequ: Routine; + + +// EXPORTS // + +export = dpbequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/test.ts new file mode 100644 index 000000000000..fc3d5827a5bd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/docs/types/test.ts @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dpbequ = require( './index' ); + +var AB = new Float64Array( 6 ); +var S = new Float64Array( 3 ); +var SCOND = new Float64Array( 1 ); +var AMAX = new Float64Array( 1 ); + +dpbequ( 'row-major', 'upper', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'row-major', 121, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'row-major', 122, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'column-major', 'upper', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'column-major', 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'column-major', 121, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 'column-major', 122, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 101, 'upper', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 101, 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 101, 121, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 101, 122, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 102, 'upper', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 102, 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 102, 121, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ( 102, 122, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectType number +dpbequ.ndarray( 'upper', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectType number +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectType number +dpbequ.ndarray( 121, 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectType number +dpbequ.ndarray( 122, 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectType number + +dpbequ( ); // $ExpectError +dpbequ( 'row-major' ); // $ExpectError +dpbequ( 'row-major', 'lower' ); // $ExpectError +dpbequ( 'row-major', 'lower', 3 ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1 ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3 ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND, AMAX, 0 ); // $ExpectError +dpbequ( 'invalid', 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'invalid', 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 'invalid', 1, AB, 3, S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 'invalid', AB, 3, S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, 'invalid', 3, S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 'invalid', S, SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, 'invalid', SCOND, AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, 'invalid', AMAX ); // $ExpectError +dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND, 'invalid' ); // $ExpectError +dpbequ.ndarray( ); // $ExpectError +dpbequ.ndarray( 'lower' ); // $ExpectError +dpbequ.ndarray( 'lower', 3 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0, 0 ); // $ExpectError +dpbequ.ndarray( 'invalid', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 'invalid', 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 'invalid', AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, 'invalid', 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 'invalid', 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 'invalid', 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 'invalid', S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, 'invalid', 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 'invalid', 0, SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 'invalid', SCOND, 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, 'invalid', 0, AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 'invalid', AMAX, 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, 'invalid', 0 ); // $ExpectError +dpbequ.ndarray( 'lower', 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 'invalid' ); // $ExpectError +dpbequ( 'row-major', 0, 3, 1, AB, 3, S, SCOND, AMAX ); // $ExpectError +dpbequ.ndarray( 0, 3, 1, AB, 3, 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); // $ExpectError diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/Makefile b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/example.c b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/example.c new file mode 100644 index 000000000000..0d09058641b5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/c/example.c @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include "stdlib/lapack/base/dpbequ.h" +#include "stdlib/lapack/base/shared.h" +#include +#include +#include +#include + +/** +* Main execution sequence. +*/ +int main( void ) { + const double AB[] = { 4.0, 16.0, 64.0, NAN, INFINITY, 999.0 }; + double before[ 6 ]; + const double B[] = { 8.0, 64.0, 999.0, 16.0, 999.0, 4.0, 999.0, 8.0 }; + double T[] = { 7.0, 7.0, 7.0, 7.0, 7.0 }; + double C[] = { 7.0, -7.0, 7.0 }; + double M[] = { 7.0, -9.0, 7.0 }; + const double F[] = { 4.0, -0.0, 16.0, 25.0 }; + const double Z[] = { -0.0, 0.0 }; + double S[ 4 ] = { 0.0, 0.0, 0.0, 0.0 }; + double sc = -0.0; + double am = -9.0; + LAPACK_INT info; + + memcpy( before, AB, sizeof AB ); + info = API_SUFFIX(c_dpbequ)( LAPACK_ROW_MAJOR, LAPACK_LOWER_TRIANGLE, 3, 1, AB, 3, S, &sc, &am ); + if ( info != 0 || S[ 0 ] != 0.5 || S[ 1 ] != 0.25 || S[ 2 ] != 0.125 || sc != 0.25 || am != 64.0 || memcmp( before, AB, sizeof AB ) != 0 ) { + return EXIT_FAILURE; + } + if ( S[ 0 ]*S[ 0 ]*AB[ 0 ] != 1.0 || S[ 1 ]*S[ 1 ]*AB[ 1 ] != 1.0 || S[ 2 ]*S[ 2 ]*AB[ 2 ] != 1.0 ) { + return EXIT_FAILURE; + } + printf( "INFO: %d; SCOND: %.2f; AMAX: %.1f\n", (int)info, sc, am ); + + info = API_SUFFIX(c_dpbequ_ndarray)( LAPACK_UPPER_TRIANGLE, 3, 1, B, 1, -2, 4, T, -1, 3, C, 1, M, 1 ); + if ( info != 0 || T[ 0 ] != 7.0 || T[ 1 ] != 0.125 || T[ 2 ] != 0.25 || T[ 3 ] != 0.5 || T[ 4 ] != 7.0 || C[ 0 ] != 7.0 || C[ 1 ] != 0.25 || C[ 2 ] != 7.0 || M[ 0 ] != 7.0 || M[ 1 ] != 64.0 || M[ 2 ] != 7.0 ) { + return EXIT_FAILURE; + } + printf( "Strided INFO: %d; guarded S: %.3f, %.2f, %.1f\n", (int)info, T[ 1 ], T[ 2 ], T[ 3 ] ); + + sc = -0.0; + info = API_SUFFIX(c_dpbequ)( LAPACK_COL_MAJOR, LAPACK_LOWER_TRIANGLE, 4, 0, F, 1, S, &sc, &am ); + if ( info != 2 || S[ 0 ] != 4.0 || S[ 1 ] != 0.0 || !signbit(S[ 1 ]) || S[ 2 ] != 16.0 || S[ 3 ] != 25.0 || sc != 0.0 || !signbit(sc) || am != 25.0 ) { + return EXIT_FAILURE; + } + printf( "Failure INFO: %d; later-column AMAX: %.1f\n", (int)info, am ); + + info = API_SUFFIX(c_dpbequ)( LAPACK_ROW_MAJOR, LAPACK_LOWER_TRIANGLE, 2, 0, Z, 2, S, &sc, &am ); + if ( info != 1 || am != 0.0 || !signbit(am) || sc != 0.0 || !signbit(sc) ) { + return EXIT_FAILURE; + } + printf( "Mixed-zero INFO: %d; first AMAX sign retained\n", (int)info ); + + info = API_SUFFIX(c_dpbequ)( LAPACK_COL_MAJOR, LAPACK_UPPER_TRIANGLE, 0, 2, NULL, 3, NULL, &sc, &am ); + if ( info != 0 || sc != 1.0 || am != 0.0 || signbit(am) ) { + return EXIT_FAILURE; + } + printf( "Empty INFO: %d; SCOND: %.1f; AMAX: %.1f\n", (int)info, sc, am ); + return EXIT_SUCCESS; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/index.js new file mode 100644 index 000000000000..24da8dbdbccd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/examples/index.js @@ -0,0 +1,85 @@ +/** +* @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 assert = require( 'assert' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dpbequ = require( './../lib' ); + + +// MAIN // + +// Only selected diagonals are read; ignored band entries may be nonfinite: +var AB = new Float64Array( [ 4.0, 16.0, 64.0, NaN, Infinity, 999.0 ] ); +var S = new Float64Array( 3 ); +var SCOND = new Float64Array( [ -7.0 ] ); +var AMAX = new Float64Array( [ -9.0 ] ); +var info = dpbequ( 'row-major', 'lower', 3, 1, AB, 3, S, SCOND, AMAX ); +assert.strictEqual( info, 0 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '0.5,0.25,0.125' ); +assert.strictEqual( SCOND[ 0 ], 0.25 ); +assert.strictEqual( AMAX[ 0 ], 64.0 ); +assert.strictEqual( S[ 0 ]*S[ 0 ]*AB[ 0 ], 1.0 ); +assert.strictEqual( S[ 1 ]*S[ 1 ]*AB[ 1 ], 1.0 ); +assert.strictEqual( S[ 2 ]*S[ 2 ]*AB[ 2 ], 1.0 ); +console.log( 'INFO: %d; S: %s; SCOND: %d; AMAX: %d', info, Array.prototype.join.call( S, ', ' ), SCOND[ 0 ], AMAX[ 0 ] ); + +// Signed band/output strides and scalar offsets retain all guards: +AB = new Float64Array( [ 8.0, 64.0, 999.0, 16.0, 999.0, 4.0, 999.0, 8.0 ] ); +S = new Float64Array( [ 7.0, 7.0, 7.0, 7.0, 7.0 ] ); +SCOND = new Float64Array( [ 7.0, -7.0, 7.0 ] ); +AMAX = new Float64Array( [ 7.0, -9.0, 7.0 ] ); +info = dpbequ.ndarray( 'upper', 3, 1, AB, 1, -2, 4, S, -1, 3, SCOND, 1, AMAX, 1 ); +assert.strictEqual( info, 0 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '7,0.125,0.25,0.5,7' ); +assert.strictEqual( Array.prototype.join.call( SCOND, ',' ), '7,0.25,7' ); +assert.strictEqual( Array.prototype.join.call( AMAX, ',' ), '7,64,7' ); +assert.strictEqual( Array.prototype.join.call( AB, ',' ), '8,64,999,16,999,4,999,8' ); +console.log( 'Strided INFO: %d; guarded S: %s', info, Array.prototype.join.call( S, ', ' ) ); + +// Failure copies every diagonal and finds AMAX even in later columns: +AB = new Float64Array( [ 4.0, -0.0, 16.0, 25.0 ] ); +S = new Float64Array( 4 ); +SCOND = new Float64Array( [ -0.0 ] ); +AMAX = new Float64Array( [ -9.0 ] ); +info = dpbequ( 'column-major', 'lower', 4, 0, AB, 1, S, SCOND, AMAX ); +assert.strictEqual( info, 2 ); +assert.strictEqual( Array.prototype.join.call( S, ',' ), '4,0,16,25' ); +assert.strictEqual( 1/S[ 1 ], -Infinity ); +assert.strictEqual( 1/SCOND[ 0 ], -Infinity ); +assert.strictEqual( AMAX[ 0 ], 25.0 ); +console.log( 'Failure INFO: %d; copied S: %s; AMAX: %d', info, Array.prototype.join.call( S, ', ' ), AMAX[ 0 ] ); + +// Strict-first AMAX preserves the first tied zero sign on failure: +AB = new Float64Array( [ -0.0, 0.0 ] ); +S = new Float64Array( 2 ); +info = dpbequ( 'row-major', 'lower', 2, 0, AB, 2, S, SCOND, AMAX ); +assert.strictEqual( info, 1 ); +assert.strictEqual( 1/AMAX[ 0 ], -Infinity ); +assert.strictEqual( 1/SCOND[ 0 ], -Infinity ); +console.log( 'Mixed-zero INFO: %d; first AMAX sign: %d', info, 1/AMAX[ 0 ] ); + +// Empty input ignores AB/S but validates and writes both active scalars: +info = dpbequ( 'column-major', 'upper', 0, 2, null, 3, null, SCOND, AMAX ); +assert.strictEqual( info, 0 ); +assert.strictEqual( SCOND[ 0 ], 1.0 ); +assert.strictEqual( 1/AMAX[ 0 ], Infinity ); +console.log( 'Empty INFO: %d; SCOND: %d; AMAX: %d', info, SCOND[ 0 ], AMAX[ 0 ] ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/include.gypi b/lib/node_modules/@stdlib/lapack/base/dpbequ/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/include.gypi @@ -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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + '= KD+1; row-major LDAB >= max(1,N). Only finite selected +* diagonal entries are supported; ignored cells may be nonfinite. +* Positive diagonals produce S[i]=1/sqrt(diagonal[i]), +* SCOND=sqrt(min(diagonal))/sqrt(max(diagonal)), and AMAX=max(diagonal). +* For a nonpositive diagonal, INFO is its first one-based index, every +* original diagonal is copied into S, AMAX includes all columns, and +* SCOND retains its caller sentinel. Strict comparisons preserve the +* first tied extremum's zero sign, differing from sampled GNU reference +* AMAX failure reductions. No universal signed-zero parity is claimed. +* +* Configured N/KD must lie in [0,MAX-1]. Negative argument positions +* identify a prewrite validation error: order -1, uplo -2, N -3, +* KD -4, AB geometry/alias/nonfinite -5, LDAB -6, S -7, SCOND -8, +* AMAX or SCOND/AMAX overlap -9. For N=0, required scalar/layout/LDAB +* validation precedes writes of SCOND=1 and AMAX=+0; AB/S are ignored. +* +* Active conservative band/vector/scalar indexed byte envelopes must +* be pairwise disjoint, even if only a diagonal is numerically read. +* Capacity, double alignment and stable exclusive lifetime are caller +* preconditions. No numerical BLAS dependency or workspace is required. +*/ +LAPACK_INT API_SUFFIX(c_dpbequ)( const LAPACK_LAYOUT order, const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT LDAB, double *S, double *SCOND, double *AMAX ); + +/** +* Computes band-matrix scaling factors using alternative indexing. +* +* AB is indexed by offsetAB+i*strideAB1+j*strideAB2 over the complete +* (KD+1)-by-N band; S by offsetS+j*strideS. Active scalar cells are +* SCOND[offsetSCOND] and AMAX[offsetAMAX]. Used strides are nonzero; +* products, index corners, byte envelopes and band injectivity validate +* before any writes. Minimum configured integer strides are rejected +* before negation even for singletons; other unused singleton strides +* need not participate in arithmetic. Full physical envelopes must be +* disjoint. Numeric and failure output semantics match c_dpbequ above. +* +* Negative positions: uplo -1, N -2, KD -3, AB null/alias/nonfinite -4, +* strideAB1 -5, strideAB2/collision -6, offsetAB/envelope -7, S -8, +* strideS -9, offsetS/envelope -10, SCOND null -11, offsetSCOND/envelope +* -12, AMAX null/SCOND overlap -13, offsetAMAX/envelope -14. For N=0, +* only uplo/N/KD and the disjoint active scalar cells validate; AB/S +* and their inactive strides/offsets are ignored. Capacity, alignment +* and stable exclusive lifetime remain caller preconditions. +*/ +LAPACK_INT API_SUFFIX(c_dpbequ_ndarray)( const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT strideAB1, const LAPACK_INT strideAB2, const LAPACK_INT offsetAB, double *S, const LAPACK_INT strideS, const LAPACK_INT offsetS, double *SCOND, const LAPACK_INT offsetSCOND, double *AMAX, const LAPACK_INT offsetAMAX ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_LAPACK_BASE_DPBEQU_H diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/base.js new file mode 100644 index 000000000000..35bbf13c131f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/base.js @@ -0,0 +1,138 @@ +/** +* @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. +*/ +/* + * Copyright (c) 1992-2025 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2000-2025 The University of California Berkeley. All + * rights reserved. + * Copyright (c) 2006-2025 The University of Colorado Denver. All rights + * reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer listed + * in this license in the documentation and/or other materials + * provided with the distribution. + * + * - Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * The copyright holders provide no reassurances that the source code + * provided does not infringe any patent, copyright, or any other + * intellectual property rights of third parties. The copyright holders + * disclaim any liability to any recipient for claims brought against + * recipient by any third party for infringement of that parties + * intellectual property rights. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +'use strict'; + +// MODULES // + +var sqrt = require( '@stdlib/math/base/special/sqrt' ); + + +// MAIN // + +/** +* Computes scaling using already validated normalized views. +* @private +* @param {integer} uplo - numeric triangle +* @param {NonNegativeInteger} N - order +* @param {NonNegativeInteger} KD - bandwidth +* @param {Float64Array} AB - band view +* @param {integer} r - row stride +* @param {integer} c - column stride +* @param {integer} o - band offset +* @param {Float64Array} S - vector output +* @param {integer} ss - vector stride +* @param {integer} os - vector offset +* @param {Float64Array} SCOND - scalar output +* @param {integer} oc - scalar offset +* @param {Float64Array} AMAX - scalar output +* @param {integer} om - scalar offset +* @returns {integer} INFO +*/ +function dpbequ( uplo, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ) { // eslint-disable-line max-params -- Preserve the adopted fourteen-argument ndarray contract. + var small; + var large; + var value; + var ai; + var j; + if ( N === 0 ) { + SCOND[oc] = 1; + AMAX[om] = 0; + return 0; + } + ai = o + ((uplo === 121) ? KD*r : 0); + small = AB[ai]; + large = small; + for ( j = 0; j < N; j++ ) { + value = AB[ai+(j*c)]; + S[os+(j*ss)] = value; + if ( value < small ) { + small = value; + } + if ( value > large ) { + large = value; + } + } + AMAX[om] = large; + if ( small <= 0 ) { + for ( j = 0; j < N; j++ ) { + if ( S[os+(j*ss)] <= 0 ) { + return j+1; + } + } + } + for ( j = 0; j < N; j++ ) { + S[os+(j*ss)] = 1 / sqrt( S[os+(j*ss)] ); + } + SCOND[oc] = sqrt(small) / sqrt(large); + return 0; +} + + +// EXPORTS // + +module.exports = dpbequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/can_use_native.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/can_use_native.js new file mode 100644 index 000000000000..f0459ed7fdea --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/can_use_native.js @@ -0,0 +1,78 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var min = require( '@stdlib/math/base/special/min' ); +var max = require( '@stdlib/math/base/special/max' ); + + +// MAIN // + +/** +* Selects native only for conservative signed32 original metadata. +* @private +* @param {integer} uplo - numeric triangle +* @param {NonNegativeInteger} N - order +* @param {NonNegativeInteger} KD - bandwidth +* @param {Float64Array} AB - band view +* @param {integer} r - row stride +* @param {integer} c - column stride +* @param {integer} o - band offset +* @param {Float64Array} S - vector output +* @param {integer} ss - vector stride +* @param {integer} os - vector offset +* @param {Float64Array} SCOND - scalar output +* @param {integer} oc - scalar offset +* @param {Float64Array} AMAX - scalar output +* @param {integer} om - scalar offset +* @returns {boolean} eligibility +*/ +function eligible( uplo, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ) { // eslint-disable-line max-params -- Preserve the adopted fourteen-argument ndarray contract. + var args = [ uplo, N, KD, r, c, o, ss, os, oc, om ]; + var MAX = 2147483647; + var dr; + var dc; + var ds; + var i; + if ( N === 0 ) { + return ((oc <= MAX) && (om <= MAX)); + } + for ( i = 0; i < args.length; i++ ) { + if ( abs(args[i]) > MAX ) { + return false; + } + } + if ( N === 0 ) { + return true; + } + dr = KD*r; + dc = (N-1)*c; + ds = (N-1)*ss; + if ( abs(dr) > MAX || abs(dc) > MAX || abs(ds) > MAX ) { + return false; + } + return o+min(dr, 0)+min(dc, 0) >= 0 && o+max(dr, 0)+max(dc, 0) <= MAX && os+min(ds, 0) >= 0 && os+max(ds, 0) <= MAX; +} + + +// EXPORTS // + +module.exports = eligible; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/factory.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/factory.js new file mode 100644 index 000000000000..4dee36bed932 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/factory.js @@ -0,0 +1,112 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var validate = require( './validate.js' ); + + +// MAIN // + +/** +* Creates a public validation contract around a normalized backend. +* @private +* @param {Function} backend - normalized backend +* @param {Function} [eligible] - native eligibility +* @param {Function} [fallback] - validated fallback +* @returns {Function} public routine +*/ +function factory( backend, eligible, fallback ) { + setReadOnly( dpbequ, 'ndarray', ndarray ); + return dpbequ; + + /** +* Computes diagonal scaling from contiguous band storage. +* @private +* @param {string|integer} order - layout +* @param {string|integer} uplo - triangle +* @param {NonNegativeInteger} N - order +* @param {NonNegativeInteger} KD - bandwidth +* @param {Float64Array} AB - band storage +* @param {PositiveInteger} LDAB - leading dimension +* @param {Float64Array} S - scaling output +* @param {Float64Array} SCOND - scalar output +* @param {Float64Array} AMAX - scalar output +* @throws {TypeError} invalid selector or storage +* @throws {RangeError} invalid metadata or domain +* @returns {integer} INFO +*/ + function dpbequ( order, uplo, N, KD, AB, LDAB, S, SCOND, AMAX ) { + var column; + var u; + if ( order !== 'row-major' && order !== 'column-major' && order !== 101 && order !== 102 ) { + throw new TypeError( 'invalid argument. Invalid layout.' ); + } + u = validate.scalars( uplo, N, KD ); + validate.integer( LDAB ); + column = order === 'column-major' || order === 102; + if ( LDAB < ((column) ? KD+1 : max(1, N)) ) { + throw new RangeError( 'invalid argument. Invalid leading dimension.' ); + } + return ndarray( u, N, KD, AB, (column) ? 1 : LDAB, (column) ? LDAB : 1, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); + } + + /** +* Computes diagonal scaling from signed injective band and output views. +* @private +* @param {string|integer} uplo - triangle +* @param {NonNegativeInteger} N - order +* @param {NonNegativeInteger} KD - bandwidth +* @param {Float64Array} AB - band storage +* @param {integer} r - row stride +* @param {integer} c - column stride +* @param {integer} o - band offset +* @param {Float64Array} S - scaling output +* @param {integer} ss - scaling stride +* @param {integer} os - scaling offset +* @param {Float64Array} SCOND - scalar output +* @param {integer} oc - scalar offset +* @param {Float64Array} AMAX - scalar output +* @param {integer} om - scalar offset +* @throws {TypeError} invalid selector or storage +* @throws {RangeError} invalid metadata or domain +* @returns {integer} INFO +*/ + function ndarray( uplo, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ) { // eslint-disable-line max-params -- Preserve the adopted fourteen-argument ndarray contract. + var info; + var use; + var u; + u = validate.scalars( uplo, N, KD ); + validate( u, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ); + use = (eligible && !eligible(u, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om)) ? fallback : backend; + info = use( u, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ); + if ( !isInteger(info) || info < 0 || info > N ) { + throw new RangeError( 'invalid argument. Private INFO is outside the scalar status domain.' ); + } + return info; + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/index.js new file mode 100644 index 000000000000..a36df112f95c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/index.js @@ -0,0 +1,36 @@ +/** +* @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. +*/ +/** +* Compute diagonal scaling factors for a symmetric band matrix. +* @module @stdlib/lapack/base/dpbequ +*/ +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var main = tryRequire( resolve(__dirname, './native.js') ); +if ( (main instanceof Error) ) { + main = require( './main.js' ); +} + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/main.js new file mode 100644 index 000000000000..43aac2629129 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/main.js @@ -0,0 +1,33 @@ +/** +* @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 factory = require( './factory.js' ); +var base = require( './base.js' ); + + +// VARIABLES // + +var dpbequ = factory( base ); + + +// EXPORTS // + +module.exports = dpbequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/native.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/native.js new file mode 100644 index 000000000000..d23737317e71 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +'use strict'; + +// MODULES // + +var factory = require( './factory.js' ); +var base = require( './base.js' ); +var eligible = require( './can_use_native.js' ); +var addon = require( './../src/addon.node' ); + + +// VARIABLES // + +var dpbequ = factory( addon, eligible, base ); + + +// EXPORTS // + +module.exports = dpbequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/validate.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/validate.js new file mode 100644 index 000000000000..20920eb0ffca --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/lib/validate.js @@ -0,0 +1,269 @@ +/** +* @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 Symbol = require( '@stdlib/symbol/ctor' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isSafeInteger = require( '@stdlib/assert/is-safe-integer' ).isPrimitive; +var isFiniteNumber = require( '@stdlib/math/base/assert/is-finite' ); +var min = require( '@stdlib/math/base/special/min' ); +var max = require( '@stdlib/math/base/special/max' ); +var abs = require( '@stdlib/math/base/special/abs' ); + + +// VARIABLES // + +var MAX = 9007199254740991; +var prototype = Object.getPrototypeOf( Float64Array.prototype ); +var tag = Object.getOwnPropertyDescriptor( prototype, Symbol.toStringTag ).get; +var getLength = Object.getOwnPropertyDescriptor( prototype, 'length' ).get; +var buffer = Object.getOwnPropertyDescriptor( prototype, 'buffer' ).get; +var byteOffset = Object.getOwnPropertyDescriptor( prototype, 'byteOffset' ).get; +var byteLength = Object.getOwnPropertyDescriptor( ArrayBuffer.prototype, 'byteLength' ).get; +var values = prototype.values; + + +// FUNCTIONS // + +/** +* Validates exact primitive metadata. +* @private +* @param {number} value - metadata +* @throws {RangeError} invalid metadata +* @returns {integer} validated metadata +*/ +function integer( value ) { + if ( !isSafeInteger( value ) ) { + throw new RangeError( 'invalid argument. Metadata must be primitive safe integers.' ); + } + return value; +} + +/** +* Adds exact signed metadata before evaluating an oversized expression. +* @private +* @param {integer} x - first term +* @param {integer} y - second term +* @throws {RangeError} inexact sum +* @returns {integer} exact sum +*/ +function sum( x, y ) { + if ( ( y > 0 && x > MAX-y ) || ( y < 0 && x < -MAX-y ) ) { + throw new RangeError( 'invalid argument. Inexact indexed sum.' ); + } + return x+y; +} + +/** +* Computes a checked product. +* @private +* @param {NonNegativeInteger} count - nonnegative count +* @param {integer} stride - signed stride +* @throws {RangeError} inexact product +* @returns {integer} exact product +*/ +function product( count, stride ) { + if ( count !== 0 && abs(stride) > MAX/count ) { + throw new RangeError( 'invalid argument. Inexact indexed product.' ); + } + return integer( count*stride ); +} + +/** +* Computes a greatest common divisor. +* @private +* @param {PositiveInteger} x - first value +* @param {PositiveInteger} y - second value +* @returns {PositiveInteger} divisor +*/ +function gcd( x, y ) { + var z; + while ( y !== 0 ) { + z = x%y; + x = y; + y = z; + } + return x; +} + +/** +* Validates an intrinsic ordinary-backed full injective view. +* @private +* @param {Float64Array} x - input view +* @param {PositiveInteger} h - logical rows +* @param {PositiveInteger} n - logical columns +* @param {integer} r - row stride +* @param {integer} c - column stride +* @param {integer} o - offset +* @throws {TypeError} invalid brand or backing +* @throws {RangeError} invalid geometry +* @returns {Object} indexed byte envelope +*/ +function view( x, h, n, r, c, o ) { + var first; + var data; + var size; + var last; + var lo; + var hi; + var dr; + var dc; + var g; + if ( tag.call(x) !== 'Float64Array' ) { + throw new TypeError( 'invalid argument. Must provide an intrinsic Float64Array.' ); + } + values.call( x ); // Intrinsic detached and current out-of-bounds validation. + data = buffer.call( x ); + size = byteLength.call( data ); // Rejects shared backing and tag spoofs. + integer( r ); + integer( c ); + integer( o ); + if ( o < 0 || (h > 1 && r === 0) || (n > 1 && c === 0) ) { + throw new RangeError( 'invalid argument. Offsets must be nonnegative and active strides nonzero.' ); + } + if ( h > 1 && n > 1 ) { + g = gcd( abs(r), abs(c) ); + if ( abs(c)/g < h && abs(r)/g < n ) { + throw new RangeError( 'invalid argument. The full indexed view must be injective.' ); + } + } + dr = product( h-1, r ); + dc = product( n-1, c ); + lo = sum( sum(o, min(dr, 0)), min(dc, 0) ); + hi = sum( sum(o, max(dr, 0)), max(dc, 0) ); + if ( lo < 0 || hi >= getLength.call(x) ) { + throw new RangeError( 'invalid argument. Indexed view exceeds the current intrinsic extent.' ); + } + first = sum( byteOffset.call(x), product(lo, 8) ); + last = sum( byteOffset.call(x), product(sum(hi, 1), 8) ); + if ( last > size ) { + throw new RangeError( 'invalid argument. Indexed view exceeds current backing extent.' ); + } + return { + 'buffer': data, + 'first': first, + 'last': last + }; +} + +/** +* Rejects overlapping indexed envelopes before writes. +* @private +* @param {Array} views - active envelopes +* @throws {RangeError} overlapping envelopes +* @returns {void} +*/ +function disjoint( views ) { + var i; + var j; + for ( i = 0; i < views.length; i++ ) { + for ( j = i+1; j < views.length; j++ ) { + if ( views[i].buffer === views[j].buffer && views[i].first < views[j].last && views[j].first < views[i].last ) { + throw new RangeError( 'invalid argument. Indexed byte envelopes overlap.' ); + } + } + } +} + +/** +* Validates selected triangle and dimensions. +* @private +* @param {string|integer} uplo - selected triangle +* @param {NonNegativeInteger} N - matrix order +* @param {NonNegativeInteger} KD - bandwidth +* @throws {TypeError} invalid selector +* @throws {RangeError} invalid dimensions +* @returns {integer} numeric triangle +*/ +function scalars( uplo, N, KD ) { + if ( uplo === 'upper' || uplo === 121 ) { + uplo = 121; + } else if ( uplo === 'lower' || uplo === 122 ) { + uplo = 122; + } else { + throw new TypeError( 'invalid argument. Invalid triangle.' ); + } + integer( N ); + integer( KD ); + if ( N < 0 || N > 2147483646 || KD < 0 || KD > 2147483646 ) { + throw new RangeError( 'invalid argument. Dimensions must be in [0,2147483646].' ); + } + return uplo; +} + + +// MAIN // + +/** +* Validates all active views, aliases and selected finite diagonals. +* @private +* @param {integer} uplo - numeric triangle +* @param {NonNegativeInteger} N - order +* @param {NonNegativeInteger} KD - bandwidth +* @param {Float64Array} AB - band view +* @param {integer} r - row stride +* @param {integer} c - column stride +* @param {integer} o - band offset +* @param {Float64Array} S - vector output +* @param {integer} ss - vector stride +* @param {integer} os - vector offset +* @param {Float64Array} SCOND - scalar output +* @param {integer} oc - scalar offset +* @param {Float64Array} AMAX - scalar output +* @param {integer} om - scalar offset +* @throws {TypeError} invalid storage +* @throws {RangeError} invalid views or nonfinite selected diagonals +* @returns {void} +*/ +function validate( uplo, N, KD, AB, r, c, o, S, ss, os, SCOND, oc, AMAX, om ) { // eslint-disable-line max-params -- Preserve the adopted fourteen-argument ndarray contract. + var scalarC; + var scalarM; + var matrix; + var vector; + var ai; + var j; + scalarC = view( SCOND, 1, 1, 0, 0, oc ); + scalarM = view( AMAX, 1, 1, 0, 0, om ); + disjoint( [ scalarC, scalarM ] ); + if ( N === 0 ) { + return; + } + matrix = view( AB, KD+1, N, r, c, o ); + vector = view( S, N, 1, ss, 0, os ); + disjoint( [ matrix, vector, scalarC, scalarM ] ); + ai = o + ((uplo === 121) ? KD*r : 0); + for ( j = 0; j < N; j++ ) { + if ( !isFiniteNumber(AB[ai+(j*c)]) ) { + throw new RangeError( 'invalid argument. Selected diagonals must be finite.' ); + } + } +} + + +// EXPORTS // + +validate.scalars = scalars; +validate.integer = integer; +validate.sum = sum; +validate.product = product; +validate.view = view; +validate.disjoint = disjoint; +module.exports = validate; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/manifest.json b/lib/node_modules/@stdlib/lapack/base/dpbequ/manifest.json new file mode 100644 index 000000000000..ab347a685d06 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/manifest.json @@ -0,0 +1,84 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c", + "./src/ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c", + "./src/ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c", + "./src/ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/lapack/base/shared" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/package.json b/lib/node_modules/@stdlib/lapack/base/dpbequ/package.json new file mode 100644 index 000000000000..67ca834cc050 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/lapack/base/dpbequ", + "version": "0.0.0", + "description": "Compute diagonal scaling factors for a symmetric band matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=16.0.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "band", + "matrix", + "linear", + "algebra", + "ndarray", + "float64", + "double", + "float64array", + "symmetric", + "dpbequ", + "scaling", + "equilibration" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/src/Makefile b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/src/addon.c b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/addon.c new file mode 100644 index 000000000000..19a02249f4c1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/addon.c @@ -0,0 +1,190 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/lapack/base/dpbequ.h" +#include +#include +#include +#include + +#ifdef LAPACK_ILP64 +#define DPBEQU_INT_MIN INT64_MIN +#define DPBEQU_INT_MAX INT64_MAX +#else +#define DPBEQU_INT_MIN INT32_MIN +#define DPBEQU_INT_MAX INT32_MAX +#endif +#define DPBEQU_RAW_DIM INT32_C(2147483646) + +/** +* Throws an exception without starting numerical writes. +*/ +static napi_value fail( napi_env env, const char *message ) { + napi_throw_range_error( env, NULL, message ); + return NULL; +} + +/** +* Checks primitive exact numbers before configured integer conversion. +*/ +static int number( napi_env env, napi_value x, int64_t *out ) { + napi_valuetype type; + double value; + if ( napi_typeof( env, x, &type ) != napi_ok || type != napi_number || napi_get_value_double( env, x, &value ) != napi_ok || !isfinite( value ) || trunc( value ) != value || fabs( value ) > 9007199254740991.0 ) { + return 0; + } + if ( value < (double)DPBEQU_INT_MIN || value > (double)DPBEQU_INT_MAX ) { + return 0; + } + *out = (int64_t)value; + return *out >= DPBEQU_INT_MIN && *out <= DPBEQU_INT_MAX; +} + +/** +* Retrieves genuine Float64 storage with ordinary backing. +*/ +static int buffer( napi_env env, napi_value value, double **pointer, size_t *length ) { + napi_typedarray_type type; + napi_value backing; + size_t byteOffset; + bool ordinary = false; + if ( napi_get_typedarray_info( env, value, &type, length, (void **)pointer, &backing, &byteOffset ) != napi_ok || type != napi_float64_array ) { + return 0; + } + if ( napi_is_arraybuffer( env, backing, &ordinary ) != napi_ok || !ordinary ) { + return 0; + } + return 1; +} + +/** +* Checks current extent, configured exact products/corners and injectivity. +*/ +static int bounds( size_t length, int64_t h, int64_t n, int64_t r, int64_t c, int64_t o ) { + int64_t dr; + int64_t dc; + int64_t low; + int64_t high; + int64_t a; + int64_t b; + int64_t g; + int64_t t; + if ( o < 0 || h < 1 || n < 1 || r == DPBEQU_INT_MIN || c == DPBEQU_INT_MIN ) { + return 0; + } + if ( ( h > 1 && r == 0 ) || ( n > 1 && c == 0 ) ) { + return 0; + } + if ( h > 1 && ( r > DPBEQU_INT_MAX/(h-1) || r < -DPBEQU_INT_MAX/(h-1) ) ) { + return 0; + } + if ( n > 1 && ( c > DPBEQU_INT_MAX/(n-1) || c < -DPBEQU_INT_MAX/(n-1) ) ) { + return 0; + } + dr = (h-1)*r; + dc = (n-1)*c; + if ( h > 1 && n > 1 ) { + a = r < 0 ? -r : r; + b = c < 0 ? -c : c; + g = a; + while ( b != 0 ) { + t = g%b; + g = b; + b = t; + } + if ( g == 0 || ( (c < 0 ? -c : c)/g < h && a/g < n ) ) { + return 0; + } + } + if ( dr < 0 && dc < 0 && dr < DPBEQU_INT_MIN-dc ) { + return 0; + } + if ( dr > 0 && dc > 0 && dr > DPBEQU_INT_MAX-dc ) { + return 0; + } + low = (dr < 0 ? dr : 0) + (dc < 0 ? dc : 0); + high = (dr > 0 ? dr : 0) + (dc > 0 ? dc : 0); + if ( low == DPBEQU_INT_MIN || o > DPBEQU_INT_MAX-high || ( low < 0 && o < -low ) ) { + return 0; + } + high += o; + return (uint64_t)high < (uint64_t)length; +} + +/** +* Performs independent raw validation before the C preflight and computation. +*/ +static napi_value call( napi_env env, napi_callback_info callback ) { + napi_value args[15]; + napi_value out; + size_t argc = 15; + size_t la; + size_t ls; + size_t lc; + size_t lm; + int64_t v[14] = { 0 }; + double *a = NULL; + double *s = NULL; + double *sc = NULL; + double *am = NULL; + LAPACK_INT info; + int i; + if ( napi_get_cb_info( env, callback, &argc, args, NULL, NULL ) != napi_ok || argc != 14 ) { + return fail( env, "invalid argument. Expected exactly fourteen arguments." ); + } + if ( !number( env, args[0], &v[0] ) || ( v[0] != 121 && v[0] != 122 ) ) { + return fail( env, "invalid argument. Invalid triangle." ); + } + if ( !number( env, args[1], &v[1] ) || v[1] < 0 || v[1] > DPBEQU_RAW_DIM ) { + return fail( env, "invalid argument. Invalid N." ); + } + if ( !number( env, args[2], &v[2] ) || v[2] < 0 || v[2] > DPBEQU_RAW_DIM ) { + return fail( env, "invalid argument. Invalid KD." ); + } + if ( !number( env, args[11], &v[11] ) || !number( env, args[13], &v[13] ) || !buffer( env, args[10], &sc, &lc ) || !buffer( env, args[12], &am, &lm ) || !bounds( lc, 1, 1, 0, 0, v[11] ) || !bounds( lm, 1, 1, 0, 0, v[13] ) ) { + return fail( env, "invalid argument. Invalid active scalar outputs." ); + } + if ( v[1] != 0 ) { + for ( i = 4; i <= 9; i++ ) { + if ( i != 7 && !number( env, args[i], &v[i] ) ) { + return fail( env, "invalid argument. Invalid view metadata." ); + } + } + if ( !buffer( env, args[3], &a, &la ) || !buffer( env, args[7], &s, &ls ) || !bounds( la, v[2]+1, v[1], v[4], v[5], v[6] ) || !bounds( ls, v[1], 1, v[8], 0, v[9] ) ) { + return fail( env, "invalid argument. Invalid indexed view." ); + } + } + // C independently checks physical pointer aliases and finite diagonals. + info = API_SUFFIX(c_dpbequ_ndarray)( (int)v[0], (LAPACK_INT)v[1], (LAPACK_INT)v[2], a, (LAPACK_INT)v[4], (LAPACK_INT)v[5], (LAPACK_INT)v[6], s, (LAPACK_INT)v[8], (LAPACK_INT)v[9], sc, (LAPACK_INT)v[11], am, (LAPACK_INT)v[13] ); + if ( info < 0 ) { + return fail( env, "invalid argument. Native preflight rejected input before writes." ); + } + if ( napi_create_int32( env, (int32_t)info, &out ) != napi_ok ) { + return NULL; + } + return out; +} + +NAPI_MODULE_INIT() { + napi_value f; + (void)exports; + if ( napi_create_function( env, "dpbequ", NAPI_AUTO_LENGTH, call, NULL, &f ) != napi_ok ) { + return NULL; + } + return f; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/src/main.c b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/main.c new file mode 100644 index 000000000000..6f93ad915668 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/main.c @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/lapack/base/dpbequ.h" +#include "preflight.h" + +/** +* Computes scaling factors for a symmetric positive definite band matrix. +* +* @param order storage layout +* @param uplo stored triangle +* @param N number of dense rows and columns +* @param KD number of stored off-diagonals +* @param AB read-only compact band matrix +* @param LDAB leading dimension of the compact view +* @param S output scales or copied diagonal on failure +* @param SCOND mutable ratio output, unchanged for a nonpositive diagonal +* @param AMAX mutable complete diagonal maximum +* @return INFO or a negative argument position +*/ +LAPACK_INT API_SUFFIX(c_dpbequ)( const LAPACK_LAYOUT order, const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT LDAB, double *S, double *SCOND, double *AMAX ) { + dpbequ_envelope envelopeAB; + dpbequ_envelope envelopeS; + dpbequ_envelope envelopeSC; + dpbequ_envelope envelopeAM; + LAPACK_INT height; + LAPACK_INT stride1; + LAPACK_INT stride2; + LAPACK_INT delta1; + LAPACK_INT delta2; + LAPACK_INT high; + LAPACK_INT info; + + if ( order != LAPACK_ROW_MAJOR && order != LAPACK_COL_MAJOR ) return -1; + if ( uplo != LAPACK_UPPER_TRIANGLE && uplo != LAPACK_LOWER_TRIANGLE ) return -2; + if ( N < 0 || N == dpbequ_max() ) return -3; + if ( KD < 0 || KD == dpbequ_max() ) return -4; + height = KD+1; + if ( LDAB < ( order == LAPACK_COL_MAJOR ? height : ( N > 0 ? N : 1 ) ) ) return -6; + if ( !dpbequ_scalar( SCOND, 0, &envelopeSC ) ) return -8; + if ( !dpbequ_scalar( AMAX, 0, &envelopeAM ) || dpbequ_overlaps( &envelopeSC, &envelopeAM ) ) return -9; + if ( N == 0 ) { + *SCOND = 1.0; + *AMAX = 0.0; + return 0; + } + if ( AB == NULL ) return -5; + stride1 = order == LAPACK_COL_MAJOR ? 1 : LDAB; + stride2 = order == LAPACK_COL_MAJOR ? LDAB : 1; + if ( !dpbequ_step( height, stride1, &delta1 ) || !dpbequ_step( N, stride2, &delta2 ) || !dpbequ_add( delta1, delta2, &high ) || !dpbequ_physical( AB, 0, 0, high, &envelopeAB ) ) return -5; + if ( dpbequ_overlaps( &envelopeAB, &envelopeSC ) || dpbequ_overlaps( &envelopeAB, &envelopeAM ) ) return -5; + if ( S == NULL || !dpbequ_physical( S, 0, 0, N-1, &envelopeS ) ) return -7; + if ( dpbequ_overlaps( &envelopeS, &envelopeAB ) || dpbequ_overlaps( &envelopeS, &envelopeSC ) || dpbequ_overlaps( &envelopeS, &envelopeAM ) ) return -7; + info = dpbequ_compute( uplo, N, KD, AB, stride1, stride2, 0, S, 1, 0, SCOND, 0, AMAX, 0 ); + return info == -1 ? -5 : info; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/src/ndarray.c b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/ndarray.c new file mode 100644 index 000000000000..91c13c345729 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/ndarray.c @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/lapack/base/dpbequ.h" +#include "preflight.h" + +/** +* Computes band-matrix scaling factors using alternative indexing. +* +* @param uplo stored triangle +* @param N number of dense rows and columns +* @param KD number of stored off-diagonals +* @param AB read-only compact band matrix +* @param strideAB1 first band dimension stride +* @param strideAB2 second band dimension stride +* @param offsetAB band starting index +* @param S output scales or copied diagonal on failure +* @param strideS scale stride +* @param offsetS scale starting index +* @param SCOND mutable ratio output +* @param offsetSCOND ratio starting index +* @param AMAX mutable complete diagonal maximum +* @param offsetAMAX maximum starting index +* @return INFO or a negative argument position +*/ +LAPACK_INT API_SUFFIX(c_dpbequ_ndarray)( const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, const LAPACK_INT strideAB1, const LAPACK_INT strideAB2, const LAPACK_INT offsetAB, double *S, const LAPACK_INT strideS, const LAPACK_INT offsetS, double *SCOND, const LAPACK_INT offsetSCOND, double *AMAX, const LAPACK_INT offsetAMAX ) { + dpbequ_envelope envelopeAB; + dpbequ_envelope envelopeS; + dpbequ_envelope envelopeSC; + dpbequ_envelope envelopeAM; + LAPACK_INT height; + LAPACK_INT delta1; + LAPACK_INT delta2; + LAPACK_INT deltaS; + LAPACK_INT low; + LAPACK_INT high; + LAPACK_INT info; + + if ( uplo != LAPACK_UPPER_TRIANGLE && uplo != LAPACK_LOWER_TRIANGLE ) return -1; + if ( N < 0 || N == dpbequ_max() ) return -2; + if ( KD < 0 || KD == dpbequ_max() ) return -3; + if ( SCOND == NULL ) return -11; + if ( !dpbequ_scalar( SCOND, offsetSCOND, &envelopeSC ) ) return -12; + if ( AMAX == NULL ) return -13; + if ( !dpbequ_scalar( AMAX, offsetAMAX, &envelopeAM ) ) return -14; + if ( dpbequ_overlaps( &envelopeSC, &envelopeAM ) ) return -13; + if ( N == 0 ) { + SCOND[ offsetSCOND ] = 1.0; + AMAX[ offsetAMAX ] = 0.0; + return 0; + } + height = KD+1; + if ( AB == NULL ) return -4; + if ( !dpbequ_step( height, strideAB1, &delta1 ) ) return -5; + if ( !dpbequ_step( N, strideAB2, &delta2 ) || !dpbequ_injective( height, N, strideAB1, strideAB2 ) ) return -6; + if ( !dpbequ_add( delta1 < 0 ? delta1 : 0, delta2 < 0 ? delta2 : 0, &low ) || !dpbequ_add( delta1 > 0 ? delta1 : 0, delta2 > 0 ? delta2 : 0, &high ) || !dpbequ_physical( AB, offsetAB, low, high, &envelopeAB ) ) return -7; + if ( dpbequ_overlaps( &envelopeAB, &envelopeSC ) || dpbequ_overlaps( &envelopeAB, &envelopeAM ) ) return -4; + if ( S == NULL ) return -8; + if ( !dpbequ_step( N, strideS, &deltaS ) ) return -9; + if ( !dpbequ_physical( S, offsetS, deltaS < 0 ? deltaS : 0, deltaS > 0 ? deltaS : 0, &envelopeS ) ) return -10; + if ( dpbequ_overlaps( &envelopeS, &envelopeAB ) || dpbequ_overlaps( &envelopeS, &envelopeSC ) || dpbequ_overlaps( &envelopeS, &envelopeAM ) ) return -8; + info = dpbequ_compute( uplo, N, KD, AB, strideAB1, strideAB2, offsetAB, S, strideS, offsetS, SCOND, offsetSCOND, AMAX, offsetAMAX ); + return info == -1 ? -4 : info; +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/src/preflight.h b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/preflight.h new file mode 100644 index 000000000000..b3c88d7ea43a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/src/preflight.h @@ -0,0 +1,245 @@ +/** +* @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. +*/ + +/* +* Adapted from Reference-LAPACK SRC/dpbequ.f at commit +* 2e5d9c1273435fbd953adb294ed603e4789afaba. Authors: University of +* Tennessee, University of California Berkeley, University of Colorado +* Denver, and NAG Ltd. Finite selected diagonals and conservative +* disjoint indexed envelopes are additional support requirements. +* Strict comparisons retain the first tied extremum, including its +* zero sign. This differs from the sampled GNU reference failure +* reductions, which retained the last tied zero sign. +*/ + +/* +* Copyright (c) 1992-2025 The University of Tennessee and The University +* of Tennessee Research Foundation. All rights +* reserved. +* Copyright (c) 2000-2025 The University of California Berkeley. All +* rights reserved. +* Copyright (c) 2006-2025 The University of Colorado Denver. All rights +* reserved. +* +* $COPYRIGHT$ +* +* Additional copyrights may follow +* +* $HEADER$ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* - Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* - Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer listed +* in this license in the documentation and/or other materials +* provided with the distribution. +* +* - Neither the name of the copyright holders nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* The copyright holders provide no reassurances that the source code +* provided does not infringe any patent, copyright, or any other +* intellectual property rights of third parties. The copyright holders +* disclaim any liability to any recipient for claims brought against +* recipient by any third party for infringement of that parties +* intellectual property rights. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef STDLIB_LAPACK_BASE_DPBEQU_PREFLIGHT_H +#define STDLIB_LAPACK_BASE_DPBEQU_PREFLIGHT_H + +#include "stdlib/lapack/base/shared.h" +#include +#include +#include +#include + +typedef char dpbequ_integer_check[ ( sizeof( LAPACK_INT ) <= sizeof( uintmax_t ) && (LAPACK_INT)-1 < 0 ) ? 1 : -1 ]; + +/** Indexed element and physical byte envelope. */ +typedef struct { + LAPACK_INT lo; + LAPACK_INT hi; + uintptr_t first; + uintptr_t last; +} dpbequ_envelope; + +/** Returns the maximum configured signed LAPACK integer. */ +static inline LAPACK_INT dpbequ_max( void ) { + return (LAPACK_INT)( UINTMAX_MAX >> ( (sizeof( uintmax_t )-sizeof( LAPACK_INT ))*CHAR_BIT + 1 ) ); +} + +/** Adds configured integers without overflowing. */ +static inline int dpbequ_add( const LAPACK_INT a, const LAPACK_INT b, LAPACK_INT *out ) { + const LAPACK_INT limit = dpbequ_max(); + const LAPACK_INT minimum = -limit-1; + if ( ( b > 0 && a > limit-b ) || ( b < 0 && a < minimum-b ) ) return 0; + *out = a+b; + return 1; +} + +/** Validates a stride and returns the terminal element displacement. */ +static inline int dpbequ_step( const LAPACK_INT extent, const LAPACK_INT stride, LAPACK_INT *out ) { + const LAPACK_INT limit = dpbequ_max(); + LAPACK_INT magnitude; + + // Reject a minimum integer before any negation, including singletons: + if ( stride == -limit-1 ) return 0; + if ( extent <= 1 ) { + *out = 0; + return 1; + } + magnitude = stride < 0 ? -stride : stride; + if ( magnitude == 0 ) return 0; + if ( extent-1 > limit/magnitude ) return 0; + *out = (extent-1)*stride; + return 1; +} + +/** Computes the greatest common divisor of two positive integers. */ +static inline LAPACK_INT dpbequ_gcd( LAPACK_INT a, LAPACK_INT b ) { + LAPACK_INT remainder; + while ( b != 0 ) { + remainder = a%b; + a = b; + b = remainder; + } + return a; +} + +/** Checks full-band injectivity after individual strides were validated. */ +static inline int dpbequ_injective( const LAPACK_INT rows, const LAPACK_INT columns, const LAPACK_INT stride1, const LAPACK_INT stride2 ) { + LAPACK_INT a; + LAPACK_INT b; + LAPACK_INT divisor; + + if ( rows <= 1 || columns <= 1 ) return 1; + a = stride1 < 0 ? -stride1 : stride1; + b = stride2 < 0 ? -stride2 : stride2; + divisor = dpbequ_gcd( a, b ); + return !( b/divisor < rows && a/divisor < columns ); +} + +/** +* Checks index and byte endpoints without constructing a derived pointer. +* +* Capacity, alignment and exclusive stable lifetime remain caller duties. +*/ +static inline int dpbequ_physical( const double *base, const LAPACK_INT offset, const LAPACK_INT low, const LAPACK_INT high, dpbequ_envelope *out ) { + const uintmax_t size = sizeof( double ); + uintptr_t address; + uintmax_t top; + LAPACK_INT lo; + LAPACK_INT hi; + + if ( offset < 0 || !dpbequ_add( offset, low, &lo ) || lo < 0 || !dpbequ_add( offset, high, &hi ) || hi < lo ) return 0; + if ( size-1 > (uintmax_t)PTRDIFF_MAX || (uintmax_t)hi > ( (uintmax_t)PTRDIFF_MAX-(size-1) )/size ) return 0; + top = (uintmax_t)hi*size+(size-1); + if ( top > UINTPTR_MAX ) return 0; + address = (uintptr_t)base; + if ( address > UINTPTR_MAX-(uintptr_t)top ) return 0; + out->lo = lo; + out->hi = hi; + out->first = address+(uintptr_t)lo*sizeof( double ); + out->last = address+(uintptr_t)top; + return 1; +} + +/** Validates a mutable scalar envelope. */ +static inline int dpbequ_scalar( const double *data, const LAPACK_INT offset, dpbequ_envelope *out ) { + return data != NULL && dpbequ_physical( data, offset, 0, 0, out ); +} + +/** Tests conservative physical byte overlap. */ +static inline int dpbequ_overlaps( const dpbequ_envelope *a, const dpbequ_envelope *b ) { + return a->first <= b->last && b->first <= a->last; +} + +/** +* Computes scales after geometry and all active aliases were validated. +* +* The complete finite diagonal scan precedes every output write. A +* nonpositive failure still copies all diagonals and computes full AMAX; +* SCOND retains its caller sentinel. Returns -1 for a nonfinite diagonal. +*/ +static inline LAPACK_INT dpbequ_compute( const int uplo, const LAPACK_INT N, const LAPACK_INT KD, const double *AB, LAPACK_INT strideAB1, LAPACK_INT strideAB2, const LAPACK_INT offsetAB, double *S, LAPACK_INT strideS, const LAPACK_INT offsetS, double *SCOND, const LAPACK_INT offsetSCOND, double *AMAX, const LAPACK_INT offsetAMAX ) { + LAPACK_INT indexAB; + LAPACK_INT indexS; + LAPACK_INT first; + LAPACK_INT j; + double smallest; + double largest; + double value; + + // Unused singleton strides were validated but need not enter arithmetic: + if ( KD == 0 ) strideAB1 = 0; + if ( N == 1 ) { + strideAB2 = 0; + strideS = 0; + } + indexAB = offsetAB+( uplo == LAPACK_UPPER_TRIANGLE ? KD*strideAB1 : 0 ); + for ( j = 0; j < N; j++ ) { + if ( !isfinite( AB[ indexAB ] ) ) return -1; + if ( j+1 < N ) indexAB += strideAB2; + } + indexAB = offsetAB+( uplo == LAPACK_UPPER_TRIANGLE ? KD*strideAB1 : 0 ); + indexS = offsetS; + smallest = AB[ indexAB ]; + largest = smallest; + first = 0; + for ( j = 0; j < N; j++ ) { + value = AB[ indexAB ]; + S[ indexS ] = value; + if ( value < smallest ) smallest = value; + if ( value > largest ) largest = value; + if ( first == 0 && value <= 0.0 ) first = j+1; + if ( j+1 < N ) { + indexAB += strideAB2; + indexS += strideS; + } + } + AMAX[ offsetAMAX ] = largest; + if ( first != 0 ) return first; + indexS = offsetS; + for ( j = 0; j < N; j++ ) { + S[ indexS ] = 1.0/sqrt( S[ indexS ] ); + if ( j+1 < N ) indexS += strideS; + } + SCOND[ offsetSCOND ] = sqrt( smallest )/sqrt( largest ); + return 0; +} + +#endif // !STDLIB_LAPACK_BASE_DPBEQU_PREFLIGHT_H diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/test/fixtures/reference.json b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/fixtures/reference.json new file mode 100644 index 000000000000..5c590a5b5221 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/fixtures/reference.json @@ -0,0 +1,1636 @@ +{ + "provenance": { + "repository": "Reference-LAPACK/lapack", + "commit": "2e5d9c1273435fbd953adb294ed603e4789afaba", + "finite_scope": "Sampled finite selected diagonals; strict first-tie mixed-zero AMAX is a documented deviation from the GNU reference." + }, + "cases": [ + { + "id": "unit", + "diag": [ + "3ff0000000000000" + ], + "kind": "finite", + "expected": { + "case": "unit", + "N": 1, + "INFO": 0, + "S": [ + { + "hex": "3ff0000000000000", + "value": "1.0" + } + ], + "SCOND": { + "hex": "3ff0000000000000", + "value": "1.0" + }, + "AMAX": { + "hex": "3ff0000000000000", + "value": "1.0" + } + } + }, + { + "id": "perfect_squares", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000" + ], + "kind": "finite", + "expected": { + "case": "perfect_squares", + "N": 4, + "INFO": 0, + "S": [ + { + "hex": "3fe0000000000000", + "value": "0.5" + }, + { + "hex": "3fd5555555555555", + "value": "0.3333333333333333" + }, + { + "hex": "3fd0000000000000", + "value": "0.25" + }, + { + "hex": "3fc999999999999a", + "value": "0.2" + } + ], + "SCOND": { + "hex": "3fd999999999999a", + "value": "0.4" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "heterogeneous", + "diag": [ + "3fc0000000000000", + "400a000000000000", + "3fd3333333333333", + "4056400000000000", + "3fd0000000000000", + "401c000000000000" + ], + "kind": "finite", + "expected": { + "case": "heterogeneous", + "N": 6, + "INFO": 0, + "S": [ + { + "hex": "4006a09e667f3bcc", + "value": "2.82842712474619" + }, + { + "hex": "3fe1c01aa03be896", + "value": "0.5547001962252291" + }, + { + "hex": "3ffd363d1848dcbf", + "value": "1.8257418583505538" + }, + { + "hex": "3fbb22cd56d87d7e", + "value": "0.105999788000636" + }, + { + "hex": "4000000000000000", + "value": "2.0" + }, + { + "hex": "3fd83091e6a7f7e6", + "value": "0.3779644730092272" + } + ], + "SCOND": { + "hex": "3fa330218127c0e1", + "value": "0.03747658444979308" + }, + "AMAX": { + "hex": "4056400000000000", + "value": "89.0" + } + } + }, + { + "id": "finite_extremes", + "diag": [ + "0000000000000001", + "0010000000000000", + "7fefffffffffffff", + "3ff0000000000000", + "0000000000000002" + ], + "kind": "finite", + "expected": { + "case": "finite_extremes", + "N": 5, + "INFO": 0, + "S": [ + { + "hex": "6180000000000000", + "value": "4.4989137945431964e+161" + }, + { + "hex": "5fe0000000000000", + "value": "6.703903964971299e+153" + }, + { + "hex": "1ff0000000000001", + "value": "7.458340731200208e-155" + }, + { + "hex": "3ff0000000000000", + "value": "1.0" + }, + { + "hex": "6176a09e667f3bcc", + "value": "3.181212452095196e+161" + } + ], + "SCOND": { + "hex": "0000000002000000", + "value": "1.6578092e-316" + }, + "AMAX": { + "hex": "7fefffffffffffff", + "value": "1.7976931348623157e+308" + } + } + }, + { + "id": "subnormals", + "diag": [ + "0000000000000001", + "0000000000000002", + "0000000000000003", + "0000000000000011", + "000000000000007b" + ], + "kind": "finite", + "expected": { + "case": "subnormals", + "N": 5, + "INFO": 0, + "S": [ + { + "hex": "6180000000000000", + "value": "4.4989137945431964e+161" + }, + { + "hex": "6176a09e667f3bcc", + "value": "3.181212452095196e+161" + }, + { + "hex": "617279a74590331d", + "value": "2.5974490903404355e+161" + }, + { + "hex": "615f0b6848d2af1c", + "value": "1.0911468691441146e+161" + }, + { + "hex": "6147152e9f44f01f", + "value": "4.0565339575260355e+160" + } + ], + "SCOND": { + "hex": "3fb7152e9f44f01f", + "value": "0.09016696346674323" + }, + "AMAX": { + "hex": "000000000000007b", + "value": "6.1e-322" + } + } + }, + { + "id": "maxima", + "diag": [ + "7fefffffffffffff", + "7feffffffffffffe", + "7fdfffffffffffff" + ], + "kind": "finite", + "expected": { + "case": "maxima", + "N": 3, + "INFO": 0, + "S": [ + { + "hex": "1ff0000000000001", + "value": "7.458340731200208e-155" + }, + { + "hex": "1ff0000000000001", + "value": "7.458340731200208e-155" + }, + { + "hex": "1ff6a09e667f3bcd", + "value": "1.0547686614863e-154" + } + ], + "SCOND": { + "hex": "3fe6a09e667f3bcd", + "value": "0.7071067811865476" + }, + "AMAX": { + "hex": "7fefffffffffffff", + "value": "1.7976931348623157e+308" + } + } + }, + { + "id": "tiny_singleton", + "diag": [ + "0000000000000001" + ], + "kind": "finite", + "expected": { + "case": "tiny_singleton", + "N": 1, + "INFO": 0, + "S": [ + { + "hex": "6180000000000000", + "value": "4.4989137945431964e+161" + } + ], + "SCOND": { + "hex": "3ff0000000000000", + "value": "1.0" + }, + "AMAX": { + "hex": "0000000000000001", + "value": "5e-324" + } + } + }, + { + "id": "large_singleton", + "diag": [ + "7fefffffffffffff" + ], + "kind": "finite", + "expected": { + "case": "large_singleton", + "N": 1, + "INFO": 0, + "S": [ + { + "hex": "1ff0000000000001", + "value": "7.458340731200208e-155" + } + ], + "SCOND": { + "hex": "3ff0000000000000", + "value": "1.0" + }, + "AMAX": { + "hex": "7fefffffffffffff", + "value": "1.7976931348623157e+308" + } + } + }, + { + "id": "dyadic_2", + "diag": [ + "55d0000000000000", + "08bd800000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_2", + "N": 2, + "INFO": 0, + "S": [ + { + "hex": "3500000000000000", + "value": "2.088097429759528e-53" + }, + { + "hex": "5b879113ebbd772a", + "value": "8.363866011151665e+132" + } + ], + "SCOND": { + "hex": "1965b9be5d52a9da", + "value": "2.4965696807857003e-186" + }, + "AMAX": { + "hex": "55d0000000000000", + "value": "2.2934986159900715e+105" + } + } + }, + { + "id": "dyadic_3", + "diag": [ + "1a56000000000000", + "47cb000000000000", + "4b22800000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_3", + "N": 3, + "INFO": 0, + "S": [ + { + "hex": "52bb4a293c1d954f", + "value": "3.4743802351733016e+90" + }, + { + "hex": "3c016b28f55d72d4", + "value": "1.1803298224917694e-19" + }, + { + "hex": "3a550b06a8fc6b70", + "value": "1.0624035548620536e-27" + } + ], + "SCOND": { + "hex": "2788acd9120213e2", + "value": "3.057821778130916e-118" + }, + "AMAX": { + "hex": "4b22800000000000", + "value": "8.85973984563092e+53" + } + } + }, + { + "id": "dyadic_7", + "diag": [ + "574c000000000000", + "4a09000000000000", + "0e83800000000000", + "5cc8000000000000", + "383e800000000000", + "6d8f400000000000", + "5910000000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_7", + "N": 7, + "INFO": 0, + "S": [ + { + "hex": "34411acee560242a", + "value": "5.44987804991868e-57" + }, + { + "hex": "3ae21a1851ff630a", + "value": "4.679240163218305e-25" + }, + { + "hex": "58a47f144fe17f9f", + "value": "1.03372726410367e+119" + }, + { + "hex": "318279a74590331d", + "value": "3.346111202467498e-70" + }, + { + "hex": "43c72d59c45f1fc5", + "value": "3.3401794735374034e+18" + }, + { + "hex": "292030dc4ea03a72", + "value": "1.34648512799519e-110" + }, + { + "hex": "3360000000000000", + "value": "3.111507638930571e-61" + } + ], + "SCOND": { + "hex": "1069472957f2765c", + "value": "1.3025535600656795e-229" + }, + "AMAX": { + "hex": "6d8f400000000000", + "value": "5.515652263101987e+219" + } + } + }, + { + "id": "dyadic_13", + "diag": [ + "68ec400000000000", + "71e1000000000000", + "4984000000000000", + "5e40000000000000", + "4fcd000000000000", + "46eac00000000000", + "2583000000000000", + "3393800000000000", + "32a4c00000000000", + "2814000000000000", + "4918000000000000", + "607c800000000000", + "0d08000000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_13", + "N": 13, + "INFO": 0, + "S": [ + { + "hex": "2b710763cec30b26", + "value": "1.946377991916712e-99" + }, + { + "hex": "26f5f3aa673fa910", + "value": "5.313152273847817e-121" + }, + { + "hex": "3b243d136248490f", + "value": "8.370479270402673e-24" + }, + { + "hex": "30c6a09e667f3bcc", + "value": "1.0005206382636743e-73" + }, + { + "hex": "3800cea6317186dc", + "value": "6.173998802129193e-39" + }, + { + "hex": "3c717ff2e00ec3ee", + "value": "1.5178656709850265e-17" + }, + { + "hex": "4d24c3abe93bcf74", + "value": "4.270977404252678e+63" + }, + { + "hex": "461cfc7da32a9212", + "value": "5.741326647832144e+29" + }, + { + "hex": "4693de948077db58", + "value": "1.0075009840937867e+32" + }, + { + "hex": "4bdc9f25c5bfedd9", + "value": "2.807205236401303e+57" + }, + { + "hex": "3b5a20bd700c2c3f", + "value": "8.64499381707839e-23" + }, + { + "hex": "2fa7fa023f1068d1", + "value": "4.044256467564718e-79" + }, + { + "hex": "596279a74590331d", + "value": "3.816608415304589e+122" + } + ], + "SCOND": { + "hex": "0d8302c5f0a5c073", + "value": "1.3921135457706616e-243" + }, + "AMAX": { + "hex": "71e1000000000000", + "value": "3.5423826674674226e+240" + } + } + }, + { + "id": "dyadic_21", + "diag": [ + "41d4800000000000", + "0c07800000000000", + "206bc00000000000", + "5ef6000000000000", + "317a800000000000", + "61b3000000000000", + "70e8800000000000", + "2e83000000000000", + "238d800000000000", + "1818400000000000", + "3020c00000000000", + "5c8a000000000000", + "2f63000000000000", + "2160c00000000000", + "27d4000000000000", + "1758000000000000", + "7390c00000000000", + "0cf1800000000000", + "1221c00000000000", + "67e0800000000000", + "3e37000000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_21", + "N": 21, + "INFO": 0, + "S": [ + { + "hex": "3efc453d90f057a1", + "value": "2.696082179561683e-05" + }, + { + "hex": "59e2abb43c0eb0f4", + "value": "9.87391214256354e+124" + }, + { + "hex": "4fb12e7d02c40253", + "value": "7.771456183750742e+75" + }, + { + "hex": "306b4a293c1d954f", + "value": "1.885427018254267e-75" + }, + { + "hex": "4728dd6b4563a009", + "value": "6.455301800776849e+34" + }, + { + "hex": "2f0d5d7ea914b936", + "value": "4.837092155509914e-82" + }, + { + "hex": "2772492492492492", + "value": "1.133009748801629e-118" + }, + { + "hex": "48a4c3abe93bcf74", + "value": "9.044146445951667e+41" + }, + { + "hex": "4e20aa07bd7b7489", + "value": "2.246327101886358e+68" + }, + { + "hex": "53d9fe2c315637ef", + "value": "8.675064982789688e+95" + }, + { + "hex": "47d61d72b7978671", + "value": "1.1758367702603593e+38" + }, + { + "hex": "31a1c01aa03be896", + "value": "1.2859358622663372e-69" + }, + { + "hex": "4834c3abe93bcf74", + "value": "7.06573941089974e+39" + }, + { + "hex": "4f361d72b7978671", + "value": "3.907387883758465e+73" + }, + { + "hex": "4bfc9f25c5bfedd9", + "value": "1.1228820945605212e+58" + }, + { + "hex": "543a20bd700c2c3f", + "value": "5.580883557553188e+97" + }, + { + "hex": "261f467f2814b0cc", + "value": "4.6202383052330204e-125" + }, + { + "hex": "596e990cdad55ed2", + "value": "6.320904050154953e+122" + }, + { + "hex": "56d57ba8b0ee01b9", + "value": "2.018153630340874e+110" + }, + { + "hex": "2bf6482d37a5a3d2", + "value": "6.519801966144273e-97" + }, + { + "hex": "40cab099ae8f539a", + "value": "13665.200639644452" + } + ], + "SCOND": { + "hex": "0c2acd38d4c12f95", + "value": "4.6792378122512634e-250" + }, + "AMAX": { + "hex": "7390c00000000000", + "value": "4.684586334320855e+248" + } + } + }, + { + "id": "dyadic_33", + "diag": [ + "2f20000000000000", + "704f400000000000", + "0c08800000000000", + "60bdc00000000000", + "269d000000000000", + "77cd400000000000", + "6501c00000000000", + "6f46800000000000", + "5ae8000000000000", + "6b70000000000000", + "6758000000000000", + "6e0a800000000000", + "4820000000000000", + "6750c00000000000", + "277e800000000000", + "3271000000000000", + "3df3000000000000", + "60d1000000000000", + "1dd8000000000000", + "3168000000000000", + "57ec000000000000", + "47bd000000000000", + "3d4a000000000000", + "1f90000000000000", + "40f7c00000000000", + "46ec000000000000", + "294c000000000000", + "3d98000000000000", + "4c70400000000000", + "1864000000000000", + "2006800000000000", + "1306400000000000", + "4afac00000000000" + ], + "kind": "finite", + "expected": { + "case": "dyadic_33", + "N": 33, + "INFO": 0, + "S": [ + { + "hex": "4856a09e667f3bcc", + "value": "3.0798844053504575e+40" + }, + { + "hex": "27c030dc4ea03a72", + "value": "3.210270709979987e-117" + }, + { + "hex": "59e2492492492492", + "value": "9.670304457731636e+124" + }, + { + "hex": "2f8777acde80baea", + "value": "9.895953418171721e-80" + }, + { + "hex": "4c97c4dd663ebb88", + "value": "9.548828913863793e+60" + }, + { + "hex": "2400bc38eb8ba412", + "value": "2.8780874925194277e-135" + }, + { + "hex": "2d657ba8b0ee01b9", + "value": "5.2731132444338515e-90" + }, + { + "hex": "284314c3d92a9e91", + "value": "9.685351204144647e-115" + }, + { + "hex": "327279a74590331d", + "value": "1.0964537188245497e-65" + }, + { + "hex": "2a30000000000000", + "value": "1.7440603504673385e-105" + }, + { + "hex": "2c3a20bd700c2c3f", + "value": "1.2232232757172353e-95" + }, + { + "hex": "28e19507ecf5b9e9", + "value": "9.138683826474833e-112" + }, + { + "hex": "3bd6a09e667f3bcc", + "value": "1.9166167708542174e-20" + }, + { + "hex": "2c3f467f2814b0cc", + "value": "1.4642119652065239e-95" + }, + { + "hex": "4c272d59c45f1fc5", + "value": "7.274266734054667e+58" + }, + { + "hex": "46af0b6848d2af1c", + "value": "3.1482924098973314e+32" + }, + { + "hex": "40ed5d7ea914b936", + "value": "60139.95813976454" + }, + { + "hex": "2f7f0b6848d2af1c", + "value": "6.5455579325904866e-80" + }, + { + "hex": "50fa20bd700c2c3f", + "value": "1.2392050846695009e+82" + }, + { + "hex": "473279a74590331d", + "value": "9.5928767647601e+34" + }, + { + "hex": "33f11acee560242a", + "value": "1.7030868905995873e-58" + }, + { + "hex": "3c07c4dd663ebb88", + "value": "1.6106503125759205e-19" + }, + { + "hex": "4141c01aa03be896", + "value": "2326581.2518282635" + }, + { + "hex": "5020000000000000", + "value": "9.263367138985296e+77" + }, + { + "hex": "3f6a43da0adc6899", + "value": "0.0032061823502661066" + }, + { + "hex": "3c711acee560242a", + "value": "1.4835979218054374e-17" + }, + { + "hex": "4b411acee560242a", + "value": "3.27661329181656e+54" + }, + { + "hex": "411a20bd700c2c3f", + "value": "428079.3594214357" + }, + { + "hex": "39afc0bd88a0f1da", + "value": "7.827692240551275e-31" + }, + { + "hex": "53b43d136248490f", + "value": "1.688646021525492e+95" + }, + { + "hex": "4fe314c3d92a9e91", + "value": "6.904506207769621e+76" + }, + { + "hex": "566330218127c0e0", + "value": "1.408245670996139e+108" + }, + { + "hex": "3a68bf9ab06e1af3", + "value": "2.4989552537067353e-27" + } + ], + "SCOND": { + "hex": "0a0d49639c345f20", + "value": "2.9762118711974254e-260" + }, + "AMAX": { + "hex": "77cd400000000000", + "value": "1.207235549665485e+269" + } + } + }, + { + "id": "nonpositive_0000000000000000_0", + "diag": [ + "0000000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_0000000000000000_0", + "N": 5, + "INFO": 1, + "S": [ + { + "hex": "0000000000000000", + "value": "0.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_0000000000000000_2", + "diag": [ + "4010000000000000", + "4022000000000000", + "0000000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_0000000000000000_2", + "N": 5, + "INFO": 3, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "0000000000000000", + "value": "0.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_0000000000000000_4", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "0000000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_0000000000000000_4", + "N": 5, + "INFO": 5, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "0000000000000000", + "value": "0.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "nonpositive_8000000000000000_0", + "diag": [ + "8000000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8000000000000000_0", + "N": 5, + "INFO": 1, + "S": [ + { + "hex": "8000000000000000", + "value": "-0.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_8000000000000000_2", + "diag": [ + "4010000000000000", + "4022000000000000", + "8000000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8000000000000000_2", + "N": 5, + "INFO": 3, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "8000000000000000", + "value": "-0.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_8000000000000000_4", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "8000000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8000000000000000_4", + "N": 5, + "INFO": 5, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "8000000000000000", + "value": "-0.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "nonpositive_bff0000000000000_0", + "diag": [ + "bff0000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_bff0000000000000_0", + "N": 5, + "INFO": 1, + "S": [ + { + "hex": "bff0000000000000", + "value": "-1.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_bff0000000000000_2", + "diag": [ + "4010000000000000", + "4022000000000000", + "bff0000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_bff0000000000000_2", + "N": 5, + "INFO": 3, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "bff0000000000000", + "value": "-1.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_bff0000000000000_4", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "bff0000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_bff0000000000000_4", + "N": 5, + "INFO": 5, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "bff0000000000000", + "value": "-1.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "nonpositive_8010000000000000_0", + "diag": [ + "8010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8010000000000000_0", + "N": 5, + "INFO": 1, + "S": [ + { + "hex": "8010000000000000", + "value": "-2.2250738585072014e-308" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_8010000000000000_2", + "diag": [ + "4010000000000000", + "4022000000000000", + "8010000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8010000000000000_2", + "N": 5, + "INFO": 3, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "8010000000000000", + "value": "-2.2250738585072014e-308" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_8010000000000000_4", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "8010000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_8010000000000000_4", + "N": 5, + "INFO": 5, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "8010000000000000", + "value": "-2.2250738585072014e-308" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "nonpositive_ffefffffffffffff_0", + "diag": [ + "ffefffffffffffff", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_ffefffffffffffff_0", + "N": 5, + "INFO": 1, + "S": [ + { + "hex": "ffefffffffffffff", + "value": "-1.7976931348623157e+308" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_ffefffffffffffff_2", + "diag": [ + "4010000000000000", + "4022000000000000", + "ffefffffffffffff", + "4039000000000000", + "4042000000000000" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_ffefffffffffffff_2", + "N": 5, + "INFO": 3, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "ffefffffffffffff", + "value": "-1.7976931348623157e+308" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "4042000000000000", + "value": "36.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4042000000000000", + "value": "36.0" + } + } + }, + { + "id": "nonpositive_ffefffffffffffff_4", + "diag": [ + "4010000000000000", + "4022000000000000", + "4030000000000000", + "4039000000000000", + "ffefffffffffffff" + ], + "kind": "finite", + "expected": { + "case": "nonpositive_ffefffffffffffff_4", + "N": 5, + "INFO": 5, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "4022000000000000", + "value": "9.0" + }, + { + "hex": "4030000000000000", + "value": "16.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + }, + { + "hex": "ffefffffffffffff", + "value": "-1.7976931348623157e+308" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "multiple_nonpositive", + "diag": [ + "4010000000000000", + "bff0000000000000", + "0000000000000000", + "c022000000000000", + "4039000000000000" + ], + "kind": "finite", + "expected": { + "case": "multiple_nonpositive", + "N": 5, + "INFO": 2, + "S": [ + { + "hex": "4010000000000000", + "value": "4.0" + }, + { + "hex": "bff0000000000000", + "value": "-1.0" + }, + { + "hex": "0000000000000000", + "value": "0.0" + }, + { + "hex": "c022000000000000", + "value": "-9.0" + }, + { + "hex": "4039000000000000", + "value": "25.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "4039000000000000", + "value": "25.0" + } + } + }, + { + "id": "all_positive_zero", + "diag": [ + "0000000000000000", + "0000000000000000", + "0000000000000000" + ], + "kind": "finite", + "expected": { + "case": "all_positive_zero", + "N": 3, + "INFO": 1, + "S": [ + { + "hex": "0000000000000000", + "value": "0.0" + }, + { + "hex": "0000000000000000", + "value": "0.0" + }, + { + "hex": "0000000000000000", + "value": "0.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "0000000000000000", + "value": "0.0" + } + } + }, + { + "id": "all_negative_zero", + "diag": [ + "8000000000000000", + "8000000000000000", + "8000000000000000" + ], + "kind": "finite", + "expected": { + "case": "all_negative_zero", + "N": 3, + "INFO": 1, + "S": [ + { + "hex": "8000000000000000", + "value": "-0.0" + }, + { + "hex": "8000000000000000", + "value": "-0.0" + }, + { + "hex": "8000000000000000", + "value": "-0.0" + } + ], + "SCOND": { + "hex": "c12e240c40000000", + "value": "-987654.125" + }, + "AMAX": { + "hex": "8000000000000000", + "value": "-0.0" + } + } + } + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/test/helpers.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/helpers.js new file mode 100644 index 000000000000..c49c20a33d12 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/helpers.js @@ -0,0 +1,227 @@ +/** +* @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'; + +/* eslint max-nested-callbacks: ["error", 5] -- Nested reference layout matrices and synchronous tape rejection assertions. */ + +// MODULES // + +var DataView = require( '@stdlib/array/dataview' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var min = require( '@stdlib/math/base/special/min' ); +var max = require( '@stdlib/math/base/special/max' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var cases = require( './fixtures/reference.json' ).cases; + + +// VARIABLES // + +var view = new DataView(new ArrayBuffer(8)); + + +// FUNCTIONS // + +/** +* Decodes exact reference bits. +* @private +* @param {string} hex - IEEE bits +* @returns {number} value +*/ +function decode(hex) { + view.setUint32(0, parseInt(hex.slice(0, 8), 16)); + view.setUint32(4, parseInt(hex.slice(8), 16)); + return view.getFloat64(0); +} +/** +* Encodes exact result bits including zero signs. +* @private +* @param {number} x - number +* @returns {string} exact bits +*/ +function bits(x) { + view.setFloat64(0, x); + return (('00000000' + view.getUint32(0).toString(16)).slice(-8) + ('00000000' + view.getUint32(4).toString(16)).slice(-8)); +} +/** +* Maps current numeric storage to exact bits. +* @private +* @param {Float64Array} x - storage +* @returns {StringArray} bits +*/ +function snapshot(x) { + return Array.prototype.map.call(x, bits); +} +/** +* Constructs an injective padded band and output vector. +* @private +* @param {PositiveInteger} h - height +* @param {PositiveInteger} n - columns +* @param {integer} r - row stride +* @param {integer} c - column stride +* @returns {Object} current signed view +*/ +function geometry(h, n, r, c) { + var high; + var low; + var dr; + var dc; + dr = ((h - 1) * r); + dc = ((n - 1) * c); + low = (min(0, dr) + min(0, dc)); + high = (max(0, dr) + max(0, dc)); + return { + 'o': (3 - low), + 'len': ((7 + high) - low) + }; +} +/** +* Runs actual finite reference, layout and guard regression coverage. +* @private +* @param {Object} t - tape assertion context +* @param {Function} f - public routine +* @returns {void} +*/ +function run(t, f) { + cases.forEach(function each(x) { + [ + 121, + 122 + ].forEach(function triangle(u) { + [ + 0, + 2, + 8 + ].forEach(function bandwidth(kd) { + [ + 'column', + 'row', + 'negative', + 'mixed' + ].forEach(function layout(mode) { + var beforeA; + var beforeS; + var beforeC; + var beforeM; + var result; + var order; + var slots; + var diag; + var lda; + var ss; + var ag; + var sg; + var ab; + var sb; + var sc; + var am; + var oc; + var om; + var n; + var h; + var r; + var c; + var a; + var s; + var j; + diag = x.diag.map(decode); + n = diag.length; + h = (kd + 1); + slots = []; + if ((mode === 'column')) { + r = 1; + c = (h + 2); + ss = 1; + lda = c; + order = 102; + } else if ((mode === 'row')) { + r = (n + 2); + c = 1; + ss = 1; + lda = r; + order = 101; + } else if ((mode === 'negative')) { + r = -2; + c = -((2 * h) + 3); + ss = -2; + } else { + r = -2; + c = ((2 * h) + 3); + ss = -3; + } + ag = geometry(h, n, r, c); + sg = geometry(n, 1, ss, 0); + if (order) { + ag.o = 0; + sg.o = 0; + } + ab = new Float64Array((ag.len + 4)); + sb = new Float64Array((sg.len + 4)); + ab.fill(Infinity); + sb.fill(-222); + a = new Float64Array(ab.buffer, 16, ag.len); + s = new Float64Array(sb.buffer, 16, sg.len); + sc = new Float64Array(7); + am = new Float64Array(8); + sc.fill(-987654.125); + am.fill(-333); + oc = ( order ) ? 0 : 3; + om = ( order ) ? 0 : 5; + for (j = 0; (j < n); j++) { + a[((ag.o + ((u === 121) ? (kd * r) : 0)) + (j * c))] = diag[j]; + slots.push(((sg.o + (j * ss)) + 2)); + } + beforeA = snapshot(ab); + beforeS = snapshot(sb); + beforeC = snapshot(sc); + beforeM = snapshot(am); + result = ( order ) ? f(order, u, n, kd, a, lda, s, sc, am) : f.ndarray(u, n, kd, a, r, c, ag.o, s, ss, sg.o, sc, oc, am, om); + t.strictEqual(result, x.expected.INFO, ((x.id + ' INFO ') + mode)); + for (j = 0; (j < n); j++) { + t.strictEqual(bits(s[(sg.o + (j * ss))]), x.expected.S[j].hex, (x.id + ' output bits')); + if ((result === 0)) { + t.ok((abs((((diag[j] * s[(sg.o + (j * ss))]) * s[(sg.o + (j * ss))]) - 1)) <= (8 * 2.220446049250313e-16)), 'independent scaled diagonal near one'); + } + } + t.strictEqual(bits(sc[oc]), x.expected.SCOND.hex, 'complete scalar sentinel/output'); + t.strictEqual(bits(am[om]), x.expected.AMAX.hex, 'full-column AMAX'); + t.deepEqual(snapshot(ab), beforeA, 'input and unused band bits untouched'); + t.deepEqual(snapshot(sb).filter(function guard(v, idx) { + return (slots.indexOf(idx) < 0); + }), beforeS.filter(function guard(v, idx) { + return (slots.indexOf(idx) < 0); + }), 'output padding untouched'); + beforeC[oc] = bits(sc[oc]); + beforeM[om] = bits(am[om]); + t.deepEqual(snapshot(sc), beforeC, 'only active SCOND scalar written'); + t.deepEqual(snapshot(am), beforeM, 'only active AMAX scalar written'); + }); + }); + }); + }); +} + + +// EXPORTS // + +module.exports = { + 'run': run, + 'bits': bits, + 'decode': decode, + 'snapshot': snapshot +}; diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.js new file mode 100644 index 000000000000..bf7a28162e42 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.js @@ -0,0 +1,38 @@ +/** +* @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 f = require( './../lib/main.js' ); +var run = require( './helpers.js' ).run; + + +// TESTS // + +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof f, 'function', 'main export'); + t.strictEqual(typeof f.ndarray, 'function', 'ndarray export'); + t.end(); +}); +tape('dpbequ: pure JavaScript finite reference and storage regressions', function test(t) { + run(t, f); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.native.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.native.js new file mode 100644 index 000000000000..26579e3718b6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test.native.js @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var factory = require( './../lib/factory.js' ); +var eligible = require( './../lib/can_use_native.js' ); +var base = require( './../lib/base.js' ); +var run = require( './helpers.js' ).run; + + +// VARIABLES // + +var addon = tryRequire( resolve(__dirname, '../src/addon.node') ); +var opts = { + 'skip': (addon instanceof Error) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test(t) { + t.ok( true, __filename ); + t.strictEqual(typeof addon, 'function', 'actual addon'); + t.end(); +}); +tape( 'dpbequ: compiled native reference and storage regressions', opts, function test(t) { + var calls = 0; + var f; + f = factory(function backend() { + calls += 1; + return addon.apply(null, arguments); + }, eligible, base); + run(t, f); + t.strictEqual(calls, 768, 'every ordinary reference fixture actually dispatches native'); + t.end(); +}); +tape( 'dpbequ: independent raw argument protocol before mutation', opts, function test(t) { + var args; + var sc; + var am; + sc = new Float64Array([91]); + am = new Float64Array([92]); + args = [122, 0, 0, null, null, null, null, null, null, null, sc, 0, am, 0]; + t.throws(function bad() { + addon.apply(null, args.slice(0, 13)); + }, RangeError, 'missing raw argument rejected'); + t.throws(function bad() { + addon.apply(null, args.concat([1])); + }, RangeError, 'extra raw argument rejected'); + t.strictEqual(sc[0], 91, 'rejections preserve SCOND'); + t.strictEqual(am[0], 92, 'rejections preserve AMAX'); + t.strictEqual(addon.apply(null, args), 0, 'raw empty ignores inactive metadata'); + t.strictEqual(sc[0], 1, 'empty SCOND'); + t.strictEqual(am[0], 0, 'empty AMAX'); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test_api.js b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test_api.js new file mode 100644 index 000000000000..c657e7e516c7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpbequ/test/test_api.js @@ -0,0 +1,301 @@ +/** +* @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'; + +/* eslint max-nested-callbacks: ["error", 5] -- Nested reference layout matrices and synchronous tape rejection assertions. */ + +// MODULES // + +var vm = require( 'vm' ); +var tape = require( 'tape' ); +var Number = require( '@stdlib/number/ctor' ); +var Proxy = require( '@stdlib/proxy/ctor' ); +var SharedArrayBuffer = require( '@stdlib/array/shared-buffer' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var main = require( './../lib/main.js' ); +var native = require( './../lib' ); +var factory = require( './../lib/factory.js' ); +var base = require( './../lib/base.js' ); +var eligible = require( './../lib/can_use_native.js' ); +var snapshot = require( './helpers.js' ).snapshot; +var bits = require( './helpers.js' ).bits; + + +// TESTS // + +tape('dpbequ: complete failed outputs and explicit first-zero reduction', function test(t) { + [ + main, + native + ].forEach(function backend(f) { + var sc; + var am; + var a; + var s; + a = new Float64Array([ + 4, + -1, + 100, + 9 + ]); + s = new Float64Array(4); + sc = new Float64Array([-91]); + am = new Float64Array([-92]); + t.strictEqual(f(102, 122, 4, 0, a, 1, s, sc, am), 2, 'first one-based nonpositive'); + t.deepEqual(Array.prototype.slice.call(s), [ + 4, + -1, + 100, + 9 + ], 'all diagonals copied, including suffix'); + t.strictEqual(am[0], 100, 'AMAX includes later columns'); + t.strictEqual(sc[0], -91, 'SCOND exact caller sentinel unchanged'); + a = new Float64Array([ + -0, + +0 + ]); + t.strictEqual(f(102, 122, 2, 0, a, 1, s, sc, am), 1, 'zero fails'); + t.strictEqual(bits(am[0]), '8000000000000000', 'deliberate first-tie AMAX minus-zero'); + t.strictEqual(bits(s[0]), '8000000000000000', 'copied minus-zero'); + t.strictEqual(bits(s[1]), '0000000000000000', 'copied plus-zero'); + }); + t.end(); +}); +tape('dpbequ: empty accesses only validated active scalar outputs', function test(t) { + [ + main, + native + ].forEach(function backend(f) { + var trap; + var sc; + var am; + trap = new Proxy({}, { + 'get': function get() { + throw new Error('inactive read'); + } + }); + sc = new Float64Array([ + 91, + 92, + 93 + ]); + am = new Float64Array([ + 94, + 95, + 96 + ]); + t.strictEqual(f.ndarray(121, 0, 2147483646, trap, trap, trap, trap, trap, trap, trap, sc, 1, am, 2), 0, 'inactive ndarray operands ignored'); + t.deepEqual(Array.prototype.slice.call(sc), [ + 91, + 1, + 93 + ], 'only active SCOND'); + t.deepEqual(Array.prototype.slice.call(am), [ + 94, + 95, + 0 + ], 'only active AMAX'); + t.strictEqual(f(102, 122, 0, 2147483646, trap, 2147483647, trap, sc, am), 0, 'empty main before unused native casts'); + t.throws(function bad() { + f(102, 122, 0, 8, trap, 1, trap, sc, am); + }, RangeError, 'leading dimension required even empty'); + t.throws(function bad() { + f.ndarray(121, 0, 0, trap, trap, trap, trap, trap, trap, trap, sc, 0, sc, 0); + }, RangeError, 'active empty scalars must be disjoint'); + }); + t.end(); +}); +tape('dpbequ: invalid metadata, finite domain and aliases never mutate outputs', function test(t) { + [ + main, + native + ].forEach(function backend(f) { + var initial; + var storage; + var views; + var bads; + var sc; + var am; + var vs; + var a; + var s; + var i; + var j; + a = new Float64Array([ + 4, + 9, + 16, + 25 + ]); + s = new Float64Array([ + 11, + 12, + 13, + 14 + ]); + sc = new Float64Array([15]); + am = new Float64Array([16]); + bads = [ + NaN, + Infinity, + -1, + 2147483647, + 0.5, + '2', + new Number(2) + ]; + bads.forEach(function each(n) { + initial = [ + snapshot(a), + snapshot(s), + snapshot(sc), + snapshot(am) + ]; + t.throws(function bad() { + f(102, 122, n, 0, a, 1, s, sc, am); + }, RangeError, 'dimension rejected'); + t.deepEqual([ + snapshot(a), + snapshot(s), + snapshot(sc), + snapshot(am) + ], initial, 'dimension rejection preserves bytes'); + }); + [ + NaN, + Infinity, + -Infinity + ].forEach(function each(v) { + a[3] = v; + initial = [ + snapshot(a), + snapshot(s), + snapshot(sc), + snapshot(am) + ]; + t.throws(function bad() { + f(102, 122, 4, 0, a, 1, s, sc, am); + }, RangeError, 'late nonfinite diagonal rejected before earlier writes'); + t.deepEqual([ + snapshot(a), + snapshot(s), + snapshot(sc), + snapshot(am) + ], initial, 'late rejection preserves all bytes'); + }); + a[3] = 25; + t.throws(function bad() { + f.ndarray(122, 2, 1, a, 1, 1, 0, s, 1, 0, sc, 0, am, 0); + }, RangeError, 'colliding full-band view rejected'); + t.throws(function bad() { + f.ndarray(122, 2, 0, a, 0, -1, 0, s, 1, 0, sc, 0, am, 0); + }, RangeError, 'negative end beyond backing rejected'); + t.throws(function bad() { + f.ndarray(122, 2, 0, a, 0, 1, 0, s, 0, 0, sc, 0, am, 0); + }, RangeError, 'output broadcasts rejected'); + storage = new ArrayBuffer(512); + views = [ + new Float64Array(storage, 0, 8), + new Float64Array(storage, 128, 8), + new Float64Array(storage, 256, 8), + new Float64Array(storage, 384, 8) + ]; + for (i = 0; (i < 4); i++) { + for (j = (i + 1); (j < 4); j++) { + vs = views.slice(); + vs[j] = new Float64Array(storage, (i * 128), 8); + views[0].fill(4); + initial = views.map(snapshot); + t.throws(f.bind(null, 102, 122, 2, 0, vs[0], 1, vs[1], vs[2], vs[3]), RangeError, ((('pairwise alias ' + i) + ',') + j)); + t.deepEqual(views.map(snapshot), initial, 'all storage preserved'); + } + } + views.forEach(function fill(v) { + v.fill(4); + }); + t.strictEqual(f(102, 122, 2, 0, views[0], 1, views[1], views[2], views[3]), 0, 'same backing disjoint views supported'); + }); + t.end(); +}); +tape('dpbequ: captured intrinsic branding and fallback protocol', function test(t) { + var wrapped; + var calls; + var sc; + var am; + var s; + [ + main, + native + ].forEach(function backend(f) { + var sc; + var am; + var a; + var s; + a = new Float64Array([4]); + s = new Float64Array(1); + sc = new Float64Array(1); + am = new Float64Array(1); + Object.defineProperty(a, 'length', { + 'get': function get() { + throw new Error('shadow getter'); + } + }); + Object.defineProperty(s, 'buffer', { + 'get': function get() { + throw new Error('shadow getter'); + } + }); + t.strictEqual(f(102, 122, 1, 0, a, 1, s, sc, am), 0, 'shadow properties ignored'); + a = vm.runInNewContext('new Float64Array([9])'); + t.strictEqual(f(102, 122, 1, 0, a, 1, s, sc, am), 0, 'genuine crossrealm supported'); + t.strictEqual(s[0], (1 / 3), 'crossrealm output'); + a = new Float64Array(new SharedArrayBuffer(8)); + a[0] = 4; + t.throws(function bad() { + f(102, 122, 1, 0, a, 1, s, sc, am); + }, TypeError, 'shared storage rejected'); + a = new Float64Array([4]); + t.throws(function bad() { + f(102, 122, 1, 0, new Proxy(a, {}), 1, s, sc, am); + }, TypeError, 'proxy rejected'); + }); + calls = 0; + wrapped = factory(function dispatch() { + calls += 1; + return base.apply(null, arguments); + }, eligible, base); + s = new Float64Array(1); + sc = new Float64Array(1); + am = new Float64Array(1); + t.strictEqual(wrapped.ndarray(122, 1, 0, new Float64Array([4]), 9007199254740991, 9007199254740991, 0, s, 9007199254740991, 0, sc, 0, am, 0), 0, 'valid wider unused metadata uses actual JS'); + t.strictEqual(calls, 0, 'native not invoked on fallback'); + t.strictEqual(wrapped(102, 122, 1, 0, new Float64Array([4]), 1, s, sc, am), 0, 'ordinary metadata dispatches'); + t.strictEqual(calls, 1, 'dispatch actually invoked'); + wrapped = factory(function fail() { + throw new RangeError('native alias error'); + }, function yes() { + return true; + }, function badFallback() { + t.fail('must not fall back after native error'); + }); + t.throws(function bad() { + wrapped(102, 122, 1, 0, new Float64Array([4]), 1, s, sc, am); + }, /native alias error/, 'native rejection propagates'); + t.end(); +});