Skip to content

Commit d594573

Browse files
committed
tidy up schur real example
1 parent 7d8ca7d commit d594573

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

example/linalg/example_schur_real.f90

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

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

1714
! Compute the Schur decomposition: A = Z T Z^T
1815
call schur(A, T, Z)
@@ -28,6 +25,5 @@ program example_schur_real
2825
! Test factorization: Z*T*Z^T = A
2926
print *, "Max error in reconstruction:", maxval(abs(matmul(Z, matmul(T, transpose(Z))) - A))
3027

31-
deallocate(A, T, Z)
3228
end program example_schur_real
3329

0 commit comments

Comments
 (0)