8000 feat: add `blas/base/strsm` by ShabiShett07 · Pull Request #7021 · stdlib-js/stdlib · GitHub
[go: up one dir, main page]

Skip to content

feat: add blas/base/strsm #7021

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 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
chore: add implementation
  • Loading branch information
ShabiShett07 committed May 18, 2025
commit bf45d08bd6ac75d38ca85bb89114b933920eb3b1
10 changes: 5 additions & 5 deletions lib/node_modules/@stdlib/blas/base/strsm/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface Routine {
* @param order - storage layout of `A` and `B`
* @param side - specifies whether `op( A )` appears on the left or right of `X`
* @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param diag - specifies whether or not `A` is unit triangular
* @param m - number of rows in `B`
* @param n - number of columns in `B`
Expand All @@ -52,14 +52,14 @@ interface Routine {
* strsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 );
* // B => <Float32Array>[ 30.0, 6.0, 0.0, 12.0 ]
*/
( order: Layout, side: OperationSide, uplo: MatrixTriangle, trans: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float32Array, LDA: number, B: Float32Array, LDB: number ): Float32Array;
( order: Layout, side: OperationSide, uplo: MatrixTriangle, transa: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float32Array, LDA: number, B: Float32Array, LDB: number ): Float32Array;

/**
* Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`.
*
* @param side - specifies whether `op( A )` appears on the left or right of `X`
* @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param diag - specifies whether or not `A` is unit triangular
* @param m - number of rows in `B`
* @param n - number of columns in `B`
Expand All @@ -83,7 +83,7 @@ interface Routine {
* strsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 );
* // B => <Float32Array>[ 0.0, 30.0, 6.0, 0.0, 12.0 ]
*/
ndarray( side: OperationSide, uplo: MatrixTriangle, trans: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number, B: Float32Array, strideB1: number, strideB2: number, offsetB: number ): Float32Array;
ndarray( side: OperationSide, uplo: MatrixTriangle, transa: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number, B: Float32Array, strideB1: number, strideB2: number, offsetB: number ): Float32Array;
}

/**
Expand All @@ -92,7 +92,7 @@ interface Routine {
* @param order - storage layout of `A` and `B`
* @param side - specifies whether `op( A )` appears on the left or right of `X`
* @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param diag - specifies whether or not `A` is unit triangular
* @param m - number of rows in `B`
* @param n - number of columns in `B`
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/strsm/lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
// MODULES //

var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );

Check failure on line 26 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Only one blank line is allowed


// FUNCTIONS

Check failure on line 29 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Header comment must end with two trailing slashes

/**
* Fills a matrix with zeros.
Expand Down Expand Up @@ -56,7 +56,7 @@
* zeros( 2, 3, X, 1, 2, 0 );
* // X => <Float32Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
*/
function zeros( M, N, X, strideX1, strideX2, offsetX ) { // TODO: consider moving to a separate package

Check warning on line 59 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: consider moving to a separate...'
var dx0;
var dx1;
var S0;
Expand Down Expand Up @@ -98,7 +98,7 @@
* @private
* @param {string} side - specifies whether `op( A )` appears on the left or right of `X`
* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param {string} trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} diag - specifies whether or not `A` is unit triangular
* @param {NonNegativeInteger} M - number of rows in `B`
* @param {NonNegativeInteger} N - number of columns in `B`
Expand All @@ -122,17 +122,17 @@
* strsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 );
* // B => <Float32Array>[ 30.0, 6.0, 0.0, 12.0 ]
*/
function strsm( side, uplo, trans, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-params
function strsm( side, uplo, transa, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-params
var nonunit;
var isrma;

Check failure on line 127 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var isrmb;

Check failure on line 128 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var tmp;
var oa2;
var ob2;
var sa0;

Check failure on line 132 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var sa1;

Check failure on line 133 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var sb0;

Check failure on line 134 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var sb1;

Check failure on line 135 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
var oa;
var ob;
var i;
Expand All @@ -141,8 +141,8 @@

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

isrma = isRowMajor( [ strideA1, strideA2 ] );

Check failure on line 144 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
isrmb = isRowMajor( [ strideB1, strideB2 ] );

Check failure on line 145 in lib/node_modules/@stdlib/blas/base/strsm/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 4 spaces
nonunit = ( diag === 'non-unit' );

if ( M === 0 || N === 0 ) {
Expand Down Expand Up @@ -172,7 +172,7 @@
return B;
}
if ( side === 'left' ) {
if ( trans === 'no-transpose' ) {
if ( transa === 'no-transpose' ) {
// B := alpha * inv( A ) * B
if ( uplo === 'upper' ) {
for ( j = 0; j < N; j++ ) {
Expand Down Expand Up @@ -258,7 +258,7 @@
return B;
}
// Right
if ( trans === 'no-transpose' ) {
if ( transa === 'no-transpose' ) {
if ( uplo === 'upper' ) {
for ( j = 0; j < N; j++ ) {
for ( i = 0; i < M; i++ ) {
Expand Down
18 changes: 11 additions & 7 deletions lib/node_modules/@stdlib/blas/base/strsm/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var base = require( './base.js' );
*
* @param {string} side - specifies whether `op( A )` appears on the left or right of `X`
* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param {string} trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} diag - specifies whether or not `A` is unit triangular
* @param {NonNegativeInteger} M - number of rows in `B`
* @param {NonNegativeInteger} N - number of columns in `B`
Expand All @@ -52,6 +52,10 @@ var base = require( './base.js' );
* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied.
* @throws {TypeError} third argument must specify correct transpose operation
* @throws {TypeError} fourth argument must specify whether the matrix is unit triangular or not
* @throws {RangeError} fifth argument must be a nonnegative integer
* @throws {RangeError} sixth argument must be a nonnegative integer
* @throws {RangeError} thirteenth argument must be non-zero
* @throws {RangeError} fourteenth argument must be non-zero
* @returns {Float32Array} `B`
*
* @example
Expand All @@ -63,15 +67,15 @@ var base = require( './base.js' );
* strsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 );
* // B => <Float32Array>[ 0.0, 30.0, 6.0, 0.0, 12.0 ]
*/
function strsm( side, uplo, trans, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params
function strsm( side, uplo, transa, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params
if ( !isOperationSide( side ) ) {
throw new TypeError( format( 'invalid argument. First argument must be a valid side. Value: `%s`.', side ) );
}
if ( !isMatrixTriangle( uplo ) ) {
throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) );
}
if ( !isTransposeOperation( trans ) ) {
throw new TypeError( format( 'invalid argument. Third argument must specify correct transpose operation. Value: `%s`.', trans ) );
if ( !isTransposeOperation( transa ) ) {
F438 throw new TypeError( format( 'invalid argument. Third argument must specify correct transpose operation. Value: `%s`.', transa ) );
}
if ( !isDiagonalType( diag ) ) {
throw new TypeError( format( 'invalid argument. Fourth argument must specify whether the matrix is unit triangular or not. Value: `%s`.', diag ) );
Expand All @@ -83,12 +87,12 @@ function strsm( side, uplo, trans, diag, M, N, alpha, A, strideA1, strideA2, off
throw new RangeError( format( 'invalid argument. Sixth argument must be a nonnegative integer. Value: `%d`.', N ) );
}
if ( strideB1 === 0 ) {
throw new RangeError( format( 'invalid argument. Seventeenth argument must be non-zero. Value: `%d`.', strideB1 ) );
throw new RangeError( format( 'invalid argument. Thirteenth argument must be non-zero. Value: `%d`.', strideB1 ) );
}
if ( strideB2 === 0 ) {
throw new RangeError( format( 'invalid argument. Eighteenth argument must be non-zero. Value: `%d`.', strideB2 ) );
throw new RangeError( format( 'invalid argument. Fourteenth argument must be non-zero. Value: `%d`.', strideB2 ) );
}
return base( side, uplo, trans, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len
return base( side, uplo, transa, diag, M, N, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len
}


Expand Down
18 changes: 11 additions & 7 deletions lib/node_modules/@stdlib/blas/base/strsm/lib/strsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var base = require( './base.js' );
* @param {string} order - storage layout of `A` and `B`
* @param {string} side - specifies whether `op( A )` appears on the left or right of `X`
* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied
* @param {string} trans - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication
* @param {string} diag - specifies whether or not `A` is unit triangular
* @param {NonNegativeInteger} M - number of rows in `B`
* @param {NonNegativeInteger} N - number of columns in `B`
Expand All @@ -53,6 +53,10 @@ var base = require( './base.js' );
* @throws {TypeError} third argument must specify whether the lower or upper triangular matrix is supplied
* @throws {TypeError} fourth argument must specify correct transpose operation
* @throws {TypeError} fifth argument must specify whether the matrix is unit triangular or not
* @throws {RangeError} sixth argument must be a nonnegative integer
* @throws {RangeError} seventh argument must be a nonnegative integer
* @throws {RangeError} tenth argument must be greater than or equal to max(1,M) when `A` is on left side and max(1,N) otherwise
* @throws {RangeError} twelfth argument must be greater than or equal to max(1,M)
* @returns {Float32Array} `B`
*
* @example
Expand All @@ -64,7 +68,7 @@ var base = require( './base.js' );
* strsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 );
* // B => <Float32Array>[ 30.0, 6.0, 0.0, 12.0 ]
*/
function strsm( order, side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ) { // eslint-disable-line max-params
function strsm( order, side, uplo, transa, diag, M, N, alpha, A, LDA, B, LDB ) { // eslint-disable-line max-params
var nrowsa;
var isrm;
var sa1;
Expand All @@ -80,8 +84,8 @@ function strsm( order, side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ) {
if ( !isMatrixTriangle( uplo ) ) {
throw new TypeError( format( 'invalid argument. Thirds argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) );
}
if ( !isTransposeOperation( trans ) ) {
throw new TypeError( format( 'invalid argument. Fourth argument must specify correct transpose operation. Value: `%s`.', trans ) );
if ( !isTransposeOperation( transa ) ) {
throw new TypeError( format( 'invalid argument. Fourth argument must specify correct transpose operation. Value: `%s`.', transa ) );
}
if ( !isDiagonalType( diag ) ) {
throw new TypeError( format( 'invalid argument. Fifth argument must specify whether the matrix is unit tr 98B1 iangular or not. Value: `%s`.', diag ) );
Expand All @@ -98,10 +102,10 @@ function strsm( order, side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ) {
nrowsa = N;
}
if ( LDA < max( 1, nrowsa ) ) {
throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', nrowsa, LDA ) );
throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', nrowsa, LDA ) );
}
if ( LDB < max( 1, M ) ) {
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDB ) );
throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDB ) );
}
isrm = isRowMajor( order );
if ( !isrm ) {
Expand All @@ -115,7 +119,7 @@ function strsm( order, side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ) {
sb1 = LDB;
sb2 = 1;
}
return base( side, uplo, trans, diag, M, N, alpha, A, sa1, sa2, 0, B, sb1, sb2, 0 ); // eslint-disable-line max-len
return base( side, uplo, transa, diag, M, N, alpha, A, sa1, sa2, 0, B, sb1, sb2, 0 ); // eslint-disable-line max-len
}


Expand Down
Loading
Loading
0