Skip to content

Commit ab27e9f

Browse files
authored
Merge pull request #15 from JuliaDiff/ox/comment-1
add some comments and docstrings to Differentiables
2 parents ccead4f + 9301583 commit ab27e9f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/differentials.jl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ mul_wirtinger(a, b::Wirtinger) = Wirtinger(mul(a, b.primal), mul(a, b.conjugate)
153153
#####
154154

155155
"""
156-
TODO
156+
Casted(v)
157+
158+
This differential wraps another differential (including a number-like type)
159+
to indicate that it should be lazily broadcast.
157160
"""
158161
struct Casted{V} <: AbstractDifferential
159162
value::V
@@ -184,11 +187,13 @@ mul_casted(a, b::Casted) = Casted(broadcasted(mul, a, b.value))
184187
#####
185188

186189
"""
187-
TODO
190+
Zero()
191+
The additive identity for differentials.
192+
This is basically the same as `0`.
188193
"""
189194
struct Zero <: AbstractDifferential end
190195

191-
extern(x::Zero) = false
196+
extern(x::Zero) = false # false is a strong 0. E.g. `false * NaN = 0.0`
192197

193198
Base.Broadcast.broadcastable(::Zero) = Ref(Zero())
194199

@@ -208,7 +213,11 @@ mul_zero(::Any, ::Zero) = Zero()
208213
#####
209214

210215
"""
211-
TODO
216+
DNE()
217+
218+
This differential indicates that the derivative Does Not Exist (D.N.E).
219+
This is not the cast that it is not implemented, but rather that it mathematically
220+
is not defined.
212221
"""
213222
struct DNE <: AbstractDifferential end
214223

@@ -232,11 +241,13 @@ mul_dne(::Any, ::DNE) = DNE()
232241
#####
233242

234243
"""
235-
TODO
244+
One()
245+
The Differential which is the multiplicative identity.
246+
Basically, this represents `1`.
236247
"""
237248
struct One <: AbstractDifferential end
238249

239-
extern(x::One) = true
250+
extern(x::One) = true # true is a strong 1.
240251

241252
Base.Broadcast.broadcastable(::One) = Ref(One())
242253

@@ -256,7 +267,9 @@ mul_one(a, ::One) = a
256267
#####
257268

258269
"""
259-
TODO
270+
Thunk(()->v)
271+
A thunk is a deferred computation.
272+
It wraps a zero argument closure that when invoked returns a differential.
260273
"""
261274
struct Thunk{F} <: AbstractDifferential
262275
f::F

0 commit comments

Comments
 (0)