Skip to content

Commit

Permalink
added trigonometric functions for poles
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Mar 4, 2020
1 parent f6a3abc commit b61da52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ylm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ abstract type Pole <: Real end
struct NorthPole <: Pole end
struct SouthPole <: Pole end

Base.cos(::NorthPole) = one(Float64)
Base.cos(::SouthPole) = -one(Float64)
Base.sin(::Pole) = zero(Float64)

Base.one(::Type{<:Pole}) = one(Float64)

const ContiguousArrayLike{T,N} =
Union{Array{T,N}, Base.FastContiguousSubArray{T,N,<:Array{T}}}

Expand Down
15 changes: 15 additions & 0 deletions test/test_ylm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ println()
end # @testset

@testset "Pole" begin
@testset "one" begin
@test one(NorthPole()) == 1
@test one(SouthPole()) == 1
end
@testset "North pole" begin
@testset "Plm" begin
@test compute_p(10,1) compute_p(10,NorthPole())
Expand All @@ -43,6 +47,12 @@ end # @testset
@test compute_y(10,1,0) compute_y(10,NorthPole())
@test compute_y(10,1,0) compute_y(10,NorthPole(),π/2)
end
@testset "trignometric functions" begin
@test cos(NorthPole()) == 1
@test sec(NorthPole()) == 1
@test sin(NorthPole()) == 0
end

end
@testset "south pole" begin
@testset "Plm" begin
Expand All @@ -52,5 +62,10 @@ end # @testset
@test compute_y(10,-1,0) compute_y(10,SouthPole())
@test compute_y(10,-1,0) compute_y(10,SouthPole(),π/2)
end
@testset "trignometric functions" begin
@test cos(SouthPole()) == -1
@test sec(SouthPole()) == -1
@test sin(SouthPole()) == 0
end
end
end

0 comments on commit b61da52

Please sign in to comment.