Skip to content

Commit

Permalink
added division by scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianAment committed Feb 1, 2022
1 parent 0d54810 commit 1832b24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.0"
julia_version = "1.7.1"
manifest_format = "2.0"

[[deps.Artifacts]]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WoodburyFactorizations"
uuid = "9f1bac23-581c-4ebc-bd36-df60d764636d"
authors = ["Sebastian Ament <sebastianeament@gmail.com>"]
version = "1.0.1"
version = "1.0.2"

[deps]
LazyInverses = "9f18896c-49a9-43cc-8eef-c455a8a119c6"
Expand Down
8 changes: 6 additions & 2 deletions src/WoodburyFactorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ end

######################## Linear Algebra primitives #############################
# IDEA: have efficient methods of hermitian WoodburyFactorization
Base.:*(a::Number, W::Woodbury) = Woodbury(a*W.A, W.U, a*W.C, W.V, W.α) # IDEA: could take over logabsdet efficiently
Base.:*(W::Woodbury, a::Number) = a*W
Base.:*(a::Number, W::Woodbury) = Woodbury(a * W.A, W.U, a * W.C, W.V, W.α) # IDEA: could take over logabsdet efficiently
Base.:*(W::Woodbury, a::Number) = a * W

Base.:\(a::Number, W::Woodbury) = W / a # IDEA: could take over logabsdet efficiently
Base.:/(W::Woodbury, a::Number) = Woodbury(W.A / a, W.U, W.C / a, W.V, W.α)


Base.:*(W::Woodbury, x::AbstractVecOrMat) = mul!(zero(x), W, x)
Base.:*(B::AbstractMatrix, W::Woodbury) = adjoint(W'*B')
Expand Down
5 changes: 4 additions & 1 deletion test/WoodburyFactorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ Base.AbstractMatrix(F::BunchKaufman) = Symmetric(Matrix(F))
@test Y B

@test α*W isa Woodbury
@test Matrix*W) α*Matrix(W) # with scalar
@test Matrix* W) α * Matrix(W) # with scalar
@test Matrix(W * α) Matrix(W) * α # with scalar
@test Matrix(W / α) Matrix(W) / α # with scalar
@test Matrix\ W) α \ Matrix(W) # with scalar
@test logdet(abs(α)*W) logdet(abs(α)*Matrix(W)) # checking that logdet works correctly

@test eltype(W) == Float64
Expand Down

0 comments on commit 1832b24

Please sign in to comment.