Skip to content

Add constructor like Complex{Float64} #81

@hyrodium

Description

@hyrodium

The following MethodError should be fixed.

julia> using Quaternions

julia> Quaternion{Float64}(1)
QuaternionF64(1.0, 0.0, 0.0, 0.0, true)

julia> Quaternion{Float64}(1,2,3,4)
ERROR: MethodError: no method matching QuaternionF64(::Int64, ::Int64, ::Int64, ::Int64)
Closest candidates are:
  Quaternion{T}(::Any, ::Any, ::Any, ::Any, ::Any) where T<:Real at ~/.julia/dev/Quaternions/src/Quaternion.jl:2
  Quaternion{T}(::Real) where T<:Real at ~/.julia/dev/Quaternions/src/Quaternion.jl:13
  (::Type{T})(::T) where T<:Number at ~/julia/julia-1.7.1/share/julia/base/boot.jl:770
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> Complex{Float64}(1)
1.0 + 0.0im

julia> Complex{Float64}(1,2)
1.0 + 2.0im

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