AlgebraResultTypes.number_typeMethod
number_type(x)

When the argument is a Number, return its type, when a container, return its element type in case it can be determined to be <: Number.

Recommended usage

Simplify

function foo(x::T1, A::AbstractArray{T2}, b::AbstractVector{T3}) where {T1,T2,T3}
    T = result_field(T1, T2, T3)
    ...
end

to

function foo(x, A, b)
    T = result_field(number_type.(x, A, b)...)
    ...
end

in situations where the types are not needed otherwise.

AlgebraResultTypes.result_fieldMethod
result_field(T1, T2, ...)

Return a supertype of the result type of applying operation +, -, *, / on the given types. Ideally, for concrete types, this is the narrowest concrete type.

You may want to apply widen to the result for complex calculations.

Formally, for any values x1::T1, x2::T2, ..., where T1, T2, ... <: Number, and operations op1, op2, ... ∈ (+, -, *, /),

op1(x1, op2(x2, op3(x3, ...))) isa result_field(T1, T2, T3, ...)

Any violation of this is a bug, and should be reported as an issue.

The implementation uses heuristics, and may not find the narrowest type, falling back to Number for non-concrete types. Please open an issue if you think this can be improved for some concrete types.

AlgebraResultTypes.result_ringMethod
result_ring(T1, T2, ...)

Return a supertype of the result type of applying operation +, -, *, on the given types. Ideally, for concrete types, this is the narrowest concrete type.

You may want to apply widen to the result for complex calculations.

See result_field for details, mutatis mutandis.