Skip to content

Simplifying Metric types by using AbstractPDMat #34

@yebai

Description

@yebai

The following 3 types in src/metric.jl:

  • struct DiagEuclideanMetric{T<:Real,A<:AbstractVector{T}} <: AbstractMetric{T}
    dim :: Int
    # Diagnal of the inverse of the mass matrix
    M⁻¹ :: A
    # Sqare root of the inverse of the mass matrix
    sqrtM⁻¹ :: A
    # Pre-allocation for intermediate variables
    _temp :: A
    end

  • struct DenseEuclideanMetric{T<:Real,AV<:AbstractVector{T},AM<:AbstractMatrix{T}} <: AbstractMetric{T}
    dim :: Int
    # Inverse of the mass matrix
    M⁻¹ :: AM
    # U of the Cholesky decomposition of the mass matrix
    cholM⁻¹ :: UpperTriangular{T,AM}
    # Pre-allocation for intermediate variables
    _temp :: AV
    end

  • struct UnitEuclideanMetric{T<:Real} <: AbstractMetric{T}
    dim :: Int
    end

can be merged into one type using AbstractPDMat

struct EuclideanMetric{T<:Real,A<:AbstractPDMat{T}} <: AbstractMetric{T}
    M⁻¹     ::  A # contains dim, M⁻¹ and its Cholesky decomposition. 
    # Pre-allocation for intermediate variables
    _temp   ::  A
end

Reference: https://github.com/JuliaStats/PDMats.jl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions