-
Notifications
You must be signed in to change notification settings - Fork 199
Fix(tridiagonal_matrices): spmv y vector overwrite and missing error check in impure init functions #1054
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
base: master
Are you sure you want to change the base?
Fix(tridiagonal_matrices): spmv y vector overwrite and missing error check in impure init functions #1054
Conversation
|
Thanks for spotting some things I completely missed. Could you also extend the tests to ensure that the cases with |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1054 +/- ##
=========================================
Coverage ? 25.13%
=========================================
Files ? 570
Lines ? 234201
Branches ? 41277
=========================================
Hits ? 58869
Misses ? 175332
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
As it is, we do not perform any check in @perazz, @jvdp1 and @jalvesz : What do you think? Should we modify the interface to be something like subroutine spmv(A, x, y, alpha, beta, op, err)where |
|
I guess we could add an optional error output argument to check for the admissibility of |
|
Well the thing is the underlying Hence, compared to the |
|
I saw the reason ... Have you tried to call these routines from OpenBLAS/MKL with values different than |
|
I've just tried with |
|
Thank you for the suggestions. I have made the changes. Please let me know if anything else needs adjustment. |
|
Thanks @Mahmood-Sinan for these fixes, LGTM! @loiseaujc I would propose that this PR is kept as is in terms of scope and then open 2 different ones: pure subroutine stdlib_glagtm_sp( trans, n, nrhs, alpha, dl, d, du, x, ldx, beta,b, ldb )
!! GLAGTM performs a matrix-vector product of the form
!! B := alpha * A * X + beta * B
!! where A is a tridiagonal matrix of order N, B and X are N by NRHS
!! matrices, and alpha and beta are real scalars
use stdlib_blas_constants_sp, only: negone, zero, half, one, two, three, four, eight, ten, czero, chalf, cone, cnegone
! Scalar Arguments
integer, parameter :: ilp = int32
integer, parameter :: wp = sp
character, intent(in) :: trans
integer(ilp), intent(in) :: ldb, ldx, n, nrhs
real(wp), intent(in) :: alpha, beta
! Array Arguments
real(wp), intent(inout) :: b(ldb,*)
real(wp), intent(in) :: d(*), dl(*), du(*), x(ldx,*)
! =====================================================================
! Local Scalars
integer(ilp) :: i, j
real(wp) :: temp
! Executable Statements
if( n==0 )return
! multiply b by beta if beta/=0
if( beta==zero ) then
b(1:n,1:nrhs) = zero
else
b(1:n,1:nrhs) = beta * b(1:n,1:nrhs)
end if
if( trans(1:1) == 'N' ) then
! compute b := b + alpha * a*x
do j = 1, nrhs
if( n==1_ilp ) then
temp = d( 1_ilp )*x( 1_ilp, j )
b( 1_ilp, j ) = b( 1_ilp, j ) + alpha*temp
else
temp = d( 1_ilp )*x( 1_ilp, j ) + du( 1_ilp )*x( 2_ilp, j )
b( 1_ilp, j ) = b( 1_ilp, j ) + alpha*temp
do i = 2, n - 1
temp = dl( i-1 )*x( i-1, j ) + d( i )*x( i, j ) + du( i )*x( i+1, j )
b( i, j ) = b( i, j ) + alpha*temp
end do
temp = dl( n-1 )*x( n-1, j ) + d( n )*x( n, j )
b( n, j ) = b( n, j ) + alpha*temp
end if
end do
else
! compute b := b + alpha * a**t*x
do j = 1, nrhs
if( n==1_ilp ) then
temp = d( 1_ilp )*x( 1_ilp, j )
b( 1_ilp, j ) = b( 1_ilp, j ) + alpha*temp
else
temp = d( 1_ilp )*x( 1_ilp, j ) + dl( 1_ilp )*x( 2_ilp, j )
b( 1_ilp, j ) = b( 1_ilp, j ) + alpha*temp
do i = 2, n - 1
temp = du( i-1 )*x( i-1, j ) + d( i )*x( i, j ) + dl( i )*x( i+1, j )
b( i, j ) = b( i, j ) + alpha*temp
end do
temp = du( n-1 )*x( n-1, j ) + d( n )*x( n, j )
b( n, j ) = b( n, j ) + alpha*temp
end if
end do
end if
return
end subroutine stdlib_glagtm_sp |
|
All good for me. @Mahmood-Sinan: do you want to take the lead with the generalized |
|
Thanks for approving. And @loiseaujc Yes, I’d be happy to work on the generalized LAGTM extension. I’ll likely need some help or pointers as I go. |
Summary:
This pr fixes two issues within tridiagonal_matrices module.
tridiagonal_matrices, the matrix fields were assigned even if there was an error(for example, when the sizes of du and dl vectors differed from dv by more than one).Changes:
if (err0%ok())check in the impure initialization functions.y = 0.0_${k1}$in the spmv subroutine.