Skip to content

Commit

Permalink
Replace broadcasted lambda with explicit loop (#738)
Browse files Browse the repository at this point in the history
* Replace broadcasted lambda with explicit loop

* version bump and NEWS

* NEWS xref
  • Loading branch information
palday authored Mar 5, 2024
1 parent ee5f2cf commit c1f9ca0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MixedModels v4.22.5 Release Notes
==============================
* Replace broadcasted lambda with explicit loop and use `one`. This may result in a small performance improvement. [#738]

MixedModels v4.22.4 Release Notes
==============================
* Switch to explicit imports from all included packages (i.e. replace `using Foo` by `using Foo: Foo, bar, baz`) [#748]
Expand Down Expand Up @@ -495,5 +499,6 @@ Package dependencies
[#715]: https://github.com/JuliaStats/MixedModels.jl/issues/715
[#717]: https://github.com/JuliaStats/MixedModels.jl/issues/717
[#733]: https://github.com/JuliaStats/MixedModels.jl/issues/733
[#738]: https://github.com/JuliaStats/MixedModels.jl/issues/738
[#744]: https://github.com/JuliaStats/MixedModels.jl/issues/744
[#748]: https://github.com/JuliaStats/MixedModels.jl/issues/748
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModels"
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
author = ["Phillip Alday <[email protected]>", "Douglas Bates <[email protected]>", "Jose Bayoan Santiago Calderon <[email protected]>"]
version = "4.22.4"
version = "4.22.5"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
9 changes: 6 additions & 3 deletions src/remat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ function copyscaleinflate! end

function copyscaleinflate!(Ljj::Diagonal{T}, Ajj::Diagonal{T}, Λj::ReMat{T,1}) where {T}
Ldiag, Adiag = Ljj.diag, Ajj.diag
broadcast!((x, λsqr) -> x * λsqr + one(T), Ldiag, Adiag, abs2(only(Λj.λ)))
lambsq = abs2(only(Λj.λ.data))
@inbounds for i in eachindex(Ldiag, Adiag)
Ldiag[i] = lambsq * Adiag[i] + one(T)
end
return Ljj
end

Expand Down Expand Up @@ -606,14 +609,14 @@ function copyscaleinflate!(
iszero(r) || throw(DimensionMismatch("size(Ljj, 1) is not a multiple of S"))
λ = Λj.λ
offset = 0
@inbounds for k in 1:q
@inbounds for _ in 1:q
inds = (offset + 1):(offset + S)
tmp = view(Ljj, inds, inds)
lmul!(adjoint(λ), rmul!(tmp, λ))
offset += S
end
for k in diagind(Ljj)
Ljj[k] += 1
Ljj[k] += one(T)
end
return Ljj
end
Expand Down

0 comments on commit c1f9ca0

Please sign in to comment.