Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to FastCholesky.jl #354

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DomainIntegrals = "cc6bae93-f070-4015-88fd-838f9505a86c"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
FastCholesky = "2d5283b6-8564-42b6-bb00-83ed8e915756"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49"
Expand Down Expand Up @@ -44,6 +45,7 @@ DataStructures = "0.17, 0.18"
Distributions = "0.24, 0.25"
DomainIntegrals = "0.3.2, 0.4"
DomainSets = "0.5.2, 0.6"
FastCholesky = "1.3.0"
FastGaussQuadrature = "0.4, 0.5"
ForwardDiff = "0.10"
HCubature = "1.0.0"
Expand Down
3 changes: 1 addition & 2 deletions src/ReactiveMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module ReactiveMP

# List global dependencies here
using TinyHugeNumbers, MatrixCorrectionTools
using TinyHugeNumbers, MatrixCorrectionTools, FastCholesky, LinearAlgebra

import MatrixCorrectionTools: AbstractCorrectionStrategy, correction!

Expand All @@ -16,7 +16,6 @@ include("helpers/helpers.jl")
# This should be included before `distributions/*.jl`
include("score/counting.jl")

include("helpers/algebra/cholesky.jl")
include("helpers/algebra/companion_matrix.jl")
include("helpers/algebra/common.jl")
include("helpers/algebra/permutation_matrix.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/distributions/wishart_inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ end
function Distributions.rand!(rng::AbstractRNG, sampleable::InverseWishartMessage, x::AbstractVector{<:AbstractMatrix})
(df, S⁻¹) = Distributions.params(sampleable)
S = cholinv(S⁻¹)
L = Distributions.PDMats.chol_lower(ReactiveMP.fastcholesky(S))
L = Distributions.PDMats.chol_lower(fastcholesky(S))

# check
p = size(S, 1)
Expand Down Expand Up @@ -124,7 +124,7 @@ function Distributions.pdf!(out::AbstractArray{<:Real}, distribution::ReactiveMP
R = similar(T)
l = length(T)

M = ReactiveMP.fastcholesky!(T)
M = fastcholesky!(T)

# logc0 evaluation
h_df = df / 2
Expand All @@ -134,7 +134,7 @@ function Distributions.pdf!(out::AbstractArray{<:Real}, distribution::ReactiveMP
# logkernel evaluation
@inbounds for i in 1:length(out)
copyto!(T, 1, samples[i], 1, l)
C = ReactiveMP.fastcholesky!(T)
C = fastcholesky!(T)
ld = logdet(C)
LinearAlgebra.inv!(C)
mul!(R, Ψ, C.factors)
Expand Down
118 changes: 0 additions & 118 deletions src/helpers/algebra/cholesky.jl

This file was deleted.

60 changes: 0 additions & 60 deletions test/algebra/test_cholesky.jl

This file was deleted.

1 change: 1 addition & 0 deletions test/distributions/test_mv_normal_mean_covariance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test
using ReactiveMP
using LinearAlgebra
using Distributions
using FastCholesky

@testset "MvNormalMeanCovariance" begin
@testset "Constructor" begin
Expand Down
1 change: 1 addition & 0 deletions test/distributions/test_mv_normal_mean_precision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test
using ReactiveMP
using LinearAlgebra
using Distributions
using FastCholesky

@testset "MvNormalMeanPrecision" begin
@testset "Constructor" begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test
using ReactiveMP
using LinearAlgebra
using Distributions
using FastCholesky

@testset "MvNormalWeightedMeanPrecision" begin
@testset "Constructor" begin
Expand Down
1 change: 1 addition & 0 deletions test/distributions/test_pointmass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Distributions
using Random
using SpecialFunctions
using LinearAlgebra: UniformScaling, I
using FastCholesky

import ReactiveMP: CountingReal, tiny, huge
import ReactiveMP.MacroHelpers: @test_inferred
Expand Down
1 change: 1 addition & 0 deletions test/distributions/test_sample_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Distributions
using LinearAlgebra
using StaticArrays
using StableRNGs
using FastCholesky

import ReactiveMP: deep_eltype, get_samples, get_weights, sample_list_zero_element
import ReactiveMP: get_meta, is_meta_present, get_unnormalised_weights, get_entropy, get_logproposal, get_logintegrand
Expand Down
1 change: 1 addition & 0 deletions test/distributions/test_wishart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using ReactiveMP
using Distributions
using Random
using LinearAlgebra
using FastCholesky

import ReactiveMP: WishartMessage

Expand Down
1 change: 1 addition & 0 deletions test/distributions/test_wishart_inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using Distributions
using Random
using LinearAlgebra
using StableRNGs
using FastCholesky

import ReactiveMP: InverseWishartMessage
import Distributions: pdf!
Expand Down
1 change: 1 addition & 0 deletions test/rules/mv_normal_mean_precision/test_precision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module RulesMvNormalMeanPrecisionPrecisionTest
using Test
using ReactiveMP
using Random
using FastCholesky

import ReactiveMP: WishartMessage, @test_rules

Expand Down
1 change: 1 addition & 0 deletions test/rules/wishart/test_marginals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test
using ReactiveMP
using Random
using Distributions
using FastCholesky

import ReactiveMP: WishartMessage, @test_marginalrules

Expand Down
1 change: 1 addition & 0 deletions test/rules/wishart/test_out.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Test
using ReactiveMP
using Random
using Distributions
using FastCholesky

import ReactiveMP: WishartMessage, @test_rules

Expand Down
Loading