Skip to content

Commit

Permalink
compare only real components with ==. closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Jun 1, 2014
1 parent a9ff70a commit 337539f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ imaginary part represents the fermionic direction), in screw theory, in motor
and spatial vector algebra, and in computer science due to its relation with the
forward mode of automatic differentiation.

The `ForwardDiff` package implements forward mode automatic differentiation in Julia using several approaches. One
The [ForwardDiff](https://github.com/scidom/ForwardDiff.jl) package implements forward mode automatic differentiation in Julia using several approaches. One
of these approaches employs dual numbers. For this reason, the `ForwardDiff` package relies on `DualNumbers`. The
user is referred to `ForwardDiff` for some examples on how to perform forward mode automatic differentiation using
dual numbers in Julia.
Expand Down Expand Up @@ -49,6 +49,10 @@ numerical derivatives, for example, ``conj``, ``abs`` and ``abs2``. In these
cases, we choose to follow the rule ``f(x::Dual) = Dual(f(real(x)),epsilon(x)*f'(real(x)))``,
where ``f'`` is the derivative of ``f``. The mathematical definitions are
available using the functions with the suffix ``dual``.
Similarly, comparison operators ``<``, ``>``, and ``==`` are overloaded to compare only real
components.




### A walk-through example
Expand Down
2 changes: 1 addition & 1 deletion src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
convert(::Type{Dual}, z::Dual) = z
convert(::Type{Dual}, x::Real) = dual(x)

==(z::Dual, w::Dual) = real(z) == real(w) && epsilon(z) == epsilon(w)
==(z::Dual, w::Dual) = real(z) == real(w)
# ==(z::Dual, x::Real) = real_valued(z) && real(z) == x
# ==(x::Real, z::Dual) = real_valued(z) && real(z) == x

Expand Down

0 comments on commit 337539f

Please sign in to comment.