Skip to content

Commit 843ffb0

Browse files
authored
Merge pull request #1087 from Mahmood-Sinan/spmv_error_check_for_operator
Add validation for op argument in spmv routine for special matrices
2 parents 5ec54ea + 1b3e3fc commit 843ffb0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/specialmatrices/stdlib_specialmatrices_tridiagonal.fypp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ submodule (stdlib_specialmatrices) tridiagonal_matrices
163163
${t1}$ :: alpha_, beta_
164164
integer(ilp) :: n, nrhs, ldx, ldy
165165
character(1) :: op_
166+
167+
type(linalg_state_type) :: err0
166168
#:if t1.startswith('real')
167169
logical :: is_alpha_special, is_beta_special
168170
#:endif
@@ -171,10 +173,19 @@ submodule (stdlib_specialmatrices) tridiagonal_matrices
171173
${t1}$, pointer :: xmat(:, :), ymat(:, :)
172174
#:endif
173175

176+
if(present(op)) then
177+
if(.not.(op == "N" .or. op == "T" .or. op == "C" .or. op == "H")) then
178+
err0 = linalg_state_type(this, LINALG_VALUE_ERROR, "Invalid matrix operation; expected 'N', 'T', 'C' or 'H'.")
179+
call linalg_error_handling(err0)
180+
end if
181+
end if
182+
174183
! Deal with optional arguments.
175184
alpha_ = 1.0_${k1}$ ; if (present(alpha)) alpha_ = alpha
176185
beta_ = 0.0_${k1}$ ; if (present(beta)) beta_ = beta
177186
op_ = "N" ; if (present(op)) op_ = op
187+
if (op_ == "H") op_ = "C"
188+
178189
#:if t1.startswith('real')
179190
is_alpha_special = (alpha_ == 1.0_${k1}$ .or. alpha_ == 0.0_${k1}$ .or. alpha_ == -1.0_${k1}$)
180191
is_beta_special = (beta_ == 1.0_${k1}$ .or. beta_ == 0.0_${k1}$ .or. beta_ == -1.0_${k1}$)

0 commit comments

Comments
 (0)