Skip to content

Does fastabs(z::Complex) mean something different than faster computation of abs(z::Complex)? #40440

@chenspc

Description

@chenspc

I came across the fastabs function here in SpecialFunctions.jl and here in Base.Math. I'm confused by its definition.

julia> z = 3 + 4im
3 + 4im

julia> abs(z)
5.0

julia> Base.Math.fastabs(z)
7

Shouldn't it be something like below?

julia> fastabs(z::Complex) = (abs2(real(z)) + abs2(imag(z)))
fastabs (generic function with 1 method)

julia> fastabs(z)
5.0

Or does it mean something else?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions