Skip to content

Commit

Permalink
Fix type promotion in jacobi_asy (#119)
Browse files Browse the repository at this point in the history
* add tests for missing promotion

* add missing type promotion for `jacobi_asy`

* bump version to v0.5.1
  • Loading branch information
hyrodium committed Apr 10, 2023
1 parent abb8e1f commit a593294
Show file tree
Hide file tree
Showing 3 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 = "FastGaussQuadrature"
uuid = "442a2c76-b920-505d-bb47-c5924d526838"
version = "0.5.0"
version = "0.5.1"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
3 changes: 2 additions & 1 deletion src/gaussjacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ end

# Convenience function: convert any kind of numbers a and b to a joint floating point type
jacobi_rec(n::Integer, α::Real, β::Real) = jacobi_rec(n, promote(float(α), float(β))...)
jacobi_asy(n::Integer, α::Real, β::Real) = jacobi_asy(n, promote(float(α), float(β))...)

function jacobi_rec(n::Integer, α::T, β::T) where {T <: AbstractFloat}
#Compute nodes and weights using recurrrence relation.
Expand Down Expand Up @@ -172,7 +173,7 @@ function weightsConstant(n, α, β)
return 2^+ β + 1) * C
end

function jacobi_asy(n, α, β)
function jacobi_asy(n::Integer, α::Float64, β::Float64)
# ASY Compute nodes and weights using asymptotic formulae.

# Determine switch between interior and boundary regions:
Expand Down
6 changes: 6 additions & 0 deletions test/test_gaussjacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@
@test isa(x,Vector{Float64})
@test isa(w,Vector{Float64})
end
@testset "missing promotion with integers (#117)" begin
x1, w1 = gaussjacobi(500, 0, -1/2)
x2, w2 = gaussjacobi(500, 0.0, -1/2)
@test x1 == x2
@test w1 == w2
end

@testset "jacobi_rec against a precomputed rule in BigFloat" begin
x,w = FastGaussQuadrature.jacobi_rec(10, big(0), big(0))
Expand Down

2 comments on commit a593294

@hyrodium
Copy link
Collaborator 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/81304

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 v0.5.1 -m "<description of version>" a5932947c43186d1e13730015da705b5052012f5
git push origin v0.5.1

Please sign in to comment.