Skip to content

Commit

Permalink
Update squarewave(x, θ) to throw DomainError.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paalon committed Mar 3, 2020
1 parent 9543acd commit d0c17de
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Waveforms.jl
Expand Up @@ -21,7 +21,10 @@ squarewave(x::Real) = ifelse(mod2pi(x) < π, 1.0, -1.0)
Compute ``2\pi``-periodic square wave of `x` with a duty cycle `θ`
and a peak amplitude ``1``.
"""
squarewave(x::Real, θ::Real) = ifelse(mod2pi(x) < 2π * θ, 1.0, -1.0)
function squarewave(x::Real, θ::Real)
0 θ 1 || throw(DomainError(θ, "squwarewave(x, θ) is only defined for 0 ≤ θ ≤ 1."))
ifelse(mod2pi(x) < 2π * θ, 1.0, -1.0)
end

@doc raw"""
squarewave1(x)
Expand Down

0 comments on commit d0c17de

Please sign in to comment.