Skip to content

Commit

Permalink
Merge pull request #37 from PieterjanRobbe/unstructured-mesh
Browse files Browse the repository at this point in the history
Fix for unstructured grids with Cholsky/Spectral
  • Loading branch information
PieterjanRobbe authored Sep 15, 2021
2 parents 9707e43 + 28202a7 commit e2aeeb6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GaussianRandomFields"
uuid = "e4b2fa32-6e09-5554-b718-106ed5adafe9"
version = "2.1.3"
version = "2.1.4"

[deps]
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
Expand Down
3 changes: 3 additions & 0 deletions src/covariance_functions/covariance_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ function apply(cov::CovarianceStructure, tx::NTuple{2,AbstractMatrix},
Symmetric(C, :U)
end

# evaluate for unstructured grids
apply(cov::CovarianceFunction{d}, x::AbstractMatrix{T}, y::AbstractMatrix{N}) where {d, T, N} = apply(cov.cov, (x,x), (x,x))

# evaluate for KL eigenfunctions
function apply(cov::CovarianceStructure, tx::NTuple{2,AbstractMatrix}, y::Tuple)
x = first(tx) # select FE nodes
Expand Down
2 changes: 1 addition & 1 deletion src/fem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function GaussianRandomField(mean::Vector{<:Real}, cov::CovarianceFunction{d}, m
size(pts, 2) == d || throw(DimensionMismatch("second dimension of points must be equal to $(d)"))
method isa CirculantEmbedding && throw(ArgumentError("cannot use circulant embedding with an unstructured grid"))

_GaussianRandomField(mean, cov, method, pts', Matrix{Int}(undef,0,0); kwargs...)
_GaussianRandomField(mean, cov, method, copy(pts'), Matrix{Int}(undef,0,0); kwargs...)
end

GaussianRandomField(cov::CovarianceFunction, method::GaussianRandomFieldGenerator,
Expand Down
4 changes: 4 additions & 0 deletions test/test_unstructured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@
grf = GaussianRandomField(cov, KarhunenLoeve(128), pts)
z = sample(grf)
@test isa(grf,GaussianRandomField{KarhunenLoeve{128}})
grf = GaussianRandomField(cov, Spectral(), pts)
@test isa(grf,GaussianRandomField{Spectral})
grf = GaussianRandomField(cov, Cholesky(), pts)
@test isa(grf,GaussianRandomField{Cholesky})

end

2 comments on commit e2aeeb6

@PieterjanRobbe
Copy link
Owner 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/44890

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 v2.1.4 -m "<description of version>" e2aeeb6f940fafdf0dfc327f2616c412022a3906
git push origin v2.1.4

Please sign in to comment.