Skip to content

Commit

Permalink
Move the approach into the eigensolvers module
Browse files Browse the repository at this point in the history
  • Loading branch information
william-dawson committed Apr 18, 2024
1 parent 3062867 commit f5b45cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions Source/Fortran/EigenSolversModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ MODULE EigenSolversModule
USE PMatrixMemoryPoolModule, ONLY : MatrixMemoryPool_p, &
& DestructMatrixMemoryPool
USE PSMatrixAlgebraModule, ONLY : IncrementMatrix, MatrixMultiply, &
& ScaleMatrix
& ScaleMatrix, MatrixDiagonalScale
USE PSMatrixModule, ONLY : Matrix_ps, GatherMatrixToProcess, &
& FillMatrixFromTripletList, ConstructEmptyMatrix, ConvertMatrixToReal, &
& DestructMatrix, CopyMatrix, GetMatrixTripletList, TransposeMatrix, &
& DestructMatrix, CopyMatrix, GatherMatrixTripletList, TransposeMatrix, &
& ConjugateMatrix, FillMatrixIdentity, WriteMatrixToMatrixMarket
USE SolverParametersModule, ONLY : SolverParameters_t, PrintParameters, &
& DestructSolverParameters, ConstructSolverParameters, &
& CopySolverParameters
USE SMatrixModule, ONLY : Matrix_lsr, Matrix_lsc, MatrixToTripletList, &
& DestructMatrix
USE TripletListModule, ONLY : TripletList_r, TripletList_c, &
& ConstructTripletList, DestructTripletList
& ConstructTripletList, CopyTripletList, DestructTripletList
USE NTMPIModule
IMPLICIT NONE
PRIVATE
Expand Down Expand Up @@ -107,6 +107,7 @@ END FUNCTION func
!! Local Variables
TYPE(Matrix_ps) :: vecs, vecsT, vals, temp
TYPE(TripletList_r) :: tlist
TYPE(TripletList_c) :: tlist_c
INTEGER :: II

!! Optional Parameters
Expand All @@ -121,26 +122,29 @@ END FUNCTION func
& eigenvectors_in = vecs)

!! Convert to a triplet list, map the triplet list, fill.
CALL GetMatrixTripletList(vals, tlist)
CALL GatherMatrixTripletList(vals, tlist)
CALL DestructMatrix(vals)
DO II = 1, tlist%CurrentSize
tlist%DATA(II)%point_value = func(tlist%DATA(II)%point_value)
END DO

!! Fill
CALL ConstructEmptyMatrix(ResultMat, this)
CALL FillMatrixFromTripletList(ResultMat, tlist, preduplicated_in = .TRUE.)
CALL DestructTripletList(tlist)

!! Multiply Back Together
CALL MatrixMultiply(vecs, ResultMat, temp, threshold_in = params%threshold)
CALL TransposeMatrix(vecs, vecsT)
CALL DestructMatrix(vecs)
CALL ConjugateMatrix(vecsT)
CALL MatrixMultiply(temp, vecsT, ResultMat, threshold_in = params%threshold)
IF (this%is_complex) THEN
CALL CopyTripletList(tlist, tlist_c)
CALL MatrixDiagonalScale(vecs, tlist_c)
ELSE
CALL MatrixDiagonalScale(vecs, tlist)
END IF
CALL MatrixMultiply(vecs, vecsT, ResultMat, threshold_in = params%threshold)

!! Cleanup
CALL DestructMatrix(vecs)
CALL DestructMatrix(vecsT)
CALL DestructMatrix(temp)
CALL DestructTripletList(tlist)
CALL DestructTripletList(tlist_c)
CALL DestructSolverParameters(params)

END SUBROUTINE DenseMatrixFunction
Expand Down
2 changes: 1 addition & 1 deletion Source/Fortran/FermiOperatorModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ SUBROUTINE ComputeDenseFOE(H, ISQ, trace, K, inv_temp_in, &

!! Scale the eigenvectors
IF (vecs%is_complex) THEN
CALL CopyTripletList(tlist, tlist_c)
CALL CopyTripletList(tlist, tlist_c)
CALL MatrixDiagonalScale(vecs, tlist_c)
ELSE
CALL MatrixDiagonalScale(vecs, tlist)
Expand Down

0 comments on commit f5b45cc

Please sign in to comment.