Skip to content

Commit f642f5d

Browse files
authored
rankUpdate! method for Diagonal + Dense (#446)
* add oxide dataset from nlme * add oxide to model cache * new rankupdate method + test * version bump
1 parent 52651b7 commit f642f5d

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

Artifacts.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
[TestData]
66
# compute this using
77
# using Tar, Inflate, SHA
8-
# filename = "download?version=4" # I just used wget for the URL below and this is how it saved it
8+
# filename = "download?version=5" # I just used wget for the URL below and this is how it saved it
99
# println("sha256: ", bytes2hex(open(sha256, filename)))
1010
# println("git-tree-sha1: ", Tar.tree_hash(IOBuffer(inflate_gzip(filename))))
1111
# from https://julialang.github.io/Pkg.jl/dev/artifacts/
12-
git-tree-sha1 = "75260d131b693f26e5834adf855f4c35d627348d"
12+
git-tree-sha1 = "91132469677f725c2e4097493ae8b1d566f90a3f"
1313
lazy = false
1414

1515
[[TestData.download]]
16-
# this is the SHA from https://osf.io/djaqb/download?version=4
17-
sha256 = "d179cadfb27fc638fd8a06b0d58f5f2916f786c5719ab22de93fedb6129726f4"
16+
# this is the SHA from https://osf.io/djaqb/download?version=5
17+
sha256 = "8040933246179d4b46cf37e4dd1076752102dfcb4bd937d5f12c0f724775e119"
1818
# when updating this, make sure to change to change the version number,
1919
# because if the version number isn't included, it will always point to the
2020
# latest version, which means it will break existing users when we update
2121
# between releases.
22-
url = "https://osf.io/djaqb/download?version=4"
22+
url = "https://osf.io/djaqb/download?version=5"
2323

2424
# for future work on using xz-compressed data:
2525
# Julia invokes wget without using HTTP metadata, so we need the link

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MixedModels"
22
uuid = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
33
author = ["Phillip Alday <[email protected]>", "Douglas Bates <[email protected]>", "Jose Bayoan Santiago Calderon <[email protected]>"]
4-
version = "3.1.1"
4+
version = "3.1.2"
55

66
[deps]
77
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"

src/linalg/rankUpdate.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ function rankUpdate!(C::HermOrSym, A::BlockedSparse, α, β)
4949
rankUpdate!(C, sparse(A), α, β)
5050
end
5151

52+
function rankUpdate!(C::HermOrSym{T,Diagonal{T,Vector{T}}}, A::StridedMatrix{T}, α, β) where {T,S}
53+
Cdiag = C.data.diag
54+
@. Cdiag = β * Cdiag
55+
56+
for i in 1:length(Cdiag)
57+
Arow = view(A, i, :)
58+
Cdiag[i] = Cdiag[i] + α * Arow'Arow
59+
end
60+
61+
C
62+
end
63+
5264
function rankUpdate!(
5365
C::HermOrSym{T,Diagonal{T,Vector{T}}},
5466
A::SparseMatrixCSC{T},

test/modelcache.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using MixedModels: dataset
99
)
1010

1111
@isdefined(fms) || const global fms = Dict(
12+
:oxide => [@formula(Thickness ~ 1 + (1|Lot/Wafer))],
1213
:dyestuff => [@formula(yield ~ 1 + (1|batch))],
1314
:dyestuff2 => [@formula(yield ~ 1 + (1|batch))],
1415
:d3 => [@formula(y ~ 1 + u + (1+u|g) + (1+u|h) + (1+u|i))],

test/pls.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ end
407407
@test "-0.89" in tokens
408408
end
409409

410+
@testset "oxide" begin
411+
# this model has an interesting structure with two diagonal blocks
412+
m = only(models(:oxide))
413+
@test all(isapprox.(m.θ, [1.689182746, 2.98504262]; atol=1e-4))
414+
end
415+
410416
@testset "Rank deficient" begin
411417
rng = MersenneTwister(0);
412418
x = rand(rng, 100);

0 commit comments

Comments
 (0)