MatrixUtils Module file:Matrix_utils_new

Classes

Dependencies

Subroutines Expand Arguments

  • Matrix_CCholesky(M)

    M = L L^\dag

    • complex(dm) intent(inout) :: M(:,:)
  • Matrix_CCholeskyRootInverse(M, dagger)

    M = L L^\dag and return L^{-1} in M ( or [L^(-1}]^\dag )

    • complex(dm) intent(inout) :: M(:,:)
    • logical intent(in), optional :: dagger
  • Matrix_CDiagonalize(n, diag)

    Complex version. Does m = U diag U^dag, returning U in M

    • integer intent(in) :: n
    • real(dm) intent(out) :: diag(n)
  • Matrix_CDiagonalize_Partial(n, diag, emin, emax, nfound)

    Complex version. Does m = U diag U^dag, returning U in M Assumes up to nfound values will be found. nfound set to true value on exit

    • integer intent(in) :: n
    • real(dm) intent(out) :: diag(:)
    • real(dm) intent(in) :: emin
    • real(dm) intent(in) :: emax
    • integer intent(inout) :: nfound
  • Matrix_Cholesky(M, err, zeroed)

    Note upper triangular is not zeroed

    • real(dm) intent(inout) :: M(:,:)
    • integer optional :: err
    • logical intent(in), optional :: zeroed
  • Matrix_CholeskyRootInverse(M, transpose, error)

    M = L L^T and return L^{-1} in M ( or [L^(-1}]^T )

    • real(dm) intent(inout) :: M(:,:)
    • logical intent(in), optional :: transpose
    • integer intent(out), optional :: error
  • Matrix_CMult(Mat, U, Out, a, b)

    Out = a*Mat U + b*out

    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • complex(dm) intent(in), optional :: a
    • complex(dm) intent(in), optional :: b
  • Matrix_CMult_NT(Mat, U, Out, a, b)

    Out = a*Mat U^dag + b*out

    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • complex(dm) intent(in), optional :: a
    • complex(dm) intent(in), optional :: b
  • Matrix_CMult_SymmLeft(Mat, U, Out, a, b)
    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • complex(dm) intent(in), optional :: a
    • complex(dm) intent(in), optional :: b
  • Matrix_CMult_SymmRight(Mat, U, Out, a, b)
    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • complex(dm) intent(in), optional :: a
    • complex(dm) intent(in), optional :: b
  • Matrix_CMult_TN(Mat, U, Out, a, b)

    Out = a*Mat^dag U + b*Out

    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • complex(dm) intent(in), optional :: a
    • complex(dm) intent(in), optional :: b
  • Matrix_CMultGen(m, k, n, Mat, U, Out)

    out(1:m,1:n) = MatMul(Mat(1:m,1:k),U(1:k,1:n))

    • integer intent(in) :: m
    • integer intent(in) :: k
    • integer intent(in) :: n
    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
  • Matrix_CRotateSymm(m, Mat, U, Out, triangular)

    Gets U^dag Mat U

    • integer intent(in) :: m
    • complex(dm) intent(in) :: Mat(:,:)
    • complex(dm) intent(in) :: U(:,:)
    • complex(dm)  :: Out(:,:)
    • logical intent(in), optional :: triangular
  • Matrix_CSVD_AllVT(m, n, Mat, VT, D)

    n>m Do singular value decomposition of m x n matrix Mat Mat = U D V^dag returns all nxn V^dag in VT, vector D of diagonal elements of

    • integer intent(in) :: m
    • integer intent(in) :: n
    • complex(dm) intent(inout) :: Mat(m,n)
    • complex(dm) intent(out) :: VT(n,n)
    • real(dm) intent(out) :: D(m)
  • Matrix_CSVD_U(m, n, Mat, VT, D)

    Do singular value decomposition of m x n matrix Mat Mat = U D VT returns U in Mat, vector D of diagonal elements of, unitary matrix V

    • integer intent(in) :: m
    • integer intent(in) :: n
    • complex(dm) intent(inout) :: Mat(m,n)
    • complex(dm) intent(out),optional :: VT(n,n)
    • real(dm) intent(out) :: D(*)
  • Matrix_CSVD_VT(m, n, Mat, U, D)

    Do singular value decomposition of m x n matrix Mat Mat = U D V^dag returns V^dag in Mat, vector D of diagonal elements of, unitary matrix U

    • integer intent(in) :: m
    • integer intent(in) :: n
    • complex(dm) intent(inout) :: Mat(m,n)
    • complex(dm) intent(out),optional :: U(m,m)
    • real(dm) intent(out) :: D(*)
  • Matrix_Diagonalize(n, diag)

    Does m = U diag U^T, returning U in M

    • integer intent(in) :: n
    • real(dm) intent(out) :: diag(n)
  • Matrix_Diagonalize_DC(n, diag)

    Complex version. Does m = U diag U^dag, returning U in M

    • integer intent(in) :: n
    • real(dm) intent(out) :: diag(n)
  • Matrix_Diagonalize_Partial(n, diag, emin, emax, nfound)

    Real version. Does m = U diag U^dag, returning U in M Assumes up to nfound values will be found. nfound set to true value on exit

    • integer intent(in) :: n
    • real(dm) intent(out) :: diag(:)
    • real(dm) intent(in) :: emin
    • real(dm) intent(in) :: emax
    • integer intent(inout) :: nfound
  • Matrix_DiagPreMul(M, D)

    M -> matmul(diag(D),M)

    • real(dm) intent(inout) :: M(:,:)
    • real(dm) intent(in) :: D(:)
  • Matrix_end(Name)
    • character(LEN=*) intent(in) :: Name
  • Matrix_Inverse(M)

    Inverse of symmetric positive definite matrix

    • real(dm) intent(inout) :: M(:,:)
  • Matrix_inverse_chol(M, err)

    Inverse of symmetric matrix This should not be used in real situations, but useful for quick testing

    • real(dm) intent(inout) :: M(:,:)
    • integer optional :: err
  • Matrix_InverseArrayMPI(nmat, Arr)

    Invert array of matrices by sending each to separate CPU

  • Matrix_InverseAsymm(M)

    This should not be used in real situations, but useful for quick testing

    • real(dm) intent(inout) :: M(:,:)
  • Matrix_Mult(Mat, U, Out, a, b)

    Out = a*Mat U + b*out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_Mult_NT(Mat, U, Out, a, b)

    Out = a*Mat U^T + b*out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_Mult_SymmLeft(Mat, U, Out, a, b)
    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_Mult_SymmRight(Mat, U, Out, a, b)

    Out = a*Mat U + b*out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_Mult_TN(Mat, U, Out, a, b)

    Out = a*Mat^dag U + b*Out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_MultGen(m, k, n, Mat, U, Out)

    out(1:m,1:n) = MatMul(Mat(1:m,1:k),U(1:k,1:n))

    • integer intent(in) :: m
    • integer intent(in) :: k
    • integer intent(in) :: n
    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
  • Matrix_MultSq_RepRight(Mat, U, a)

    U = a*Mat*U

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(inout) :: U(:,:)
    • real(dm) intent(in), optional :: a
  • Matrix_MultTri(Mat, L, side)

    Mat -> L Mat or Mat L where L is lower triangular

    • real(dm) intent(inout) :: Mat(:,:)
    • real(dm) intent(in) :: L(:,:)
    • character(LEN=*) intent(in) :: side
  • Matrix_MulVec(Mat, vec, Out, a, b)

    Out = a*Mat*vec + b*out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm)  :: vec(:)
    • real(dm)  :: Out(:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_MulVecSingle(Mat, vec, Out, a, b)

    Out = a*Mat*vec + b*out

    • real intent(in) :: Mat(:,:)
    • real  :: vec(:)
    • real  :: Out(:)
    • real intent(in), optional :: a
    • real intent(in), optional :: b
  • Matrix_MulVecSymm(Mat, vec, Out, a, b)

    Out = a*Mat*vec + b*out

    • real(dm) intent(in) :: Mat(:,:)
    • real(dm)  :: vec(:)
    • real(dm)  :: Out(:)
    • real(dm) intent(in), optional :: a
    • real(dm) intent(in), optional :: b
  • Matrix_MulVecSymmSingle(Mat, vec, Out, a, b)

    Out = a*Mat*vec + b*out

    • real intent(in) :: Mat(:,:)
    • real  :: vec(:)
    • real  :: Out(:)
    • real intent(in), optional :: a
    • real intent(in), optional :: b
  • Matrix_Read(aname, mat)
    • character(LEN=*) intent(IN) :: aname
    • real(dm) intent(out) :: mat(:,:)
  • Matrix_Read_Binary(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(out) :: mat(:,:)
  • Matrix_ReadSingle(aname, mat)
    • character(LEN=*) intent(IN) :: aname
    • real intent(out) :: mat(:,:)
  • Matrix_Root(n, M, pow)

    Does M**pow for symmetric M using U D**pow U^T Not optimized for large matrices

    • integer intent(in) :: n
    • real(dm) intent(inout) :: M(n,n)
    • real(dm) intent(in) :: pow
  • Matrix_RotateAntiSymm(m, Mat, U, Out)

    Gets U^T Mat U Where Mat = -Mat^T

    • integer intent(in) :: m
    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
  • Matrix_RotateSymm(m, Mat, U, Out, triangular)

    Gets U^T Mat U If triangular U = Upper triangular (U^T lower triangular)

    • integer intent(in) :: m
    • real(dm) intent(in) :: Mat(:,:)
    • real(dm) intent(in) :: U(:,:)
    • real(dm)  :: Out(:,:)
    • logical intent(in), optional :: triangular
  • Matrix_SolveASymm(soln, M, a)
    • real(dm) intent(out) :: soln(:)
    • real(dm) intent(in) :: M(:,:)
    • real(dm) intent(in) :: a(:)
  • Matrix_SolveSymm(soln, M, a)
    • real(dm) intent(out) :: soln(:)
    • real(dm) intent(in) :: M(:,:)
    • real(dm) intent(in) :: a(:)
  • Matrix_start(Name)
    • character(LEN=*) intent(in) :: Name
  • Matrix_SVD(m, n, Mat, D, VT)

    Do singular value decomposition of m x n matrix Mat Mat = U D V^T returns U in Mat, vector D of diagonal elements of, orthogonal matrix VT= V^T

    • integer intent(in) :: m
    • integer intent(in) :: n
    • real(dm) intent(inout) :: Mat(m,n)
    • real(dm) intent(out) :: D(n)
    • real(dm) intent(out) :: VT(n,n)
  • Matrix_SVD_VT(m, n, Mat, U, D)

    Do singular value decomposition of m x n matrix Mat Mat = U D V^dag returns V^dag in Mat, vector D of diagonal elements of, unitary matrix U

    • integer intent(in) :: m
    • integer intent(in) :: n
    • real(dm) intent(inout) :: Mat(m,n)
    • real(dm) intent(out),optional :: U(m,m)
    • real(dm) intent(out) :: D(*)
  • Matrix_Write(aname, commentline, mat, forcetable)
    • character(LEN=*) intent(in) :: aname
    • character(LEN=*) intent(in), optional :: commentline
    • real(dm) intent(in) :: mat(:,:)
    • logical intent(in), optional :: forcetable
  • Matrix_Write_Binary(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(in) :: mat(:,:)
  • Matrix_Write_double(aname, mat, forcetable)
    • character(LEN=*) intent(in) :: aname
    • double precision intent(in) :: mat(:,:)
    • logical intent(in), optional :: forcetable
  • Matrix_WriteFileRow(aunit, n, vec)
    • integer intent(in) :: aunit
    • integer intent(in) :: n
    • real(dm)  :: vec(n)
  • Matrix_WriteVec(aname, vec)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(in) :: vec(:)
  • MatrixSym_Read_Binary(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(out) :: mat(:,:)
  • MatrixSym_Read_Binary_Single(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real intent(out) :: mat(:,:)
  • MatrixSym_Write_Binary(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(in) :: mat(:,:)
  • MatrixSym_Write_Binary_Single(aname, mat)
    • character(LEN=*) intent(in) :: aname
    • real(dm) intent(in) :: mat(:,:)

    Functions  Expand Arguments

  • real GetMatrixTime()
  • integer ILAENV_wrap(i, a, b, c, d, S1, S2)
    • integer intent(in) :: i
    • integer intent(in) :: a
    • integer intent(in) :: b
    • integer intent(in) :: c
    • integer intent(in) :: d
    • character(LEN=*) intent(in) :: S1
    • character(LEN=*) intent(in) :: S2
  • complex(dm) Matrix_CTrace(M)
    • complex(dm) intent(in) :: M(:,:)
  • real(dm) Matrix_Diag(n, M)
    • integer intent(in) :: n
    • real(dm) intent(in) :: M(:,:)
  • real(dm) Matrix_GaussianLogLike(Cov, d)

    Returns -Log Likelihood for Gaussian: (d^T Cov^{-1} d + log|Cov|)/2 Cov is destroyed by the function** [replaced by choleksy lower triangular]

    • real(dm) intent(inout) :: Cov(:,:)
    • real(dm) intent(in) :: d(:)
  • double precision Matrix_GaussianLogLikeDouble(Cov, d)

    Returns -Log Likelihood for Gaussian: (d^T Cov^{-1} d + log|Cov|)/2 Cov is destroyed by the function** [replaced by choleksy lower triangular]

    • double precision intent(inout) :: Cov(:,:)
    • double precision intent(in) :: d(:)
  • real(dm) Matrix_QuadForm(vec, Mat)

    Get vec^T*Mat*vec where Mat is symmetric

    • real(dm)  :: vec(:)
    • real(dm)  :: Mat(:,:)
  • real(dm) Matrix_Trace(M)
    • real(dm) intent(in) :: M(:,:)
  • real(dm) Matrix_vecdot(vec1, vec2)
    • real(dm)  :: vec1(:)
    • real(dm)  :: vec2(:)
  • real Matrix_vecdotSingle(vec1, vec2)
    • real  :: vec1(:)
    • real  :: vec2(:)
  • real(dm) MatrixSym_LogDet(mat)
    • real(dm) intent(in) :: mat(:,:)