Skip to content

Commit 4fe4ba7

Browse files
committed
feat: add lapack/base/dlasyf
Implement the partial Bunch–Kaufman panel with JavaScript and C paths, checked output staging, reference-order helpers and regression coverage. AI-assisted implementation, tests, documentation and independent automated review by OpenAI Codex under benatsf’s authorization. The public API is proposed under RFC #2464. Assisted-by: OpenAI Codex
1 parent d27df7e commit 4fe4ba7

35 files changed

Lines changed: 11546 additions & 0 deletions
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
This package derives the DLASYF Bunch-Kaufman panel algorithm and narrow private DGEMV/DGEMMTR updates from Reference-LAPACK commit 2e5d9c1273435fbd953adb294ed603e4789afaba. DGEMMTR author: Martin Koehler. Original source and license remain pinned in the contribution evidence. Signed one-based pivots and operation order are retained. The safe empty KB-only branch is new package behavior, not unchanged reference parity.
2+
3+
Copyright (c) 1992-2025 The University of Tennessee and The University
4+
of Tennessee Research Foundation. All rights
5+
reserved.
6+
Copyright (c) 2000-2025 The University of California Berkeley. All
7+
rights reserved.
8+
Copyright (c) 2006-2025 The University of Colorado Denver. All rights
9+
reserved.
10+
11+
$COPYRIGHT$
12+
13+
Additional copyrights may follow
14+
15+
$HEADER$
16+
17+
Redistribution and use in source and binary forms, with or without
18+
modification, are permitted provided that the following conditions are
19+
met:
20+
21+
- Redistributions of source code must retain the above copyright
22+
notice, this list of conditions and the following disclaimer.
23+
24+
- Redistributions in binary form must reproduce the above copyright
25+
notice, this list of conditions and the following disclaimer listed
26+
in this license in the documentation and/or other materials
27+
provided with the distribution.
28+
29+
- Neither the name of the copyright holders nor the names of its
30+
contributors may be used to endorse or promote products derived from
31+
this software without specific prior written permission.
32+
33+
The copyright holders provide no reassurances that the source code
34+
provided does not infringe any patent, copyright, or any other
35+
intellectual property rights of third parties. The copyright holders
36+
disclaim any liability to any recipient for claims brought against
37+
recipient by any third party for infringement of that parties
38+
intellectual property rights.
39+
40+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎lib/node_modules/@stdlib/lapack/base/dlasyf/README.md‎

Lines changed: 367 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
25+
var Int32Array = require( '@stdlib/array/int32' );
26+
var format = require( '@stdlib/string/format' );
27+
var pkg = require( './../package.json' ).name;
28+
var dlasyf = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a bounded reset-and-factor benchmark.
35+
*
36+
* @private
37+
* @param {PositiveInteger} N - matrix order
38+
* @param {PositiveInteger} NB - panel width
39+
* @param {string} uplo - stored triangle
40+
* @returns {Function} benchmark function
41+
*/
42+
function createBenchmark( N, NB, uplo ) {
43+
var original;
44+
var IPIV;
45+
var KB;
46+
var A;
47+
var W;
48+
var i;
49+
var j;
50+
51+
original = new Float64Array( N*N );
52+
A = new Float64Array( N*N );
53+
W = new Float64Array( N*NB );
54+
IPIV = new Int32Array( N );
55+
KB = new Int32Array( 1 );
56+
for ( i = 0; i < N; i++ ) {
57+
for ( j = 0; j < N; j++ ) {
58+
if ( i === j ) {
59+
original[ (i*N)+j ] = N + 2.0;
60+
} else if ( ( uplo === 'upper' && i < j ) || ( uplo === 'lower' && i > j ) ) {
61+
original[ (i*N)+j ] = 0.25;
62+
} else {
63+
original[ (i*N)+j ] = 999.0;
64+
}
65+
}
66+
}
67+
return benchmark;
68+
69+
/**
70+
* Benchmark function.
71+
*
72+
* @private
73+
* @param {Benchmark} b - benchmark instance
74+
*/
75+
function benchmark( b ) {
76+
var expected;
77+
var start;
78+
var info;
79+
var stop;
80+
var i;
81+
82+
expected = ( N <= NB ) ? N : NB-1;
83+
info = 0;
84+
b.tic();
85+
for ( i = 0; i < b.iterations; i++ ) {
86+
// Include resetting the changed input in each iteration:
87+
A.set( original );
88+
info = dlasyf( 'row-major', uplo, N, NB, KB, A, N, IPIV, W, NB );
89+
if ( info !== 0 || KB[ 0 ] !== expected ) {
90+
b.fail( 'should factor the expected nonsingular panel' );
91+
break;
92+
}
93+
}
94+
b.toc();
95+
start = ( uplo === 'upper' ) ? N-expected : 0;
96+
stop = start + expected;
97+
for ( i = start; i < stop; i++ ) {
98+
if ( IPIV[ i ] !== i+1 ) {
99+
b.fail( 'should produce the expected identity pivot targets' );
100+
break;
101+
}
102+
}
103+
if ( ( uplo === 'upper' && A[ N ] !== 999.0 ) || ( uplo === 'lower' && A[ 1 ] !== 999.0 ) ) {
104+
b.fail( 'should preserve the ignored triangle' );
105+
}
106+
b.pass( 'benchmark finished' );
107+
b.end();
108+
}
109+
}
110+
111+
112+
// MAIN //
113+
114+
/**
115+
* Main execution sequence.
116+
*
117+
* @private
118+
*/
119+
function main() {
120+
var options;
121+
var sizes;
122+
var uplos;
123+
var width;
124+
var name;
125+
var fcn;
126+
var i;
127+
var j;
128+
var k;
129+
130+
options = {
131+
'iterations': 200,
132+
'repeats': 2
133+
};
134+
sizes = [ 8, 16 ];
135+
uplos = [ 'upper', 'lower' ];
136+
for ( i = 0; i < sizes.length; i++ ) {
137+
for ( j = 0; j < uplos.length; j++ ) {
138+
for ( k = 0; k < 2; k++ ) {
139+
width = ( k === 1 ) ? sizes[ i ] : 4;
140+
name = format( '%s:triangle=%s:N=%d:NB=%d', pkg, uplos[ j ], sizes[ i ], width );
141+
fcn = createBenchmark( sizes[ i ], width, uplos[ j ] );
142+
bench( name, options, fcn );
143+
}
144+
}
145+
}
146+
}
147+
148+
main();
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
25+
var Int32Array = require( '@stdlib/array/int32' );
26+
var format = require( '@stdlib/string/format' );
27+
var pkg = require( './../package.json' ).name;
28+
var dlasyf = require( './../lib' ).ndarray;
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a bounded reset-and-factor benchmark.
35+
*
36+
* @private
37+
* @param {PositiveInteger} N - matrix order
38+
* @param {PositiveInteger} NB - panel width
39+
* @param {string} uplo - stored triangle
40+
* @returns {Function} benchmark function
41+
*/
42+
function createBenchmark( N, NB, uplo ) {
43+
var original;
44+
var IPIV;
45+
var KB;
46+
var A;
47+
var W;
48+
var i;
49+
var j;
50+
51+
original = new Float64Array( N*N );
52+
A = new Float64Array( N*N );
53+
W = new Float64Array( N*NB );
54+
IPIV = new Int32Array( N );
55+
KB = new Int32Array( 1 );
56+
for ( i = 0; i < N; i++ ) {
57+
for ( j = 0; j < N; j++ ) {
58+
if ( i === j ) {
59+
original[ (i*N)+j ] = N + 2.0;
60+
} else if ( ( uplo === 'upper' && i < j ) || ( uplo === 'lower' && i > j ) ) {
61+
original[ (i*N)+j ] = 0.25;
62+
} else {
63+
original[ (i*N)+j ] = 999.0;
64+
}
65+
}
66+
}
67+
return benchmark;
68+
69+
/**
70+
* Benchmark function.
71+
*
72+
* @private
73+
* @param {Benchmark} b - benchmark instance
74+
*/
75+
function benchmark( b ) {
76+
var expected;
77+
var start;
78+
var info;
79+
var stop;
80+
var i;
81+
82+
expected = ( N <= NB ) ? N : NB-1;
83+
info = 0;
84+
b.tic();
85+
for ( i = 0; i < b.iterations; i++ ) {
86+
// Include resetting the changed input in each iteration:
87+
A.set( original );
88+
info = dlasyf( uplo, N, NB, KB, 0, A, N, 1, 0, IPIV, 1, 0, W, NB, 1, 0 ); // eslint-disable-line max-len
89+
if ( info !== 0 || KB[ 0 ] !== expected ) {
90+
b.fail( 'should factor the expected nonsingular panel' );
91+
break;
92+
}
93+
}
94+
b.toc();
95+
start = ( uplo === 'upper' ) ? N-expected : 0;
96+
stop = start + expected;
97+
for ( i = start; i < stop; i++ ) {
98+
if ( IPIV[ i ] !== i+1 ) {
99+
b.fail( 'should produce the expected identity pivot targets' );
100+
break;
101+
}
102+
}
103+
if ( ( uplo === 'upper' && A[ N ] !== 999.0 ) || ( uplo === 'lower' && A[ 1 ] !== 999.0 ) ) {
104+
b.fail( 'should preserve the ignored triangle' );
105+
}
106+
b.pass( 'benchmark finished' );
107+
b.end();
108+
}
109+
}
110+
111+
112+
// MAIN //
113+
114+
/**
115+
* Main execution sequence.
116+
*
117+
* @private
118+
*/
119+
function main() {
120+
var options;
121+
var sizes;
122+
var uplos;
123+
var width;
124+
var name;
125+
var fcn;
126+
var i;
127+
var j;
128+
var k;
129+
130+
options = {
131+
'iterations': 200,
132+
'repeats': 2
133+
};
134+
sizes = [ 8, 16 ];
135+
uplos = [ 'upper', 'lower' ];
136+
for ( i = 0; i < sizes.length; i++ ) {
137+
for ( j = 0; j < uplos.length; j++ ) {
138+
for ( k = 0; k < 2; k++ ) {
139+
width = ( k === 1 ) ? sizes[ i ] : 4;
140+
name = format( '%s:ndarray:triangle=%s:N=%d:NB=%d', pkg, uplos[ j ], sizes[ i ], width );
141+
fcn = createBenchmark( sizes[ i ], width, uplos[ j ] );
142+
bench( name, options, fcn );
143+
}
144+
}
145+
}
146+
}
147+
148+
main();

0 commit comments

Comments
 (0)