Skip to content

Commit 477e9ce

Browse files
committed
chore: initial implementation
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent e2d5250 commit 477e9ce

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed

lib/node_modules/@stdlib/blas/base/sgbmv/examples/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ var opts = {
2727

2828
const A = [0, 9, 10, // First row (upper band)
2929
11, 12, 5, // Second row (main diagonal)
30-
6, 7, 8, // Third row (lower band)
31-
0, 1, 2, // Fourth row (lower band)
32-
0, 0, 3]; // Packed storage (row-major)
30+
1, 2, 0 // Fourth row (lower band)
31+
]; // Packed storage (row-major)
3332
const x = [57, 245, 121];
3433
const y = [0, 0, 0];
3534
console.log( x );
3635
console.log( y );
3736

38-
const order = 'column-major';
37+
const order = 'row-major';
3938
const trans = 'no-transpose';
4039
const LDA = 3;
4140
const M = 3, N = 3;

lib/node_modules/@stdlib/blas/base/sgbmv/lib/base.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -112,40 +112,34 @@ function sgbmv(trans, M, N, KL, KU, alpha, A, strideA1, strideA2, offsetA, x, st
112112
kup1 = KU + 1;
113113
ix1 = offsetX;
114114
for (i1 = 0; i1 < xlen; i1++) {
115-
tmp = f32(alpha * x[ix1]);
115+
tmp = f32(alpha * x[ix1]); // Compute scaled x[i1]
116116
oa = offsetA + (sa1 * i1);
117117
iy1 = offsetY;
118+
119+
console.log(`Processing x[${i1}] = ${x[ix1]}, scaled tmp = ${tmp}`);
120+
console.log(`Offset in A (oa) = ${oa}`);
121+
118122
for (i0 = Math.max(0, i1 - KU); i0 < Math.min(ylen, i1 + KL + 1); i0++) {
119-
// Calculate diagonal offset
120-
let diag_offset = i0 - i1;
121-
122-
// Fix the a_idx calculation for banded matrix format
123-
// The banded matrix layout appears to have a different structure than expected
124-
// The correct index depends on the exact layout of your band matrix
125-
126-
// Based on the debug output pattern, this appears to be the correct formula:
127-
if (diag_offset == -1) {
128-
// Lower diagonal elements
129-
a_idx = 3 + (3 * i1);
130-
} else if (diag_offset == 0) {
131-
// Main diagonal elements (9, 12, 8)
132-
if (i1 == 0) a_idx = 1;
133-
else if (i1 == 1) a_idx = 4;
134-
else if (i1 == 2) a_idx = 8; // This was wrong in original - should be 8 not 7
135-
} else if (diag_offset == 1) {
136-
// Upper diagonal elements
137-
a_idx = 2 + (3 * i1);
138-
}
123+
// Fixed indexing for banded matrix
124+
a_idx = oa + (kup1 + KU) * sa0;
125+
console.log(`i0 = ${i0}, a_idx = ${a_idx}, A[a_idx] = ${A[a_idx]}`);
139126

140-
if (a_idx >= 0 && a_idx < A.length) {
141-
y[iy1] += f32(A[a_idx] * tmp);
127+
if (i0 < ylen && a_idx >= 0) {
128+
y[iy1] += f32(A[a_idx] * tmp); // Accumulate correctly
129+
console.log(`Updated y[${i0}] = ${y[iy1]}`);
142130
}
143131
iy1 += strideY;
144132
}
133+
134+
// Debugging: Print intermediate y after processing x[i1]
135+
console.log(`Intermediate y after processing x[${i1}]: [${y}]`);
145136
ix1 += strideX;
146137
}
138+
console.log("Expected: [3208, 4236, 2072]");
147139
return y;
148140
}
141+
142+
// Leaving the second part unchanged
149143
kup1 = KU + 1;
150144
iy1 = offsetY;
151145
for (i1 = 0; i1 < ylen; i1++) {

lib/node_modules/@stdlib/blas/base/sgbmv/lib/ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function sgemv( trans, M, N, KL, KU, alpha, A, strideA1, strideA2, offsetA, x, s
9090
if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) {
9191
return y;
9292
}
93-
return base( trans, M, N, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len
93+
return base( trans, M, N, KL, KU, alpha, A, strideA1, strideA2, offsetA, x, strideX, offsetX, beta, y, strideY, offsetY ); // eslint-disable-line max-len
9494
}
9595

9696

lib/node_modules/@stdlib/blas/base/sgbmv/lib/sgbmv.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ var base = require( './base.js' );
3636
* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed
3737
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
3838
* @param {NonNegativeInteger} N - number of columns in the matrix `A`
39+
* @param {NonNegativeInteger} KL - number of sub-diagonals of matrix `A`
40+
* @param {NonNegativeInteger} KU - number of super-diagonals of matrix `A`
3941
* @param {number} alpha - scalar constant
4042
* @param {Float32Array} A - input matrix
4143
* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
@@ -118,7 +120,7 @@ function sgbmv( order, trans, M, N, KL, KU, alpha, A, LDA, x, strideX, beta, y,
118120
sa1 = LDA;
119121
sa2 = 1;
120122
}
121-
return base( trans, M, N, alpha, A, sa1, sa2, 0, x, strideX, ox, beta, y, strideY, oy ); // eslint-disable-line max-len
123+
return base( trans, M, N, KL, KU, alpha, A, sa1, sa2, 0, x, strideX, ox, beta, y, strideY, oy ); // eslint-disable-line max-len
122124
}
123125

124126

0 commit comments

Comments
 (0)