Skip to content

Commit 21fa91f

Browse files
committed
tidy up complex example
1 parent 0ee05fc commit 21fa91f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

example/linalg/example_schur_complex.f90

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ program example_schur_complex
33
use stdlib_linalg, only: schur
44
use stdlib_linalg_constants, only: dp
55
implicit none
6-
complex(dp), allocatable :: A(:,:), T(:,:), Z(:,:)
7-
integer :: n
6+
7+
integer, parameter :: n = 3
8+
complex(dp), dimension(n,n) :: A, T, Z
89

910
! Initialize a complex-valued square matrix
10-
n = 3
11-
allocate(A(n,n), T(n,n), Z(n,n))
12-
A = reshape([ &
13-
(1.0_dp, 2.0_dp), (3.0_dp, -1.0_dp), (4.0_dp, 1.0_dp), &
14-
(0.0_dp, -1.0_dp), (2.0_dp, 0.0_dp), (1.0_dp, -2.0_dp), &
15-
(2.0_dp, 3.0_dp), (1.0_dp, 1.0_dp), (0.0_dp, -1.0_dp) ], shape=[n,n])
11+
A = reshape([ (1, 2), (3,-1), (4, 1), &
12+
(0,-1), (2, 0), (1,-2), &
13+
(2, 3), (1, 1), (0,-1) ], shape=[n,n])
1614

1715
! Compute the Schur decomposition: A = Z T Z^H
1816
call schur(A, T, Z)
@@ -28,6 +26,5 @@ program example_schur_complex
2826
! Test factorization: Z*T*Z^H = A
2927
print *, "Max error in reconstruction:", maxval(abs(matmul(Z, matmul(T, conjg(transpose(Z)))) - A))
3028

31-
deallocate(A, T, Z)
3229
end program example_schur_complex
3330

0 commit comments

Comments
 (0)