struct Perturbator
rng::AbstractRNG
end
function (a::Perturbator)()
randn(a.rng)
end
const MultiLike = Union{Tuple,Array}
+′(a,b) = a + b
-′(a,b) = a - b
*′(a,b) = a * b
/′(a,b) = a / b
+′(a::T,b) where T <: MultiLike = a .+′ b
-′(a::T,b) where T <: MultiLike = a .-′ b
*′(a::T,b) where T <: MultiLike = a .*′ b
/′(a::T,b) where T <: MultiLike = a ./′ b
+′(a,b::T) where T <: MultiLike = a .+′ b
-′(a,b::T) where T <: MultiLike = a .-′ b
*′(a,b::T) where T <: MultiLike = a .*′ b
/′(a,b::T) where T <: MultiLike = a ./′ b
+′(a::T,b::R) where {T <: MultiLike,R <: MultiLike} = a .+′ b
-′(a::T,b::R) where {T <: MultiLike,R <: MultiLike} = a .-′ b
*′(a::T,b::R) where {T <: MultiLike,R <: MultiLike} = a .*′ b
/′(a::T,b::R) where {T <: MultiLike,R <: MultiLike} = a ./′ b
+′(a::R,b::T) where {T <: MultiLike,R <: MultiLike} = a .+′ b
-′(a::R,b::T) where {T <: MultiLike,R <: MultiLike} = a .-′ b
*′(a::R,b::T) where {T <: MultiLike,R <: MultiLike} = a .*′ b
/′(a::R,b::T) where {T <: MultiLike,R <: MultiLike} = a ./′ b
+′(a::T,b) where T<:Integer = round(T,a + b)
-′(a::T,b) where T<:Integer = round(T,a - b)
*′(a::T,b) where T<:Integer = round(T,a * b)
/′(a::T,b) where T<:Integer = round(T,a / b)
+′(a,b::T) where T<:Integer = round(T,a + b)
-′(a,b::T) where T<:Integer = round(T,a - b)
*′(a,b::T) where T<:Integer = round(T,a * b)
/′(a,b::T) where T<:Integer = round(T,a / b)
+′(a,b::Perturbator) = a +′ b()
-′(a,b::Perturbator) = a -′ b()
*′(a,b::Perturbator) = a *′ b()
/′(a,b::Perturbator) = a /′ b()
+′(a::Perturbator,b) = a() +′ b
-′(a::Perturbator,b) = a() -′ b
*′(a::Perturbator,b) = a() *′ b
/′(a::Perturbator,b) = a() /′ b
+′(a::T,b::Perturbator) where T <: MultiLike = a .+′ Ref(b)
-′(a::T,b::Perturbator) where T <: MultiLike = a .-′ Ref(b)
*′(a::T,b::Perturbator) where T <: MultiLike = a .*′ Ref(b)
/′(a::T,b::Perturbator) where T <: MultiLike = a ./′ Ref(b)
+′(a::Perturbator,b::T) where T <: MultiLike = Ref(a) .+′ b
-′(a::Perturbator,b::T) where T <: MultiLike = Ref(a) .-′ b
*′(a::Perturbator,b::T) where T <: MultiLike = Ref(a) .*′ b
/′(a::Perturbator,b::T) where T <: MultiLike = Ref(a) ./′ b
+′(a::T,b::Perturbator) where T<:Integer = round(T,a + b())
-′(a::T,b::Perturbator) where T<:Integer = round(T,a - b())
*′(a::T,b::Perturbator) where T<:Integer = round(T,a * b())
/′(a::T,b::Perturbator) where T<:Integer = round(T,a / b())
+′(a::Perturbator,b::T) where T<:Integer = round(T,a() + b)
-′(a::Perturbator,b::T) where T<:Integer = round(T,a() - b)
*′(a::Perturbator,b::T) where T<:Integer = round(T,a() * b)
/′(a::Perturbator,b::T) where T<:Integer = round(T,a() / b)
what i would like is to naturally operate on these object via primed operators, but this type hierarchy has become ridiculous, is there a way to shorten it and make it manageable?