Skip to content

Commit a47c525

Browse files
authored
Make StaticFloat64 <: Real (#87) (Fix #66)
1 parent a2d0b16 commit a47c525

File tree

4 files changed

+178
-122
lines changed

4 files changed

+178
-122
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Static"
22
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
33
authors = ["chriselrod", "ChrisRackauckas", "Tokazama"]
4-
version = "0.7.7"
4+
version = "0.7.8"
55

66
[deps]
77
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"

src/Static.jl

+57-119
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,29 @@ end
2424

2525
Base.Symbol(@nospecialize(s::StaticSymbol)) = known(s)
2626

27-
abstract type StaticNumber{N} <: Number end
27+
abstract type StaticInteger{N} <: Number end
2828

29-
abstract type StaticInteger{N} <: StaticNumber{N} end
29+
"""
30+
StaticBool(x::Bool) -> True/False
31+
32+
A statically typed `Bool`.
33+
"""
34+
abstract type StaticBool{bool} <: StaticInteger{bool} end
35+
36+
struct True <: StaticBool{true} end
37+
38+
struct False <: StaticBool{false} end
39+
40+
StaticBool{true}() = True()
41+
StaticBool{false}() = False()
42+
StaticBool(x::StaticBool) = x
43+
function StaticBool(x::Bool)
44+
if x
45+
return True()
46+
else
47+
return False()
48+
end
49+
end
3050

3151
"""
3252
StaticInt(N::Int) -> StaticInt{N}()
@@ -41,6 +61,10 @@ struct StaticInt{N} <: StaticInteger{N}
4161
StaticInt(::Val{N}) where {N} = StaticInt(N)
4262
end
4363

64+
include("float.jl")
65+
66+
const StaticNumber{N} = Union{StaticInt{N}, StaticBool{N}, StaticFloat64{N}}
67+
4468
Base.getindex(x::Tuple, ::StaticInt{N}) where {N} = getfield(x, N)
4569

4670
Base.zero(@nospecialize(::StaticInt)) = StaticInt{0}()
@@ -50,42 +74,6 @@ function Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, ::StaticNumber{N
5074
checkindex(Bool, inds, N)
5175
end
5276

53-
"""
54-
StaticFloat64{N}
55-
56-
A statically sized `Float64`.
57-
Use `StaticInt(N)` instead of `Val(N)` when you want it to behave like a number.
58-
"""
59-
struct StaticFloat64{N} <: StaticNumber{N}
60-
StaticFloat64{N}() where {N} = new{N::Float64}()
61-
StaticFloat64(x::Float64) = new{x}()
62-
StaticFloat64(x::Int) = new{Base.sitofp(Float64, x)::Float64}()
63-
StaticFloat64(x::StaticInt{N}) where {N} = StaticFloat64(convert(Float64, N))
64-
StaticFloat64(x::Complex) = StaticFloat64(convert(Float64, x))
65-
end
66-
67-
"""
68-
StaticBool(x::Bool) -> True/False
69-
70-
A statically typed `Bool`.
71-
"""
72-
abstract type StaticBool{bool} <: StaticInteger{bool} end
73-
74-
struct True <: StaticBool{true} end
75-
76-
struct False <: StaticBool{false} end
77-
78-
StaticBool{true}() = True()
79-
StaticBool{false}() = False()
80-
StaticBool(x::StaticBool) = x
81-
function StaticBool(x::Bool)
82-
if x
83-
return True()
84-
else
85-
return False()
86-
end
87-
end
88-
8977
ifelse(::True, @nospecialize(x), @nospecialize(y)) = x
9078
ifelse(::False, @nospecialize(x), @nospecialize(y)) = y
9179

@@ -304,16 +292,22 @@ function Base.promote_rule(@nospecialize(T1::Type{<:StaticNumber}),
304292
promote_rule(T2, eltype(T1))
305293
end
306294

307-
Base.:(~)(::StaticNumber{N}) where {N} = static(~N)
295+
Base.:(~)(::StaticInteger{N}) where {N} = static(~N)
308296

309-
Base.inv(x::StaticNumber{N}) where {N} = one(x) / x
297+
Base.inv(x::StaticInteger{N}) where {N} = one(x) / x
298+
299+
Base.zero(@nospecialize T::Type{<:StaticInt}) = StaticInt(0)
300+
Base.zero(@nospecialize T::Type{<:StaticBool}) = False()
301+
302+
Base.one(@nospecialize T::Type{<:StaticBool}) = True()
303+
Base.one(@nospecialize T::Type{<:StaticInt}) = StaticInt(1)
310304

311-
@inline Base.one(@nospecialize T::Type{<:StaticNumber}) = static(one(eltype(T)))
312-
@inline Base.zero(@nospecialize T::Type{<:StaticNumber}) = static(zero(eltype(T)))
313305
@inline Base.iszero(::Union{StaticInt{0}, StaticFloat64{0.0}, False}) = true
314-
@inline Base.iszero(@nospecialize x::StaticNumber) = false
315-
@inline Base.isone(::Union{One, FloatOne, True}) = true
316-
@inline Base.isone(@nospecialize x::StaticNumber) = false
306+
@inline Base.iszero(@nospecialize x::Union{StaticInt, True, StaticFloat64}) = false
307+
308+
@inline Base.isone(::Union{One, True, StaticFloat64{1.0}}) = true
309+
@inline Base.isone(@nospecialize x::Union{StaticInt, False, StaticFloat64}) = false
310+
317311
@inline Base.iseven(@nospecialize x::StaticNumber) = iseven(known(x))
318312
@inline Base.isodd(@nospecialize x::StaticNumber) = isodd(known(x))
319313

@@ -332,7 +326,7 @@ end
332326
#Base.Bool(::StaticInt{N}) where {N} = Bool(N)
333327

334328
Base.Integer(@nospecialize(x::StaticInt)) = x
335-
(::Type{T})(x::StaticNumber) where {T <: Real} = T(known(x))
329+
(::Type{T})(x::StaticInteger) where {T <: Real} = T(known(x))
336330
function (@nospecialize(T::Type{<:StaticNumber}))(x::Union{AbstractFloat,
337331
AbstractIrrational, Integer,
338332
Rational})
@@ -342,10 +336,10 @@ end
342336
@inline Base.:(-)(::StaticNumber{N}) where {N} = static(-N)
343337
Base.:(*)(::Union{AbstractFloat, AbstractIrrational, Integer, Rational}, y::Zero) = y
344338
Base.:(*)(x::Zero, ::Union{AbstractFloat, AbstractIrrational, Integer, Rational}) = x
345-
Base.:(*)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(X * Y)
346-
Base.:(/)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(X / Y)
347-
Base.:(-)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(X - Y)
348-
Base.:(+)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(X + Y)
339+
Base.:(*)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X * Y)
340+
Base.:(/)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X / Y)
341+
Base.:(-)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X - Y)
342+
Base.:(+)(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(X + Y)
349343
Base.:(-)(x::Ptr, ::StaticInt{N}) where {N} = x - N
350344
Base.:(-)(::StaticInt{N}, y::Ptr) where {N} = y - N
351345
Base.:(+)(x::Ptr, ::StaticInt{N}) where {N} = x + N
@@ -356,39 +350,32 @@ Base.:(+)(::StaticInt{N}, y::Ptr) where {N} = y + N
356350
function Base.div(::StaticNumber{X}, ::StaticNumber{Y}, m::RoundingMode) where {X, Y}
357351
static(div(X, Y, m))
358352
end
359-
Base.div(x::Real, ::StaticNumber{Y}, m::RoundingMode) where {Y} = div(x, Y, m)
353+
Base.div(x::Real, ::StaticInteger{Y}, m::RoundingMode) where {Y} = div(x, Y, m)
360354
Base.div(::StaticNumber{X}, y::Real, m::RoundingMode) where {X} = div(X, y, m)
361355
Base.div(x::StaticBool, y::False) = throw(DivideError())
362356
Base.div(x::StaticBool, y::True) = x
363357

364358
Base.rem(@nospecialize(x::StaticNumber), T::Type{<:Integer}) = rem(known(x), T)
365359
Base.rem(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(rem(X, Y))
366-
Base.rem(x::Real, ::StaticNumber{Y}) where {Y} = rem(x, Y)
367-
Base.rem(::StaticNumber{X}, y::Real) where {X} = rem(X, y)
368-
360+
Base.rem(x::Real, ::StaticInteger{Y}) where {Y} = rem(x, Y)
361+
Base.rem(::StaticInteger{X}, y::Real) where {X} = rem(X, y)
369362
Base.mod(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(mod(X, Y))
370363

371-
Base.round(::StaticFloat64{M}) where {M} = StaticFloat64(round(M))
372-
roundtostaticint(::StaticFloat64{M}) where {M} = StaticInt(round(Int, M))
373-
roundtostaticint(x::AbstractFloat) = round(Int, x)
374-
floortostaticint(::StaticFloat64{M}) where {M} = StaticInt(Base.fptosi(Int, M))
375-
floortostaticint(x::AbstractFloat) = Base.fptosi(Int, x)
376-
377364
Base.:(==)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = ==(X, Y)
378365

379366
Base.:(<)(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = <(X, Y)
380367

381-
Base.isless(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = isless(X, Y)
382-
Base.isless(::StaticNumber{X}, y::Real) where {X} = isless(X, y)
368+
Base.isless(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = isless(X, Y)
369+
Base.isless(::StaticInteger{X}, y::Real) where {X} = isless(X, y)
383370
Base.isless(x::Real, ::StaticInteger{Y}) where {Y} = isless(x, Y)
384371

385-
Base.min(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(min(X, Y))
386-
Base.min(::StaticNumber{X}, y::Number) where {X} = min(X, y)
387-
Base.min(x::Number, ::StaticNumber{Y}) where {Y} = min(x, Y)
372+
Base.min(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(min(X, Y))
373+
Base.min(::StaticInteger{X}, y::Number) where {X} = min(X, y)
374+
Base.min(x::Number, ::StaticInteger{Y}) where {Y} = min(x, Y)
388375

389-
Base.max(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(max(X, Y))
390-
Base.max(::StaticNumber{X}, y::Number) where {X} = max(X, y)
391-
Base.max(x::Number, ::StaticNumber{Y}) where {Y} = max(x, Y)
376+
Base.max(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(max(X, Y))
377+
Base.max(::StaticInteger{X}, y::Number) where {X} = max(X, y)
378+
Base.max(x::Number, ::StaticInteger{Y}) where {Y} = max(x, Y)
392379

393380
Base.minmax(::StaticNumber{X}, ::StaticNumber{Y}) where {X, Y} = static(minmax(X, Y))
394381

@@ -448,57 +435,6 @@ Functionally equivalent to `fieldtype(T, f)` except `f` may be a static type.
448435
@inline field_type(::Type{T}, ::StaticInt{N}) where {T, N} = fieldtype(T, N)
449436
@inline field_type(::Type{T}, ::StaticSymbol{S}) where {T, S} = fieldtype(T, S)
450437

451-
Base.rad2deg(::StaticFloat64{M}) where {M} = StaticFloat64(rad2deg(M))
452-
Base.deg2rad(::StaticFloat64{M}) where {M} = StaticFloat64(deg2rad(M))
453-
@generated Base.cbrt(::StaticFloat64{M}) where {M} = StaticFloat64(cbrt(M))
454-
Base.mod2pi(::StaticFloat64{M}) where {M} = StaticFloat64(mod2pi(M))
455-
@generated Base.sinpi(::StaticFloat64{M}) where {M} = StaticFloat64(sinpi(M))
456-
@generated Base.cospi(::StaticFloat64{M}) where {M} = StaticFloat64(cospi(M))
457-
Base.exp(::StaticFloat64{M}) where {M} = StaticFloat64(exp(M))
458-
Base.exp2(::StaticFloat64{M}) where {M} = StaticFloat64(exp2(M))
459-
Base.exp10(::StaticFloat64{M}) where {M} = StaticFloat64(exp10(M))
460-
@generated Base.expm1(::StaticFloat64{M}) where {M} = StaticFloat64(expm1(M))
461-
@generated Base.log(::StaticFloat64{M}) where {M} = StaticFloat64(log(M))
462-
@generated Base.log2(::StaticFloat64{M}) where {M} = StaticFloat64(log2(M))
463-
@generated Base.log10(::StaticFloat64{M}) where {M} = StaticFloat64(log10(M))
464-
@generated Base.log1p(::StaticFloat64{M}) where {M} = StaticFloat64(log1p(M))
465-
@generated Base.sin(::StaticFloat64{M}) where {M} = StaticFloat64(sin(M))
466-
@generated Base.cos(::StaticFloat64{M}) where {M} = StaticFloat64(cos(M))
467-
@generated Base.tan(::StaticFloat64{M}) where {M} = StaticFloat64(tan(M))
468-
Base.sec(x::StaticFloat64{M}) where {M} = inv(cos(x))
469-
Base.csc(x::StaticFloat64{M}) where {M} = inv(sin(x))
470-
Base.cot(x::StaticFloat64{M}) where {M} = inv(tan(x))
471-
@generated Base.asin(::StaticFloat64{M}) where {M} = StaticFloat64(asin(M))
472-
@generated Base.acos(::StaticFloat64{M}) where {M} = StaticFloat64(acos(M))
473-
@generated Base.atan(::StaticFloat64{M}) where {M} = StaticFloat64(atan(M))
474-
@generated Base.sind(::StaticFloat64{M}) where {M} = StaticFloat64(sind(M))
475-
@generated Base.cosd(::StaticFloat64{M}) where {M} = StaticFloat64(cosd(M))
476-
Base.tand(x::StaticFloat64{M}) where {M} = sind(x) / cosd(x)
477-
Base.secd(x::StaticFloat64{M}) where {M} = inv(cosd(x))
478-
Base.cscd(x::StaticFloat64{M}) where {M} = inv(sind(x))
479-
Base.cotd(x::StaticFloat64{M}) where {M} = inv(tand(x))
480-
Base.asind(x::StaticFloat64{M}) where {M} = rad2deg(asin(x))
481-
Base.acosd(x::StaticFloat64{M}) where {M} = rad2deg(acos(x))
482-
Base.asecd(x::StaticFloat64{M}) where {M} = rad2deg(asec(x))
483-
Base.acscd(x::StaticFloat64{M}) where {M} = rad2deg(acsc(x))
484-
Base.acotd(x::StaticFloat64{M}) where {M} = rad2deg(acot(x))
485-
Base.atand(x::StaticFloat64{M}) where {M} = rad2deg(atan(x))
486-
@generated Base.sinh(::StaticFloat64{M}) where {M} = StaticFloat64(sinh(M))
487-
Base.cosh(::StaticFloat64{M}) where {M} = StaticFloat64(cosh(M))
488-
Base.tanh(x::StaticFloat64{M}) where {M} = StaticFloat64(tanh(M))
489-
Base.sech(x::StaticFloat64{M}) where {M} = inv(cosh(x))
490-
Base.csch(x::StaticFloat64{M}) where {M} = inv(sinh(x))
491-
Base.coth(x::StaticFloat64{M}) where {M} = inv(tanh(x))
492-
@generated Base.asinh(::StaticFloat64{M}) where {M} = StaticFloat64(asinh(M))
493-
@generated Base.acosh(::StaticFloat64{M}) where {M} = StaticFloat64(acosh(M))
494-
@generated Base.atanh(::StaticFloat64{M}) where {M} = StaticFloat64(atanh(M))
495-
Base.asech(x::StaticFloat64{M}) where {M} = acosh(inv(x))
496-
Base.acsch(x::StaticFloat64{M}) where {M} = asinh(inv(x))
497-
Base.acoth(x::StaticFloat64{M}) where {M} = atanh(inv(x))
498-
Base.asec(x::StaticFloat64{M}) where {M} = acos(inv(x))
499-
Base.acsc(x::StaticFloat64{M}) where {M} = asin(inv(x))
500-
Base.acot(x::StaticFloat64{M}) where {M} = atan(inv(x))
501-
502438
@inline Base.exponent(::StaticNumber{M}) where {M} = static(exponent(M))
503439

504440
Base.:(^)(::StaticFloat64{x}, y::Float64) where {x} = exp2(log2(x) * y)
@@ -935,10 +871,12 @@ end
935871
function Base.show(io::IO, ::MIME"text/plain",
936872
@nospecialize(x::Union{StaticNumber, StaticSymbol}))
937873
print(io, "static(" * repr(known(typeof(x))) * ")")
874+
nothing
938875
end
939876
function Base.show(io::IO, m::MIME"text/plain", @nospecialize(x::NDIndex))
940877
print(io, "NDIndex")
941878
show(io, m, Tuple(x))
879+
nothing
942880
end
943881

944882
end

src/float.jl

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
"""
3+
StaticFloat64{N}
4+
5+
A statically sized `Float64`.
6+
Use `StaticInt(N)` instead of `Val(N)` when you want it to behave like a number.
7+
"""
8+
struct StaticFloat64{N} <: Real
9+
StaticFloat64{N}() where {N} = new{N::Float64}()
10+
StaticFloat64(x::Float64) = new{x}()
11+
StaticFloat64(x::Int) = new{Base.sitofp(Float64, x)::Float64}()
12+
StaticFloat64(x::StaticInt{N}) where {N} = StaticFloat64(convert(Float64, N))
13+
StaticFloat64(x::Complex) = StaticFloat64(convert(Float64, x))
14+
StaticFloat64(@nospecialize x::StaticFloat64) = x
15+
end
16+
17+
Base.zero(@nospecialize T::Type{<:StaticFloat64}) = Float64(0.0)
18+
Base.one(@nospecialize T::Type{<:StaticFloat64}) = Float64(1.0)
19+
20+
Base.round(::StaticFloat64{M}) where {M} = StaticFloat64(round(M))
21+
roundtostaticint(::StaticFloat64{M}) where {M} = StaticInt(round(Int, M))
22+
roundtostaticint(x::AbstractFloat) = round(Int, x)
23+
floortostaticint(::StaticFloat64{M}) where {M} = StaticInt(Base.fptosi(Int, M))
24+
floortostaticint(x::AbstractFloat) = Base.fptosi(Int, x)
25+
26+
Base.rad2deg(::StaticFloat64{M}) where {M} = StaticFloat64(rad2deg(M))
27+
Base.deg2rad(::StaticFloat64{M}) where {M} = StaticFloat64(deg2rad(M))
28+
@generated Base.cbrt(::StaticFloat64{M}) where {M} = StaticFloat64(cbrt(M))
29+
Base.mod2pi(::StaticFloat64{M}) where {M} = StaticFloat64(mod2pi(M))
30+
@generated Base.sinpi(::StaticFloat64{M}) where {M} = StaticFloat64(sinpi(M))
31+
@generated Base.cospi(::StaticFloat64{M}) where {M} = StaticFloat64(cospi(M))
32+
Base.exp(::StaticFloat64{M}) where {M} = StaticFloat64(exp(M))
33+
Base.exp2(::StaticFloat64{M}) where {M} = StaticFloat64(exp2(M))
34+
Base.exp10(::StaticFloat64{M}) where {M} = StaticFloat64(exp10(M))
35+
@generated Base.expm1(::StaticFloat64{M}) where {M} = StaticFloat64(expm1(M))
36+
@generated Base.log(::StaticFloat64{M}) where {M} = StaticFloat64(log(M))
37+
@generated Base.log2(::StaticFloat64{M}) where {M} = StaticFloat64(log2(M))
38+
@generated Base.log10(::StaticFloat64{M}) where {M} = StaticFloat64(log10(M))
39+
@generated Base.log1p(::StaticFloat64{M}) where {M} = StaticFloat64(log1p(M))
40+
@generated Base.sin(::StaticFloat64{M}) where {M} = StaticFloat64(sin(M))
41+
@generated Base.cos(::StaticFloat64{M}) where {M} = StaticFloat64(cos(M))
42+
@generated Base.tan(::StaticFloat64{M}) where {M} = StaticFloat64(tan(M))
43+
Base.sec(x::StaticFloat64{M}) where {M} = inv(cos(x))
44+
Base.csc(x::StaticFloat64{M}) where {M} = inv(sin(x))
45+
Base.cot(x::StaticFloat64{M}) where {M} = inv(tan(x))
46+
@generated Base.asin(::StaticFloat64{M}) where {M} = StaticFloat64(asin(M))
47+
@generated Base.acos(::StaticFloat64{M}) where {M} = StaticFloat64(acos(M))
48+
@generated Base.atan(::StaticFloat64{M}) where {M} = StaticFloat64(atan(M))
49+
@generated Base.sind(::StaticFloat64{M}) where {M} = StaticFloat64(sind(M))
50+
@generated Base.cosd(::StaticFloat64{M}) where {M} = StaticFloat64(cosd(M))
51+
Base.tand(x::StaticFloat64{M}) where {M} = sind(x) / cosd(x)
52+
Base.secd(x::StaticFloat64{M}) where {M} = inv(cosd(x))
53+
Base.cscd(x::StaticFloat64{M}) where {M} = inv(sind(x))
54+
Base.cotd(x::StaticFloat64{M}) where {M} = inv(tand(x))
55+
Base.asind(x::StaticFloat64{M}) where {M} = rad2deg(asin(x))
56+
Base.acosd(x::StaticFloat64{M}) where {M} = rad2deg(acos(x))
57+
Base.asecd(x::StaticFloat64{M}) where {M} = rad2deg(asec(x))
58+
Base.acscd(x::StaticFloat64{M}) where {M} = rad2deg(acsc(x))
59+
Base.acotd(x::StaticFloat64{M}) where {M} = rad2deg(acot(x))
60+
Base.atand(x::StaticFloat64{M}) where {M} = rad2deg(atan(x))
61+
@generated Base.sinh(::StaticFloat64{M}) where {M} = StaticFloat64(sinh(M))
62+
Base.cosh(::StaticFloat64{M}) where {M} = StaticFloat64(cosh(M))
63+
Base.tanh(x::StaticFloat64{M}) where {M} = StaticFloat64(tanh(M))
64+
Base.sech(x::StaticFloat64{M}) where {M} = inv(cosh(x))
65+
Base.csch(x::StaticFloat64{M}) where {M} = inv(sinh(x))
66+
Base.coth(x::StaticFloat64{M}) where {M} = inv(tanh(x))
67+
@generated Base.asinh(::StaticFloat64{M}) where {M} = StaticFloat64(asinh(M))
68+
@generated Base.acosh(::StaticFloat64{M}) where {M} = StaticFloat64(acosh(M))
69+
@generated Base.atanh(::StaticFloat64{M}) where {M} = StaticFloat64(atanh(M))
70+
Base.asech(x::StaticFloat64{M}) where {M} = acosh(inv(x))
71+
Base.acsch(x::StaticFloat64{M}) where {M} = asinh(inv(x))
72+
Base.acoth(x::StaticFloat64{M}) where {M} = atanh(inv(x))
73+
Base.asec(x::StaticFloat64{M}) where {M} = acos(inv(x))
74+
Base.acsc(x::StaticFloat64{M}) where {M} = asin(inv(x))
75+
Base.acot(x::StaticFloat64{M}) where {M} = atan(inv(x))
76+
77+
Base.rem(x::Real, ::StaticFloat64{Y}) where {Y} = rem(x, Y)
78+
Base.rem(::StaticFloat64{X}, y::Real) where {X} = rem(X, y)
79+
Base.rem(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = StaticFloat64(rem(X, Y))
80+
81+
Base.min(x::StaticFloat64{X}, y::StaticFloat64{Y}) where {X, Y} = X > Y ? y : x
82+
Base.min(x::Real, ::StaticFloat64{Y}) where {Y} = min(x, Y)
83+
Base.min(::StaticFloat64{X}, y::Real) where {X} = min(X, y)
84+
85+
Base.max(x::StaticFloat64{X}, y::StaticFloat64{Y}) where {X, Y} = X > Y ? x : y
86+
Base.max(x::Real, ::StaticFloat64{Y}) where {Y} = max(x, Y)
87+
Base.max(::StaticFloat64{X}, y::Real) where {X} = max(X, y)
88+
89+
Base.isless(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = isless(X, Y)
90+
Base.isless(x::AbstractFloat, ::StaticFloat64{Y}) where {Y} = isless(x, Y)
91+
Base.isless(::StaticFloat64{X}, y::AbstractFloat) where {X} = isless(X, y)
92+
93+
Base.inv(::StaticFloat64{N}) where {N} = StaticFloat64(1.0 / N)
94+
95+
Base.:(*)(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = static(X * Y)
96+
Base.:(/)(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = static(X / Y)
97+
Base.:(-)(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = static(X - Y)
98+
Base.:(+)(::StaticFloat64{X}, ::StaticFloat64{Y}) where {X, Y} = static(X + Y)

0 commit comments

Comments
 (0)