Skip to content

Commit

Permalink
v1.5.0 using Diagonal matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cohensbw committed Nov 8, 2024
1 parent 0f744ae commit 817c894
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 259 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StableLinearAlgebra"
uuid = "7d06c537-f8ff-4c22-91e1-ce4088e3cfd7"
authors = ["Benjamin Cohen-Stead <[email protected]>"]
version = "1.4.2"
version = "1.5.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
7 changes: 0 additions & 7 deletions docs/src/developer_api.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Developer API

```@docs
StableLinearAlgebra.det_D
StableLinearAlgebra.mul_D!
StableLinearAlgebra.div_D!
StableLinearAlgebra.lmul_D!
StableLinearAlgebra.rmul_D!
StableLinearAlgebra.ldiv_D!
StableLinearAlgebra.rdiv_D!
StableLinearAlgebra.mul_P!
StableLinearAlgebra.inv_P!
StableLinearAlgebra.perm_sign
Expand Down
3 changes: 2 additions & 1 deletion src/LDR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ function ldr!(F::LDR, ws::LDRWorkspace{T}) where{T}
end

# calculate R = D⁻¹⋅R
ldiv_D!(d, M)
D = Diagonal(d)
ldiv!(D, M)

# calculate R⋅Pᵀ
mul_P!(R, M, qr_ws.jpvt)
Expand Down
162 changes: 0 additions & 162 deletions src/developer_functions.jl
Original file line number Diff line number Diff line change
@@ -1,165 +1,3 @@
@doc raw"""
det_D(d::AbstractVector{T}) where {T}
Given a diagonal matrix ``D`` represented by the vector `d`,
return ``\textrm{sign}(\det D)`` and ``\log(|\det A|).``
"""
function det_D(d::AbstractVector{T}) where {T}

logdetD = zero(real(T))
sgndetD = oneunit(T)
for i in eachindex(d)
logdetD += log(abs(d[i]))
sgndetD *= sign(d[i])
end

return logdetD, sgndetD
end

@doc raw"""
mul_D!(A, d, B)
Calculate the matrix product ``A = D \cdot B,`` where ``D`` is a diagonal matrix
represented by the vector `d`.
"""
function mul_D!(A::AbstractMatrix, d::AbstractVector, B::AbstractMatrix)

@inbounds @fastmath for c in axes(B,2)
for r in eachindex(d)
A[r,c] = d[r] * B[r,c]
end
end

return nothing
end


@doc raw"""
mul_D!(A, B, d)
Calculate the matrix product ``A = B \cdot D,`` where ``D`` is a diagonal matrix
represented by the vector `d`.
"""
function mul_D!(A::AbstractMatrix, B::AbstractMatrix, d::AbstractVector)

@inbounds @fastmath for c in eachindex(d)
for r in axes(A,1)
A[r,c] = B[r,c] * d[c]
end
end

return nothing
end


@doc raw"""
div_D!(A, d, B)
Calculate the matrix product ``A = D^{-1} \cdot B,`` where ``D`` is a diagonal matrix
represented by the vector `d`.
"""
function div_D!(A::AbstractMatrix, d::AbstractVector, B::AbstractMatrix)

@inbounds @fastmath for c in axes(B,2)
for r in eachindex(d)
A[r,c] = B[r,c] / d[r]
end
end

return nothing
end


@doc raw"""
div_D!(A, B, d)
Calculate the matrix product ``A = B \cdot D^{-1},`` where ``D`` is a diagonal matrix
represented by the vector `d`.
"""
function div_D!(A::AbstractMatrix, B::AbstractMatrix, d::AbstractVector)

@inbounds @fastmath for c in eachindex(d)
for r in axes(B,1)
A[r,c] = B[r,c] / d[c]
end
end

return nothing
end


@doc raw"""
lmul_D!(d, M)
In-place calculation of the matrix product ``M = D \cdot M,`` where ``D`` is a diagonal
matrix represented by the vector `d`.
"""
function lmul_D!(d::AbstractVector, M::AbstractMatrix)

@inbounds @fastmath for c in axes(M,2)
for r in eachindex(d)
M[r,c] *= d[r]
end
end

return nothing
end


@doc raw"""
rmul_D!(M, d)
In-place calculation of the matrix product ``M = M \cdot D,`` where ``D`` is a diagonal
matrix represented by the vector `d`.
"""
function rmul_D!(M::AbstractMatrix, d::AbstractVector)

@inbounds @fastmath for c in eachindex(d)
for r in axes(M,1)
M[r,c] *= d[c]
end
end

return nothing
end


@doc raw"""
ldiv_D!(d, M)
In-place calculation of the matrix product ``M = D^{-1} \cdot M,`` where ``D`` is a diagonal
matrix represented by the vector `d`.
"""
function ldiv_D!(d::AbstractVector, M::AbstractMatrix)

@inbounds @fastmath for c in axes(M,2)
for r in eachindex(d)
M[r,c] /= d[r]
end
end

return nothing
end


@doc raw"""
rdiv_D!(M, d)
In-place calculation of the matrix product ``M = M \cdot D^{-1},`` where ``D`` is a diagonal
matrix represented by the vector `d`.
"""
function rdiv_D!(M::AbstractMatrix, d::AbstractVector)

@inbounds @fastmath for c in eachindex(d)
for r in axes(M,1)
M[r,c] /= d[c]
end
end

return nothing
end


@doc raw"""
mul_P!(A, p, B)
Expand Down
Loading

2 comments on commit 817c894

@cohensbw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119009

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.5.0 -m "<description of version>" 817c894a8436fff264604f31c8d52519daa26b6d
git push origin v1.5.0

Please sign in to comment.