Skip to content

Commit 9d8710b

Browse files
committed
Changed comparison to account for floating point errors.
1 parent abb6904 commit 9d8710b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/stdlib_sparse_spmv.fypp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,9 @@ contains
620620
#:endif
621621

622622
! Deal with optional arguments.
623-
alpha_ = 1.0_${k1}$ ; if (present(alpha)) alpha_ = alpha
624-
beta_ = 0.0_${k1}$ ; if (present(beta)) beta_ = beta
625-
op_ = "N" ; if (present(op)) op_ = op
623+
alpha_ = 1.0_${k1}$ ; if (present(alpha)) alpha_ = alpha
624+
beta_ = 0.0_${k1}$ ; if (present(beta)) beta_ = beta
625+
op_ = sparse_op_none ; if (present(op)) op_ = op
626626

627627
! Prepare Lapack arguments.
628628
n = A%nrows ; ldx = n ; ldy = n ; y = 0.0_${k1}$

test/linalg/test_linalg_sparse.fypp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
module test_sparse_spmv
55
use testdrive, only : new_unittest, unittest_type, error_type, check, skip_test
66
use stdlib_kinds, only: sp, dp, xdp, qp, int8, int16, int32, int64
7+
use stdlib_linalg, only: hermitian
8+
use stdlib_math, only: all_close
79
use stdlib_sparse
810

911
implicit none
@@ -408,14 +410,22 @@ contains
408410

409411
! Test y = A @ x
410412
y1 = matmul(Amat, x) ; call spmv(A, x, y2)
411-
call check(error, all(y1 == y2))
413+
call check(error, all_close(y1, y2))
412414
if (allocated(error)) return
413415

414416
! Test y = A.T @ x
415417
y1 = 0.0_wp ; y2 = 0.0_wp
416418
y1 = matmul(transpose(Amat), x) ; call spmv(A, x, y2, op="T")
417-
call check(error, all(y1 == y2))
419+
call check(error, all_close(y1, y2))
418420
if (allocated(error)) return
421+
422+
#:if t1.startswith('complex')
423+
! Test y = A.H @ x
424+
y1 = 0.0_wp ; y2 = 0.0_wp
425+
y1 = matmul(hermitian(Amat), x) ; call spmv(A, x, y2, op="H")
426+
call check(error, all_close(y1, y2))
427+
if (allocated(error)) return
428+
#:endif
419429
end block
420430
#:endif
421431
#:endfor

0 commit comments

Comments
 (0)