Skip to content
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d811c8c
feat: add blas/base/dsbmv
ShabiShett07 Apr 11, 2025
6e2483c
chore: add complete implementation
ShabiShett07 Apr 12, 2025
0a25c0d
chore: update copyright years
stdlib-bot Apr 12, 2025
409d821
chore: add test cases
ShabiShett07 Apr 12, 2025
16a9063
chore: add test cases
ShabiShett07 Apr 12, 2025
30e624d
chore: update test cases
ShabiShett07 Apr 13, 2025
a4a8183
chore: update examples
ShabiShett07 Apr 14, 2025
e25f528
chore: update examples
ShabiShett07 Apr 14, 2025
5f6910a
chore: update fixtures
ShabiShett07 Apr 16, 2025
4fd0fcd
chore: update jsdoc
ShabiShett07 Apr 16, 2025
7475eff
chore: update examples
ShabiShett07 Apr 16, 2025
55a7239
chore: fix test fixtures
ShabiShett07 Apr 24, 2025
56ff685
chore: fix test fixtures
ShabiShett07 Apr 24, 2025
87bd6e9
test: update test cases
ShabiShett07 Apr 29, 2025
3f6abe6
remove: indentation
ShabiShett07 Apr 30, 2025
541a527
bench: update variable declarations
Jul 23, 2025
0e094de
chore: update repl.txt
Jul 23, 2025
6739244
chore: update jsdoc
Jul 23, 2025
bc5a88f
chore: update test cases
Jul 24, 2025
673ff3b
chore: update example
Jul 24, 2025
210b9a1
refactor: update jsdoc and reduce arithmetic operations
Jul 24, 2025
5fb6caf
chore: update jsdoc
Jul 24, 2025
9b116b9
chore: use alpha and beta symbols
Jul 24, 2025
506ba6b
test: update fixtures
Jul 24, 2025
f6e13a0
test: update fixtures
Jul 24, 2025
d3e5a48
test: update test description
Jul 24, 2025
6d52968
test: update test description
Jul 24, 2025
1270d7c
chore: update description
Jul 24, 2025
c7f20c0
chore: update markdown file
Jul 24, 2025
a4cb271
test: complete test coverage
Jul 24, 2025
1ebeb8a
test: fix test cases
Jul 24, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add blas/base/dsbmv
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
  • Loading branch information
ShabiShett07 committed Apr 11, 2025
commit d811c8c28dc9c2c67ecc96ff4d9bac99e722a58b
174 changes: 174 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dsbmv/lib/ndarray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray;
var dscal = require( '@stdlib/blas/base/dscal' ).ndarray;
var max = require( '@stdlib/math/base/special/max' );
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' );


// MAIN //

/**
* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix, with `K` super-diagonals.
*
* @param {string} order - storage layout
* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced
* @param {NonNegativeInteger} N - number of elements along each dimension of `A`
* @param {NonNegativeInteger} K - number of super-diagonals of the matrix `A`
* @param {number} alpha - scalar constant
* @param {Float64Array} A - matrix
* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
* @param {Float64Array} x - first input array
* @param {integer} strideX - `x` stride length
* @param {NonNegativeInteger} offsetX - starting `x` index
* @param {number} beta - scalar constant
* @param {Float64Array} y - second input array
* @param {integer} strideY - `y` stride length
* @param {NonNegativeInteger} offsetY - starting `y` index
* @throws {TypeError} first argument must be a valid order
* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix
* @throws {RangeError} third argument must be a nonnegative integer
* @throws {RangeError} sixth argument must be greater than or equal to max(1,N)
* @throws {RangeError} eighth argument must be non-zero
* @throws {RangeError} twelfth argument must be non-zero
* @returns {Float64Array} `y`
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0, 3.0, 5.0 ] );
* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] );
*
* dsbmv( 'row-major', 'lower', 3, 1, 1.0, A, 2, x, 1, 0, 0.0, y, 1, 0 );
* // y => <Float64Array>[ 2.0, 17.0, 21.0 ]
*/
function dsbmv( order, uplo, N, K, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len
var temp1;
var temp2;
var jmin;
var ix;
var iy;
var jx;
var jy;
var ox;
var oy;
var i;
var j;

if ( !isLayout( order ) ) {
throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order );
}
if ( !isMatrixTriangle( uplo ) ) {
throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo );
}
if ( N < 0 ) {
throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N );
}
if ( K < 0 ) {
throw new RangeError( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', K );
}
if ( LDA < max( K + 1 ) ) {
throw new RangeError( 'invalid argument. Seventh argument must be greater than or equal to ( K + 1 ). Value: `%d`.', N, LDA );
}
if ( strideX === 0 ) {
throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX );
}
if ( strideY === 0 ) {
throw new RangeError( 'invalid argument. Therteenth argument must be non-zero. Value: `%d`.', strideY );
}
if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) {
return y;
}
// Form: y = beta*y
if ( beta !== 1.0 ) {
if ( beta === 0.0 ) {
dfill( N, 0.0, y, strideY, offsetY );
} else {
dscal( N, beta, y, strideY, offsetY );
}
}
if ( alpha === 0.0 ) {
return y;
}
ox = offsetX;
oy = offsetY;

// Form: y = alpha*A*x + y
if (
( order === 'row-major' && uplo === 'upper' ) ||
( order === 'column-major' && uplo === 'lower' )
) {
ix = ox;
iy = oy;
for ( i = 0; i < N; i++ ) {
temp1 = alpha * x[ ix ];
temp2 = 0.0;
jmin = max( 0, i - K );
jx = ox + ( jmin * strideX );
jy = oy + ( jmin * strideY );
for ( j = jmin; j < i; j++ ) {
y[ jy ] += temp1 * A[ (i - j) + ( j * (K + 1) ) ];
temp2 += x[ jx ] * A[ (i - j) + ( j * (K + 1) ) ];
jx += strideX;
jy += strideY;
}
y[ iy ] += ( temp1 * A[ 0 + ( i * (K + 1) ) ] ) + ( alpha * temp2 );
ix += strideX;
iy += strideY;
}
return y;
}

// ( order === 'row-major' && uplo === 'lower') || ( order === 'column-major' && uplo === 'upper' )

Check warning on line 144 in lib/node_modules/@stdlib/blas/base/dsbmv/lib/ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"

Check warning on line 144 in lib/node_modules/@stdlib/blas/base/dsbmv/lib/ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"
if (
( order === 'row-major' && uplo === 'lower' ) ||
( order === 'column-major' && uplo === 'upper' )
) {
ix = ox;
iy = oy;
for ( i = 0; i < N; i++ ) {
temp1 = alpha * x[ ix ];
temp2 = 0.0;
jmin = max( 0, i - K );
jx = ox + ( jmin * strideX );
jy = oy + ( jmin * strideY );
for ( j = jmin; j < i; j++ ) {
y[ jy ] += temp1 * ( A[ (K + j - i) + ( i * (K + 1) ) ] );
temp2 += x[ jx ] * ( A[ (K + j - i) + ( i * (K + 1) ) ] );
jx += strideX;
jy += strideY;
}
y[ iy ] += ( temp1 * ( A[ K + ( i * (K + 1) ) ] ) ) + ( alpha * temp2 );

Check warning on line 163 in lib/node_modules/@stdlib/blas/base/dsbmv/lib/ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 84. Maximum allowed is 80
ix += strideX;
iy += strideY;
}
return y;
}
}


// EXPORTS //

module.exports = dsbmv;
Loading