Skip to content

Commit 7162489

Browse files
committed
use allocate for matrix elements, move call spmv to separate line
1 parent d8b2b7c commit 7162489

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/stdlib_specialmatrices_tridiagonal.fypp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ submodule (stdlib_specialmatrices) tridiagonal_matrices
6969
call linalg_error_handling(err0)
7070
endif
7171
! Matrix elements.
72-
A%dl = [(dl, i = 1, n-1)]
73-
A%dv = [(dv, i = 1, n)]
74-
A%du = [(du, i = 1, n-1)]
72+
allocate( A%dl(n-1), source = dl )
73+
allocate( A%dv(n), source= dv )
74+
allocate( A%du(n-1), source = du )
7575
end function
7676

7777
module function initialize_tridiagonal_impure_${s1}$(dl, dv, du, err) result(A)
@@ -135,9 +135,9 @@ submodule (stdlib_specialmatrices) tridiagonal_matrices
135135
! Description of the matrix.
136136
A%n = n
137137
! Matrix elements.
138-
A%dl = [(dl, i = 1, n-1)]
139-
A%dv = [(dv, i = 1, n)]
140-
A%du = [(du, i = 1, n-1)]
138+
allocate( A%dl(n-1), source = dl )
139+
allocate( A%dv(n), source= dv )
140+
allocate( A%du(n-1), source = du )
141141
endif
142142
end function
143143
#:endfor

test/linalg/test_linalg_specialmatrices.fypp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ contains
7676

7777
y1 = 0.0_wp
7878
call random_number(y2)
79-
y1 = alpha * matmul(Amat, x) + beta * y2 ; call spmv(A, x, y2, alpha=alpha, beta=beta)
79+
y1 = alpha * matmul(Amat, x) + beta * y2
80+
call spmv(A, x, y2, alpha=alpha, beta=beta)
8081
call check(error, all_close(y1, y2), .true.)
8182
if (allocated(error)) return
8283
end do

0 commit comments

Comments
 (0)