Skip to content

Commit 5dce265

Browse files
Tor FjeldeTor Fjelde
authored andcommitted
added dimensionality check of the provided S matrix
1 parent 7405a19 commit 5dce265

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/RobustAdaptiveMetropolis.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ function AbstractMCMC.step(
194194
convert(AbstractVector{T}, initial_params)
195195
end
196196
# Initialize the Cholesky factor of the covariance matrix.
197-
S = LinearAlgebra.LowerTriangular(
198-
sampler.S === nothing ? LinearAlgebra.diagm(0 => ones(T, d)) :
199-
convert(AbstractMatrix{T}, sampler.S),
200-
)
197+
S_data if sampler.S === nothing
198+
LinearAlgebra.diagm(0 => ones(T, d))
199+
else
200+
# Check the dimensionality of the provided `S`.
201+
if size(sampler.S) != (d, d)
202+
throw(ArgumentError("The provided `S` has the wrong dimensionality."))
203+
end
204+
convert(AbstractMatrix{T}, sampler.S)
205+
end
206+
S = LinearAlgebra.LowerTriangular(S_data)
201207

202208
# Construct the initial state.
203209
lp = LogDensityProblems.logdensity(f, x)

0 commit comments

Comments
 (0)