stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

feat: Add generalized lagtm routine supporting arbitrary values for alpha and beta

Open Mahmood-Sinan opened this issue 1 month ago • 1 comments

This PR adds a generalized lagtm routine that supports arbitrary values of alpha and beta for the operation:

y = alpha * A * x + beta * y

where A is a tridiagonal matrix. The existing LAPACK lagtm restricts alpha and beta to the set { -1, 0, 1 }, which limits its applicability in several higher-level routines. The routine can be called as follows:

glagtm(trans, n, nrhs, alpha, dl, d, du, x, ldx, beta, b, ldb)

which is similar to the LAPACK version:

lagtm( trans, n, nrhs, alpha, dl, d, du, x, ldx, beta,b, ldb )

except that alpha and beta can be arbitrary(including complex values).

This new subroutine is placed inside src/lapack_extended/stdlib_extended_lapack_base.fypp (interface) and src/lapack_extended/stdlib_extended_lapack.fypp (implementation).

Mahmood-Sinan avatar Dec 09 '25 05:12 Mahmood-Sinan

Codecov Report

:x: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 68.57%. Comparing base (34723c7) to head (21a5435).

Files with missing lines Patch % Lines
...ecialmatrices/example_specialmatrices_cdp_spmv.f90 0.00% 17 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1068      +/-   ##
==========================================
- Coverage   68.69%   68.57%   -0.13%     
==========================================
  Files         392      393       +1     
  Lines       12693    12710      +17     
  Branches     1377     1377              
==========================================
- Hits         8720     8716       -4     
- Misses       3973     3994      +21     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 09 '25 05:12 codecov[bot]

Hi @Mahmood-Sinan, this looks pretty neat! the only thing I would suggest would be to keep the files and folders naming somewhat coherent with respect to the name lapack_extended.

jalvesz avatar Dec 10 '25 17:12 jalvesz

Hi @Mahmood-Sinan, this looks pretty neat! the only thing I would suggest would be to keep the files and folders naming somewhat coherent with respect to the name lapack_extended.

Sure, I will do that in the next commit.

Mahmood-Sinan avatar Dec 11 '25 05:12 Mahmood-Sinan

I also noticed that the documentation in doc/specs/stdlib_specialmatrices.md contains the following warning:

@warning
Due to limitations of the underlying `lapack` driver, currently `alpha` and `beta` can only take one of the values [-1, 0, 1] for `tridiagonal` and `symtridiagonal` matrices. See `lagtm` for more details.
@endwarning

Since the specialmatrices routines now call glagtm when alpha or beta take arbitrary values, this warning is no longer entirely accurate. Should I update this as well?

Mahmood-Sinan avatar Dec 11 '25 06:12 Mahmood-Sinan

I’ve applied the changes. Please let me know if anything else is needed.

Mahmood-Sinan avatar Dec 11 '25 08:12 Mahmood-Sinan