1
1
program example_solve3
2
- use stdlib_linalg_constants, only: sp
2
+ use stdlib_linalg_constants, only: sp,ilp
3
3
use stdlib_linalg, only: solve_lu, linalg_state_type
4
4
implicit none
5
5
6
6
integer (ilp) :: test
7
+ integer (ilp), allocatable :: pivot(:)
7
8
complex (sp), allocatable :: A(:,:),b(:),x(:)
8
9
9
10
! Solve a system of 3 complex linear equations:
@@ -15,15 +16,16 @@ program example_solve3
15
16
A = transpose (reshape ([(2.0 , 0.0 ),(0.0 , 1.0 ),(2.0 ,0.0 ), &
16
17
(0.0 ,- 1.0 ),(4.0 ,- 3.0 ),(6.0 ,0.0 ), &
17
18
(4.0 , 0.0 ),(3.0 , 0.0 ),(1.0 ,0.0 )] , [3 ,3 ]))
18
- b = [(5.0 ,- 1.0 ),(0.0 ,1.0 ),(1.0 ,0.0 )]
19
19
20
20
! Pre-allocate x
21
- allocate (x,source= b)
21
+ allocate (b(size (A,2 )),pivot(size (A,2 )))
22
+ allocate (x,mold= b)
22
23
23
24
! Call system many times avoiding reallocation
24
25
do test= 1 ,100
25
- call solve_lu(A,b,x)
26
- print " (i2,'-th solution: ',*(1x,f12.6))" , test,x
26
+ b = test* [(5.0 ,- 1.0 ),(0.0 ,1.0 ),(1.0 ,0.0 )]
27
+ call solve_lu(A,b,x,pivot)
28
+ print " (i3,'-th solution: ',*(1x,f12.6))" , test,x
27
29
end do
28
30
29
31
end program example_solve3
0 commit comments