Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add norm for Vector{T<:Dual} #31

Closed
dlfivefifty opened this issue Dec 8, 2015 · 6 comments
Closed

Add norm for Vector{T<:Dual} #31

dlfivefifty opened this issue Dec 8, 2015 · 6 comments

Comments

@dlfivefifty
Copy link
Collaborator

julia> norm([dual(1.,2.),dual(3.,2.)])
ERROR: InexactError()
 in float at float.jl:121
 in generic_vecnormInf at linalg/generic.jl:92
 in generic_vecnorm2 at linalg/generic.jl:114
 in vecnorm at linalg/generic.jl:175
 in norm at linalg/generic.jl:191
@jrevels
Copy link
Member

jrevels commented Dec 8, 2015

see JuliaDiff/ForwardDiff.jl#52 for prior experience with this, the key is to define float(::Dual)

@dlfivefifty
Copy link
Collaborator Author

I’d expect norm(::Vector{T<:Dual}) to return a Dual. Does this change result in that?

On 9 Dec 2015, at 1:57 AM, Jarrett Revels [email protected] wrote:

see JuliaDiff/ForwardDiff.jl#52 JuliaDiff/ForwardDiff.jl#52 for prior experience with this, the key is to define float(::Dual)


Reply to this email directly or view it on GitHub #31 (comment).

@jrevels
Copy link
Member

jrevels commented Dec 9, 2015

The definition I'm thinking of is:

float(d::Dual) = Dual(float(value(d)), float(epsilon(d)))

With that definition, yes, norm(::Vector{T<:Dual}) should return a Dual

@dlfivefifty
Copy link
Collaborator Author

OK, thanks! Are you planning to add this definition to DualNumbers.jl?

On 9 Dec 2015, at 12:10 PM, Jarrett Revels [email protected] wrote:

The definition I'm thinking of is:

float(d::Dual) = Dual(float(value(d)), float(epsilon(d)))
With that definition, yes, norm(::Vector{T<:Dual}) should return a Dual


Reply to this email directly or view it on GitHub #31 (comment).

@MikaelSlevinsky
Copy link
Contributor

i thought i added this in #29? Yep, I also added a test.

@dlfivefifty
Copy link
Collaborator Author

This has been implemented apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants