Skip to content

feat: add blas/base/dtbmv #6862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

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/dtbmv
---
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 29, 2025
commit 1d9ed30941b934e0d3cfee65ef72d4ad5bcc60dc
171 changes: 171 additions & 0 deletions lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );
var max = require( '@stdlib/math/base/special/max' );
var min = require( '@stdlib/math/base/special/min' );


// MAIN //

/**
* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular band matrix, with ( `K` + 1 ) diagonals.
*
* @private
* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix
* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed
* @param {string} diag - specifies whether `A` has a unit diagonal
* @param {NonNegativeInteger} N - number of elements along each dimension of `A`
* @param {NonNegativeInteger} K - number of super-diagonals or sub-diagonals of the matrix `A`
* @param {Float64Array} A - input matrix
* @param {integer} strideA1 - stride of the first dimension of `A`
* @param {integer} strideA2 - stride of the second dimension of `A`
* @param {NonNegativeInteger} offsetA - starting index for `A`
* @param {Float64Array} x - input vector
* @param {integer} strideX - `x` stride length
* @param {NonNegativeInteger} offsetX - starting index for `x`
* @returns {Float64Array} `x`
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] );
* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
*
* dtbmv( 'upper', 'no-transpose', 'unit', 3, 1, A, 2, 1, 0, x, 1, 0 );
* // x => <Float64Array>[ 3.0, 11.0, 3.0 ]
*/
function dtbmv( uplo, trans, diag, N, K, A, strideA1, strideA2, offsetA, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len
var nonunit;
var isrm;
var idx;
var tmp;
var sa0;
var sa1;
var ix0;
var ix1;
var i0;
var i1;
var oa;
var ox;

// Note on variable naming convention: sa#, ix#, i# where # corresponds to the loop number, with `0` being the innermost loop...

isrm = isRowMajor( [ strideA1, strideA2 ] );
nonunit = ( diag === 'non-unit' );

if ( isrm ) {
// For row-major matrices, the last dimension has the fastest changing index...
sa0 = strideA2; // stride for innermost loop
sa1 = strideA1; // stride for outermost loop
} else { // isColMajor
// For column-major matrices, the first dimension has the fastest changing index...
sa0 = strideA1; // stride for innermost loop
sa1 = strideA2; // stride for outermost loop
}
ox = offsetX;
if (
( !isrm && trans === 'no-transpose' && uplo === 'upper' ) ||
( isrm && trans !== 'no-transpose' && uplo === 'lower' )
) {
ix1 = ox;
for ( i1 = 0; i1 < N; i1++ ) {
oa = offsetA + ( sa1 * i1 );
tmp = x[ ix1 ];
if ( nonunit ) {
tmp = A[ oa + ( sa0 * K ) ] * x[ ix1 ];
}
for ( i0 = i1 + 1; i0 <= min( N - 1, i1 + K ); i0++ ) {
ix0 = ox + ( i0 * strideX );
idx = oa + ( sa0 * ( K + i0 - i1 ) );
tmp += A[ idx ] * x[ ix0 ];
}
x[ ix1 ] = tmp;
ix1 += strideX;
}
return x;
}
if (
( !isrm && trans === 'no-transpose' && uplo === 'lower' ) ||
( isrm && trans !== 'no-transpose' && uplo === 'upper' )
) {
ix1 = ox + ( (N - 1) * strideX );
for ( i1 = N - 1; i1 >= 0; i1-- ) {
oa = offsetA;
tmp = x[ ix1 ];
if ( nonunit ) {
tmp = A[ oa + ( sa1 * i1 ) ] * x[ ix1 ];
}
for ( i0 = max( 0, i1 - K ); i0 < i1; i0++ ) {
idx = oa + ( sa1 * i0 ) + ( sa0 * ( i1 - i0 ) );
ix0 = ox + ( i0 * strideX );
tmp += A[ idx ] * x[ ix0 ];
}
x[ ix1 ] = tmp;
ix1 -= strideX;
}
return x;
}
if (
( !isrm && trans !== 'no-transpose' && uplo === 'upper' ) ||
( isrm && trans === 'no-transpose' && uplo === 'lower' )
) {
ix1 = x + ( ( N - 1 ) * strideX );
for ( i1 = N - 1; i1 >= 0; i1-- ) {
oa = offsetA + ( sa1 * i1 );
tmp = x[ ix1 ];
if ( nonunit ) {
tmp = A[ oa + ( sa0 * K ) ] * x[ ix1 ];
}
for ( i0 = max( 0, i1 - K ); i0 < i1; i0++ ) {
idx = oa + ( sa0 * ( K + i0 - i1 ) );
ix0 = ox + ( i0 * strideX );
tmp += A[ idx ] * x[ ix0 ];
}
x[ ix1 ] = tmp;
ix1 -= strideX;
}
return x;
}
// ( !isrm && trans !== 'no-transpose' && uplo === 'lower' ) || ( isrm && trans === 'no-transpose' && uplo === 'upper' )

Check warning on line 149 in lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"

Check warning on line 149 in lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "isrm"

Check warning on line 149 in lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "uplo"

Check warning on line 149 in lib/node_modules/@stdlib/blas/base/dtbmv/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "isrm"
ix1 = ox;
for ( i1 = 0; i1 < N; i1++ ) {
oa = offsetA + ( sa1 * i1 );
tmp = x[ ix1 ];
if ( nonunit ) {
tmp = A[ oa ] * x[ ix1 ];
}
for ( i0 = i1 + 1; i0 <= min( N - 1, i1 + K ); i0++ ) {
ix0 = ox + ( i0 * strideX );
idx = oa + ( sa0 * ( i0 - i1 ) );
tmp += A[ idx ] * x[ ix0 ];
}
x[ ix1 ] = tmp;
ix1 += strideX;
}
return x;
}


// EXPORTS //

module.exports = dtbmv;
Loading