Skip to content

Commit 6830652

Browse files
committed
example cleanup
1 parent 870425b commit 6830652

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

example/linalg/example_eig_generalized.f90

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! Eigendecomposition of a real square matrix for the generalized eigenproblem
22
program example_eig_generalized
3-
use stdlib_linalg, only: eig
3+
use stdlib_linalg, only: eig, eye
44
implicit none
55

66
integer :: i
@@ -10,12 +10,10 @@ program example_eig_generalized
1010
! Matrices for the generalized eigenproblem: A * v = lambda * B * v
1111
! NB Fortran is column-major -> transpose input
1212
A = transpose(reshape([ [2, 2, 4], &
13-
[1, 3, 5], &
14-
[2, 3, 4] ], [3,3]))
13+
[1, 3, 5], &
14+
[2, 3, 4] ], [3,3]))
1515

16-
B = transpose(reshape([ [1, 0, 0], &
17-
[0, 1, 0], &
18-
[0, 0, 1] ], [3,3]))
16+
B = eye(3)
1917

2018
! Allocate eigenvalues and right eigenvectors
2119
allocate(lambda(3), vectors(3,3))

example/linalg/example_eigvals_generalized.f90

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
! Eigenvalues of a general real/complex matrix for the generalized eigenproblem
22
program example_eigvals_generalized
3-
use stdlib_linalg, only: eigvals
3+
use stdlib_linalg, only: eigvals, eye
44
implicit none
55

66
real, allocatable :: A(:,:), B(:,:), lambda(:)
77
complex, allocatable :: cA(:,:), cB(:,:), clambda(:)
88

99
! NB Fortran is column-major -> transpose input
1010
A = transpose(reshape([ [2, 8, 4], &
11-
[1, 3, 5], &
12-
[9, 5,-2] ], [3,3]))
11+
[1, 3, 5], &
12+
[9, 5,-2] ], [3,3]))
1313

14-
B = transpose(reshape([ [1, 0, 0], &
15-
[0, 1, 0], &
16-
[0, 0, 1] ], [3,3]))
14+
B = eye(3)
1715

1816
! Real generalized eigenproblem
1917
lambda = eigvals(A, B)

0 commit comments

Comments
 (0)