Refactor: lalg_adv module structure and use of X macro

Files:

  • lalg_adv_lapack_inc.F90:
  • lalg_adv.F90

Issues with the module:

  • File is very large.
    • Suggested splitting is given below
  • Many implementations are with ifdefs in the inc file, which defeats the purpose of an inc file
    • Should refactor to use X() macro
  • Several use Octopus-defined f90 interfaces, like lapack_getrf, which is just an interface to d/zgetrf, suggesting that there's zero need to be writing caller routines twice: for real and complex
    • Should refactor to a single routine, replacing real/complex with RTYPE as required
    • In some instances, an extra arg rwork is required - this needs some thought

Routines:

  • X(cholesky)
  • X(geneigensolve).
    • Generalised eigenvalue problem for symmetric/Hermitian
    • Wraps lapack_sygv/lapack_hegv
    • Implemented with ifdefs in an inc file
  • X(eigensolve_nonh)
    • Wraps lapack_geev
  • X(lowest_geneigensolve)
    • Wraps dsygvx/zhegvx
    • Implemented with ifdefs in an inc file
  • X(eigensolve)
    • Wraps lapack_syev/lapack_heev
    • Implemented with ifdefs in an inc file
  • X(lowest_eigensolve)
    • Computes the k lowest eigenvalues and the eigenvectors of a symmetric/Hermitian matrix
    • Wraps dsyevx/zheevx
    • Implemented with ifdefs in an inc file
  • X(determinant)
    • Wraps lapack_getrf
  • X(direct_inverse)
    • Wraps lapack_getri
  • X(matrix_norm2)
    • Norm of a 2D matrix
  • X(sym_inverse)
    • Invert a real/complex symmetric square matrix a
    • Wraps lapack_sytri
  • dlinsyssolve
    • Compute the solution to a real system of linear equations A*X = B,
    • Wraps X(gesvx)
  • zlinsyssolve
    • Compute the solution to a complex system of linear equations A*X = B,
    • Wraps X(gesvx) ... upon skimming, looks identical to dlinsyssolve
  • dsingular_value_decomp
    • Singular value decomposition, on real matrix
    • Wraps X(gesvd)
  • zsingular_value_decomp
    • Singular value decomposition, on complex matrix
    • Wraps X(gesvd)
  • dsvd_inverse
    • Pseudo-inverse on real matrix
  • zsvd_inverse
    • Pseudo-inverse on complex matrix
  • lalg_zpseudoinverse * Pseudo-inverse on complex matrix * Completely redundant, and should be replaced by zsvd_inverse or X(lalg_pseudo_inverse)
  • X(upper_triangular_inverse)
    • Calculate the inverse of a real/complex upper triangular matrix
    • Wraps X(trtri)
  • X(least_squares_vec)
    • No docs
    • Wraps lapack_gelss but differs in its use of rwork for complex
    • Implemented with ifdefs in an inc file
  • X(eigensolve_parallel)
    • Wrapper for scalapack/ELPA
    • Would benefit from splitting
  • X(inverse)
    • Interface to different inversion routines
  • X(lalg_matrix_function)

Group as:

New folder lapack_drivers/

  • decompositon.F90
    • dsingular_value_decomp
    • zsingular_value_decomp
    • X(cholesky)
    • X(lalg_matrix_function)
  • eigensolver.F90
    • X(geneigensolve).
    • X(eigensolve_nonh)
    • X(lowest_geneigensolve)
    • X(lowest_geneigensolve)
    • X(eigensolve)
    • X(lowest_eigensolve)
    • X(eigensolve_parallel)
  • inversion.F90
    • X(direct_inverse)
    • dsvd_inverse
    • zsvd_inverse
    • X(upper_triangular_inverse)
    • X(inverse)
  • matrix_properties.F90
    • X(determinant)
    • X(matrix_norm2)
  • linear_systems.F90
    • dlinsyssolve
    • zlinsyssolve
    • X(least_squares_vec)
Edited by Alex Buccheri