From 8385e710a31dc9c2a5d3167496685ab3d6586278 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier <4486578+briochemc@users.noreply.github.com> Date: Wed, 25 May 2022 09:48:07 +1000 Subject: [PATCH] Fix issue #39 --- Project.toml | 2 +- src/hyperdual.jl | 1 + test/test_basics.jl | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ceabcdc..c1f367a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HyperDualNumbers" uuid = "50ceba7f-c3ee-5a84-a6e8-3ad40456ec97" authors = ["Rob J Goedman "] -version = "4.0.8" +version = "4.0.9" [deps] Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" diff --git a/src/hyperdual.jl b/src/hyperdual.jl index fcd407e..ee24f6c 100644 --- a/src/hyperdual.jl +++ b/src/hyperdual.jl @@ -8,6 +8,7 @@ struct Hyper{T<:ReComp} <: Number end Hyper(x::S, y::T, z::U, w::V) where {S<:ReComp,T<:ReComp,U<:ReComp,V<:ReComp} = Hyper(promote(x,y,z,w)...) Hyper(x::ReComp) = Hyper(x, zero(x), zero(x), zero(x)) +Hyper{T}(x::ReComp) where T<:ReComp = Hyper{T}(T(x), zero(T), zero(T), zero(T)) """ Creation of a HyperDualNumber diff --git a/test/test_basics.jl b/test/test_basics.jl index 1e6128f..d29547a 100644 --- a/test/test_basics.jl +++ b/test/test_basics.jl @@ -15,6 +15,8 @@ hd9 = hyper(-1.0, -2.0, -3.0, -4.0) hdNaN = hyper(0/0) +hd_from_f32 = Hyper{Float64}(1f2) + # Addition and subtraction @test ε₁part(hd1) == 0.0 @test isequal(hd1 + hd2, hyper(2.0, 2.0, 3.0, 4.0))