SymLargestEigenval
This routine computes the largest eigenvalue of a csrmatrix.
Calling example
ans = SymLargestEigenVal(CSRMatrix_::mat [, char(2)::which, &
& INTEGER::NCV, INTEGER::maxIter, REAL::tol]) &
ans = SymLargestEigenVal(CSRMatrix_::mat, INTEGER::nev &
& [, char(2)::which, INTEGER::NCV, &
& INTEGER::maxIter, REAL::tol]) &
Interface
- ܀ SymLargestEigenVal(mat, which, NCV, maxIter, tol)
- ️܀ Example 1
- ️܀ Example 2
- ↢
INTERFACE
MODULE FUNCTION SymLargestEigenVal(mat, which, NCV, maxIter, tol) &
& RESULT(ans)
TYPE(CSRMatrix_), INTENT(IN) :: mat
!! dense matrix
CHARACTER(*), OPTIONAL, INTENT(IN) :: which
!! `which = "LM"` ⇨ absolute largest eigenvalue
!! `which = "LA"` ⇨ algebraic largest eigenvalue
!! default is "LA"
INTEGER(I4B), OPTIONAL, INTENT(IN) :: NCV
!! Number of Lanczos vectors generated
!! It must be greater than 1 and smaller than `size(mat,1)`
!! Default is `NCV = MIN(n, 20)`
INTEGER(I4B), OPTIONAL, INTENT(IN) :: maxIter
!! Maximum number of iteration default = `N*10`
REAL(DFP), OPTIONAL, INTENT(IN) :: tol
!! tolerance, default = 0.0
REAL(DFP) :: ans
!! maximum eigenvalue
END FUNCTION SymLargestEigenVal
END INTERFACE
program main
use easifemBase
implicit none
Declaring variables:
TYPE(CSRMatrix_) :: csrmat
CHARACTER(*), PARAMETER :: matrix_name = "./matrixMarket/fidap005.mtx"
REAL( DFP ), ALLOCATABLE :: rhs(:), sol(:), exact_sol(:)
INTEGER( I4B ) :: info
REAL( DFP ) :: ev1
Import csrmatrix from matrix market.
CALL IMPORT(csrmat, matrix_name, SPARSE_FMT_COO)
CALL Display(SIZE(csrmat, 1), "csrmat = ")
CALL Display(SIZE(csrmat, 2), "csrmat = ")
CALL Display(GetNNZ(csrmat), "GetNNZ = ")
Getting the largest eigenvalue.
ev1 = SymLargestEigenVal(mat=csrmat, which="LM")
CALL Display(ev1, "ev1 = ")
end program main
program main
use easifemBase
implicit none
Declaring variables:
TYPE(CSRMatrix_) :: csrmat
CHARACTER(*), PARAMETER :: matrix_name = "./matrixMarket/fidap005.mtx"
REAL( DFP ), ALLOCATABLE :: rhs(:), sol(:), exact_sol(:)
INTEGER( I4B ) :: info
REAL( DFP ) :: ev1
Import csrmatrix from matrix market.
CALL IMPORT(csrmat, matrix_name, SPARSE_FMT_COO)
CALL Display(SIZE(csrmat, 1), "csrmat = ")
CALL Display(SIZE(csrmat, 2), "csrmat = ")
CALL Display(GetNNZ(csrmat), "GetNNZ = ")
Getting the largest eigenvalue.
ev1 = SymLargestEigenVal(mat=csrmat, which="LA")
CALL Display(ev1, "ev1 = ")
end program main
- ܀ SymLargestEigenVal2(mat, nev, which, NCV, maxIter, tol)
- ️܀ Example 1
- ️܀ Example 2
- ↢
INTERFACE
MODULE FUNCTION SymLargestEigenVal2(mat, nev, which, NCV, maxIter, tol) &
& RESULT(ans)
TYPE(CSRMatrix_), INTENT(IN) :: mat
!! dense matrix
INTEGER(I4B), INTENT(IN) :: nev
!! number of eigenvalues requested
CHARACTER(*), OPTIONAL, INTENT(IN) :: which
!! `which = "LM"` ⇨ absolute largest eigenvalue
!! `which = "LA"` ⇨ algebraic largest eigenvalue
!! default is "LA"
INTEGER(I4B), OPTIONAL, INTENT(IN) :: NCV
!! Number of Lanczos vectors generated
!! It must be greater than 1 and smaller than `size(mat,1)`
!! Default is `NCV = MIN(n, MAX(2*nev+1, 20))`
INTEGER(I4B), OPTIONAL, INTENT(IN) :: maxIter
!! Maximum number of iteration default = `N*10`
REAL(DFP), OPTIONAL, INTENT(IN) :: tol
!! tolerance, default = 0.0
REAL(DFP) :: ans(nev)
!! first k, largest eigenvalue
END FUNCTION SymLargestEigenVal2
END INTERFACE
program main
use easifemBase
implicit none
Declaring variables:
TYPE(CSRMatrix_) :: csrmat
CHARACTER(*), PARAMETER :: matrix_name = "./matrixMarket/fidap005.mtx"
INTEGER( I4B ) :: info, nev
REAL( DFP ), ALLOCATABLE :: ev1(:)
Import csrmatrix from matrix market.
CALL IMPORT(csrmat, matrix_name, SPARSE_FMT_COO)
CALL Display(SIZE(csrmat, 1), "csrmat = ")
CALL Display(SIZE(csrmat, 2), "csrmat = ")
CALL Display(GetNNZ(csrmat), "GetNNZ = ")
Getting the largest eigenvalue.
nev = 6
ev1 = SymLargestEigenVal(mat=csrmat, which="LM", nev=nev)
CALL Display(ev1, "ev1 = ")
end program main
program main
use easifemBase
implicit none
Declaring variables:
TYPE(CSRMatrix_) :: csrmat
CHARACTER(*), PARAMETER :: matrix_name = "./matrixMarket/fidap005.mtx"
INTEGER( I4B ) :: info, nev
REAL( DFP ), ALLOCATABLE :: ev1(:)
Import csrmatrix from matrix market.
CALL IMPORT(csrmat, matrix_name, SPARSE_FMT_COO)
CALL Display(SIZE(csrmat, 1), "csrmat = ")
CALL Display(SIZE(csrmat, 2), "csrmat = ")
CALL Display(GetNNZ(csrmat), "GetNNZ = ")
Getting the largest eigenvalue.
nev = 6
ev1 = SymLargestEigenVal(mat=csrmat, which="LA", nev=nev)
CALL Display(ev1, "ev1 = ")
end program main